Fix SlotItemHandler.isItemValid check

This commit is contained in:
mezz 2018-08-09 21:18:29 -07:00
parent 5a48ca99b6
commit cfa33be24b

View file

@ -43,10 +43,27 @@ public class SlotItemHandler extends Slot
@Override @Override
public boolean isItemValid(@Nonnull ItemStack stack) public boolean isItemValid(@Nonnull ItemStack stack)
{ {
if (stack.isEmpty()) if (stack.isEmpty() || !itemHandler.isItemValid(index, stack))
return false; 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 @Override