From 50b9abc13f2d640750d5f73bb3777f63d828c4ed Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Mon, 30 Sep 2013 11:37:37 -0700 Subject: [PATCH] Vanilla hopper should obey the IInventory contract, TileEntityHopper now takes into account IInventory.getInventoryStackLimit() when inserting items Closes #597. --- .../tileentity/TileEntityHopper.java.patch | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 patches/minecraft/net/minecraft/tileentity/TileEntityHopper.java.patch diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityHopper.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityHopper.java.patch new file mode 100644 index 000000000..ef86ad058 --- /dev/null +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityHopper.java.patch @@ -0,0 +1,38 @@ +--- ../src_base/minecraft/net/minecraft/tileentity/TileEntityHopper.java ++++ ../src_work/minecraft/net/minecraft/tileentity/TileEntityHopper.java +@@ -453,17 +453,28 @@ + + if (itemstack1 == null) + { +- par0IInventory.setInventorySlotContents(par2, par1ItemStack); +- par1ItemStack = null; ++ int max = Math.min(par1ItemStack.getMaxStackSize(), par0IInventory.getInventoryStackLimit()); ++ if (max >= par1ItemStack.stackSize) ++ { ++ par0IInventory.setInventorySlotContents(par2, par1ItemStack); ++ par1ItemStack = null; ++ } ++ else ++ { ++ par0IInventory.setInventorySlotContents(par2, par1ItemStack.splitStack(max)); ++ } + flag = true; + } + else if (areItemStacksEqualItem(itemstack1, par1ItemStack)) + { +- int k = par1ItemStack.getMaxStackSize() - itemstack1.stackSize; +- int l = Math.min(par1ItemStack.stackSize, k); +- par1ItemStack.stackSize -= l; +- itemstack1.stackSize += l; +- flag = l > 0; ++ int max = Math.min(par1ItemStack.getMaxStackSize(), par0IInventory.getInventoryStackLimit()); ++ if (max > itemstack1.stackSize) ++ { ++ int l = Math.min(par1ItemStack.stackSize, max - itemstack1.stackSize); ++ par1ItemStack.stackSize -= l; ++ itemstack1.stackSize += l; ++ flag = l > 0; ++ } + } + + if (flag)