Improve performance of inserting into inventory wrappers (#4468)

This commit is contained in:
Ben Staddon 2017-10-31 17:41:33 +00:00 committed by LexManos
parent 57e6559fa4
commit 7b4040b70b
2 changed files with 8 additions and 2 deletions

View File

@ -80,6 +80,9 @@ public class InvWrapper implements IItemHandlerModifiable
int m;
if (!stackInSlot.isEmpty())
{
if (stackInSlot.getCount() >= Math.min(stackInSlot.getMaxStackSize(), getSlotLimit(slot)))
return stack;
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack;

View File

@ -98,10 +98,13 @@ public class SidedInvWrapper implements IItemHandlerModifiable
int m;
if (!stackInSlot.isEmpty())
{
if (stackInSlot.getCount() >= Math.min(stackInSlot.getMaxStackSize(), getSlotLimit(slot)))
return stack;
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack;
if (!inv.isItemValidForSlot(slot1, stack) || !inv.canInsertItem(slot1, stack, side))
if (!inv.canInsertItem(slot1, stack, side) || !inv.isItemValidForSlot(slot1, stack))
return stack;
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot)) - stackInSlot.getCount();
@ -137,7 +140,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
}
else
{
if (!inv.isItemValidForSlot(slot1, stack) || !inv.canInsertItem(slot1, stack, side))
if (!inv.canInsertItem(slot1, stack, side) || !inv.isItemValidForSlot(slot1, stack))
return stack;
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot));