From a445890fcc6e6ca5a72d70287b07d90d49ed719d Mon Sep 17 00:00:00 2001 From: Rseifert Date: Fri, 1 Feb 2013 01:55:12 -0500 Subject: [PATCH] Item Crate can add items to Block Crate If you have a crate, with items in it, clicking on a create that is empty or contains the same item will result in the held crate giving some of its items to the block crate. So far now bugs but futhur testing will be need to make sure that the max limit is held as well as the item crate can still be used. Also not sure why the two computer craft api files think there new. --- .../assemblyline/common/block/BlockCrate.java | 15 ++++++++++++++- .../assemblyline/common/block/ItemBlockCrate.java | 6 +++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/minecraft/assemblyline/common/block/BlockCrate.java b/src/minecraft/assemblyline/common/block/BlockCrate.java index 99721b1a..5deed9e8 100644 --- a/src/minecraft/assemblyline/common/block/BlockCrate.java +++ b/src/minecraft/assemblyline/common/block/BlockCrate.java @@ -49,7 +49,7 @@ public class BlockCrate extends BlockMachine } tileEntity.prevClickTime = world.getWorldTime(); - + // add items if (side == 1 || (side > 1 && hitY > 0.5)) { if (allMode) @@ -61,6 +61,7 @@ public class BlockCrate extends BlockMachine this.insertCurrentItem(tileEntity, player); } } + // remove items else if (side == 0 || (side > 1 && hitY <= 0.5)) { if (allMode) @@ -100,6 +101,18 @@ public class BlockCrate extends BlockMachine { player.inventory.setInventorySlotContents(player.inventory.currentItem, this.putIn(tileEntity, currentStack)); return true; + }// if the item being used is a create then try to merge the items inside + else if (currentStack.getItem().itemID == AssemblyLine.blockCrate.blockID) + { + ItemStack containedStack = ItemBlockCrate.getContainingItemStack(currentStack); + ItemStack crateStack = tileEntity.getStackInSlot(0); + if (containedStack != null && (crateStack == null || (crateStack != null && containedStack.getItem().itemID == crateStack.getItem().itemID && containedStack.getItemDamage() == crateStack.getItemDamage()))) + { + ItemStack returned = this.putIn(tileEntity, containedStack); + ItemBlockCrate.setContainingItemStack(currentStack, returned ); + return true; + } + } } diff --git a/src/minecraft/assemblyline/common/block/ItemBlockCrate.java b/src/minecraft/assemblyline/common/block/ItemBlockCrate.java index a356e07b..ca66affa 100644 --- a/src/minecraft/assemblyline/common/block/ItemBlockCrate.java +++ b/src/minecraft/assemblyline/common/block/ItemBlockCrate.java @@ -50,7 +50,7 @@ public class ItemBlockCrate extends ItemBlock } } } - + public static void setContainingItemStack(ItemStack itemStack, ItemStack containingStack) { if (itemStack.stackTagCompound == null) @@ -66,6 +66,10 @@ public class ItemBlockCrate extends ItemBlock itemStack.getTagCompound().setTag("Item", itemTagCompound); itemStack.getTagCompound().setInteger("Count", containingStack.stackSize); + }else + { + itemStack.getTagCompound().setTag("Item", new NBTTagCompound()); + itemStack.getTagCompound().setInteger("Count", 0); } }