Fix #3432 Hopper and Dropper item moving does not exactly match vanilla (#3442)

This commit is contained in:
mezz authored and LexManos committed 2016-11-23 12:45:07 -08:00
1 parent 95ecd2a8f4
commit 969a75154f
3 files changed
+218 -56

No files matched your search

@@ -39,17 +39,31 @@ public class VanillaHopperItemHandler extends InvWrapper
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
if (stack.func_190926_b())
return ItemStack.field_190927_a;
if (simulate || !hopper.mayTransfer())
return super.insertItem(slot, stack, simulate);
int curStackSize = stack.func_190916_E();
ItemStack itemStack = super.insertItem(slot, stack, false);
if (itemStack.func_190926_b() || curStackSize != itemStack.func_190916_E())
if (simulate)
{
hopper.setTransferCooldown(8);
return super.insertItem(slot, stack, simulate);
}
else
{
boolean wasEmpty = getInv().func_191420_l();
int originalStackSize = stack.func_190916_E();
stack = super.insertItem(slot, stack, simulate);
if (wasEmpty && originalStackSize > stack.func_190916_E())
{
if (!hopper.mayTransfer())
{
// This cooldown is always set to 8 in vanilla with one exception:
// Hopper -> Hopper transfer sets this cooldown to 7 when this hopper
// has not been updated as recently as the one pushing items into it.
// This vanilla behavior is preserved by VanillaInventoryCodeHooks#insertStack,
// the cooldown is set properly by the hopper that is pushing items into this one.
hopper.setTransferCooldown(8);
}
}
return stack;
}
return itemStack;
}
}