mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 00:07:45 +00:00
Fix SlotItemHandler.isItemValid check
This commit is contained in:
1 parent
5a48ca99b6
commit
cfa33be24b
1 file changed
+19
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user