Fix SlotItemHandler.isItemValid check
This commit is contained in:
parent
5a48ca99b6
commit
cfa33be24b
1 changed files with 19 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue