diff --git a/block/crafting/BlockCraftingStorage.java b/block/crafting/BlockCraftingStorage.java index a17ea8225..af67349db 100644 --- a/block/crafting/BlockCraftingStorage.java +++ b/block/crafting/BlockCraftingStorage.java @@ -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) { diff --git a/block/crafting/ItemCraftingStorage.java b/block/crafting/ItemCraftingStorage.java new file mode 100644 index 000000000..df5f180ee --- /dev/null +++ b/block/crafting/ItemCraftingStorage.java @@ -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 ); + } + +} diff --git a/core/AEConfig.java b/core/AEConfig.java index 976e16fa1..08b9e98d8 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -305,7 +305,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo { if ( e == setting ) { - String Category = e.getClass().getSimpleName(); + String Category = "Client"; Property p = this.get( Category, e.name(), settings.getSetting( e ).name(), getListComment( newValue ) ); p.set( newValue.name() ); } diff --git a/core/Registration.java b/core/Registration.java index 7b2ed1ae4..af09d9e50 100644 --- a/core/Registration.java +++ b/core/Registration.java @@ -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() ); } diff --git a/core/features/AEFeature.java b/core/features/AEFeature.java index 3a95a1edf..3ec29d164 100644 --- a/core/features/AEFeature.java +++ b/core/features/AEFeature.java @@ -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; diff --git a/helpers/DualityInterface.java b/helpers/DualityInterface.java index 29ecb62fd..a46c538e7 100644 --- a/helpers/DualityInterface.java +++ b/helpers/DualityInterface.java @@ -741,8 +741,8 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt TileEntity tile = iHost.getTileEntity(); World w = tile.getWorldObj(); - boolean allAreBusy=true; - + boolean allAreBusy = true; + for (ForgeDirection s : possibleDirections) { TileEntity te = w.getTileEntity( tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ ); @@ -757,7 +757,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt } } } - + busy = allAreBusy; } @@ -814,7 +814,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt if ( ad.simulateRemove( 1, null, null ) != null ) continue; } - + if ( acceptsItems( ad, table ) ) { for (int x = 0; x < table.getSizeInventory(); x++) @@ -876,7 +876,13 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() ); if ( ad != null ) { - whatToSend = ad.addItems( whatToSend ); + ItemStack Result = ad.addItems( whatToSend ); + + if ( Result == null ) + whatToSend = null; + else + whatToSend.stackSize -= whatToSend.stackSize - Result.stackSize; + if ( whatToSend == null ) break; } diff --git a/items/storage/ItemBasicStorageCell.java b/items/storage/ItemBasicStorageCell.java index b613fc6da..3ec5cfdac 100644 --- a/items/storage/ItemBasicStorageCell.java +++ b/items/storage/ItemBasicStorageCell.java @@ -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 ); + } + } diff --git a/recipes/game/DisassembleRecipe.java b/recipes/game/DisassembleRecipe.java new file mode 100644 index 000000000..2ec0192bf --- /dev/null +++ b/recipes/game/DisassembleRecipe.java @@ -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 cellInv = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS ); + if ( cellInv != null ) + { + IItemList 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; + } + +} \ No newline at end of file diff --git a/tile/crafting/TileMolecularAssembler.java b/tile/crafting/TileMolecularAssembler.java index db338bbae..1c0a53bf5 100644 --- a/tile/crafting/TileMolecularAssembler.java +++ b/tile/crafting/TileMolecularAssembler.java @@ -133,6 +133,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn forcePlan = false; myPlan = null; myPattern = null; + pushDirection = ForgeDirection.UNKNOWN; } updateSleepyness(); @@ -206,6 +207,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn NBTTagCompound pdata = new NBTTagCompound(); pattern.writeToNBT( pdata ); data.setTag( "myPlan", pdata ); + data.setInteger( "pushDirection", pushDirection.ordinal() ); } } @@ -230,6 +232,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn { forcePlan = true; myPlan = ph; + pushDirection = ForgeDirection.getOrientation( data.getInteger( "pushDirection" ) ); } } } @@ -439,7 +442,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn { forcePlan = false; myPlan = null; + pushDirection = ForgeDirection.UNKNOWN; } + ejectHeldItems(); try