Improve performance of inserting into inventory wrappers (#3622)

This commit is contained in:
James Mitchell 2017-01-11 16:29:49 -08:00 committed by LexManos
parent aed00b5dce
commit bc381b92ea
2 changed files with 12 additions and 6 deletions

View File

@ -75,9 +75,6 @@ public class InvWrapper implements IItemHandlerModifiable
if (stack.isEmpty())
return ItemStack.EMPTY;
if (!getInv().isItemValidForSlot(slot, stack))
return stack;
ItemStack stackInSlot = getInv().getStackInSlot(slot);
int m;
@ -86,6 +83,9 @@ public class InvWrapper implements IItemHandlerModifiable
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack;
if (!getInv().isItemValidForSlot(slot, stack))
return stack;
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot)) - stackInSlot.getCount();
if (stack.getCount() <= m)
@ -121,6 +121,9 @@ public class InvWrapper implements IItemHandlerModifiable
}
else
{
if (!getInv().isItemValidForSlot(slot, stack))
return stack;
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot));
if (m < stack.getCount())
{

View File

@ -93,9 +93,6 @@ public class SidedInvWrapper implements IItemHandlerModifiable
if (slot1 == -1)
return stack;
if (!inv.isItemValidForSlot(slot1, stack) || !inv.canInsertItem(slot1, stack, side))
return stack;
ItemStack stackInSlot = inv.getStackInSlot(slot1);
int m;
@ -104,6 +101,9 @@ public class SidedInvWrapper implements IItemHandlerModifiable
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack;
if (!inv.isItemValidForSlot(slot1, stack) || !inv.canInsertItem(slot1, stack, side))
return stack;
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot)) - stackInSlot.getCount();
if (stack.getCount() <= m)
@ -137,6 +137,9 @@ public class SidedInvWrapper implements IItemHandlerModifiable
}
else
{
if (!inv.isItemValidForSlot(slot1, stack) || !inv.canInsertItem(slot1, stack, side))
return stack;
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot));
if (m < stack.getCount())
{