You can now disassemble Storage Cells, Crafting CPU Parts, and Encoded Patterns by crafting items by themselves.

This commit is contained in:
AlgorithmX2 2014-07-29 21:27:37 -05:00
parent f5ba33dda5
commit ba182af4e9
6 changed files with 162 additions and 1 deletions

View file

@ -17,6 +17,12 @@ public class BlockCraftingStorage extends BlockCraftingUnit
setTileEntiy( TileCraftingStorageTile.class );
}
@Override
public Class getItemBlockClass()
{
return ItemCraftingStorage.class;
}
@Override
public String getUnlocalizedName(ItemStack is)
{

View file

@ -0,0 +1,29 @@
package appeng.block.crafting;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.block.AEBaseItemBlock;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
public class ItemCraftingStorage extends AEBaseItemBlock
{
public ItemCraftingStorage(Block id) {
super( id );
}
@Override
public boolean hasContainerItem()
{
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
}
@Override
public ItemStack getContainerItem(ItemStack itemStack)
{
return AEApi.instance().blocks().blockCraftingUnit.stack( 1 );
}
}

View file

@ -139,6 +139,7 @@ import appeng.me.storage.AEExternalHandler;
import appeng.parts.PartPlacement;
import appeng.recipes.AEItemResolver;
import appeng.recipes.RecipeHandler;
import appeng.recipes.game.DisassembleRecipe;
import appeng.recipes.game.FacadeRecipe;
import appeng.recipes.game.ShapedRecipe;
import appeng.recipes.game.ShapelessRecipe;
@ -562,6 +563,9 @@ public class Registration
recipeHandler.injectRecipes();
if ( AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting ) )
CraftingManager.getInstance().getRecipeList().add( new DisassembleRecipe() );
if ( AEConfig.instance.isFeatureEnabled( AEFeature.enableFacadeCrafting ) )
CraftingManager.getInstance().getRecipeList().add( new FacadeRecipe() );
}

View file

@ -52,7 +52,9 @@ public enum AEFeature
enableFacadeCrafting("Crafting"), inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false),
AlphaPass("Rendering"), PaintBalls("Tools"), PacketLogging("Misc", false), CraftingLog("Misc", false), InterfaceTerminal("Crafting"), LightDetector("Misc");
AlphaPass("Rendering"), PaintBalls("Tools"), PacketLogging("Misc", false), CraftingLog("Misc", false), InterfaceTerminal("Crafting"), LightDetector("Misc"),
enableDisassemblyCrafting("Crafting");
String Category;
boolean visible = true;

View file

@ -20,6 +20,7 @@ import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
@ -226,4 +227,17 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
{
return dissassembleDrive( stack, world, player );
}
@Override
public boolean hasContainerItem()
{
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
}
@Override
public ItemStack getContainerItem(ItemStack itemStack)
{
return AEApi.instance().materials().materialEmptyStorageCell.stack( 1 );
}
}

View file

@ -0,0 +1,106 @@
package appeng.recipes.game;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.definitions.Blocks;
import appeng.api.definitions.Items;
import appeng.api.definitions.Materials;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
public class DisassembleRecipe implements IRecipe
{
private Materials mats = AEApi.instance().materials();
private Items items = AEApi.instance().items();
private Blocks blks = AEApi.instance().blocks();
private ItemStack getOutput(InventoryCrafting inv, boolean createFacade)
{
ItemStack hasCell = null;
for (int x = 0; x < inv.getSizeInventory(); x++)
{
ItemStack is = inv.getStackInSlot( x );
if ( is != null )
{
if ( hasCell != null )
return null;
if ( items.itemCell1k.sameAsStack( is ) )
hasCell = mats.materialCell1kPart.stack( 1 );
if ( items.itemCell4k.sameAsStack( is ) )
hasCell = mats.materialCell4kPart.stack( 1 );
if ( items.itemCell16k.sameAsStack( is ) )
hasCell = mats.materialCell16kPart.stack( 1 );
if ( items.itemCell64k.sameAsStack( is ) )
hasCell = mats.materialCell64kPart.stack( 1 );
// make sure the storage cell is empty...
if ( hasCell != null )
{
IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
if ( cellInv != null )
{
IItemList<IAEItemStack> list = cellInv.getAvailableItems( StorageChannel.ITEMS.createList() );
if ( !list.isEmpty() )
return null;
}
}
if ( items.itemEncodedPattern.sameAsStack( is ) )
hasCell = mats.materialBlankPattern.stack( 1 );
if ( blks.blockCraftingStorage1k.sameAsStack( is ) )
hasCell = mats.materialCell1kPart.stack( 1 );
if ( blks.blockCraftingStorage4k.sameAsStack( is ) )
hasCell = mats.materialCell4kPart.stack( 1 );
if ( blks.blockCraftingStorage16k.sameAsStack( is ) )
hasCell = mats.materialCell16kPart.stack( 1 );
if ( blks.blockCraftingStorage64k.sameAsStack( is ) )
hasCell = mats.materialCell64kPart.stack( 1 );
if ( hasCell == null )
return null;
}
}
return hasCell;
}
@Override
public boolean matches(InventoryCrafting inv, World w)
{
return getOutput( inv, false ) != null;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv)
{
return getOutput( inv, true );
}
@Override
public int getRecipeSize()
{
return 1;
}
@Override
public ItemStack getRecipeOutput() // no default output..
{
return null;
}
}