diff --git a/src/main/java/net/minecraftforge/items/SlotItemHandler.java b/src/main/java/net/minecraftforge/items/SlotItemHandler.java index 81b7f03c4..25d0889c4 100644 --- a/src/main/java/net/minecraftforge/items/SlotItemHandler.java +++ b/src/main/java/net/minecraftforge/items/SlotItemHandler.java @@ -43,10 +43,27 @@ public class SlotItemHandler extends Slot @Override public boolean isItemValid(@Nonnull ItemStack stack) { - if (stack.isEmpty()) + if (stack.isEmpty() || !itemHandler.isItemValid(index, stack)) return false; - return itemHandler.isItemValid(index, stack); + IItemHandler handler = this.getItemHandler(); + ItemStack remainder; + if (handler instanceof IItemHandlerModifiable) + { + IItemHandlerModifiable handlerModifiable = (IItemHandlerModifiable) handler; + ItemStack currentStack = handlerModifiable.getStackInSlot(index); + + handlerModifiable.setStackInSlot(index, ItemStack.EMPTY); + + remainder = handlerModifiable.insertItem(index, stack, true); + + handlerModifiable.setStackInSlot(index, currentStack); + } + else + { + remainder = handler.insertItem(index, stack, true); + } + return remainder.getCount() < stack.getCount(); } @Override