Don't markDirty() when inserting into a full slot

When inserting into a full slot, the inventory is not actually modified
but markDirty() is still called. This in turn sends a block update to
all neighbours. When a diamond chest is full, attempting to insert into
it will send 100+ block updates (one for each slot). This can cause mild
performance issues.
This commit is contained in:
SquidDev 2019-05-01 14:21:08 +01:00
parent 6acfe334f1
commit b98680c26c
2 changed files with 6 additions and 4 deletions

View File

@ -79,10 +79,11 @@ public class ICChestInventoryHandler implements IItemHandlerModifiable
}
else
{
if (!ItemHandlerHelper.canItemStacksStack(stack, currentStack))
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
if (accepted <= 0 || !ItemHandlerHelper.canItemStacksStack(stack, currentStack))
return stack;
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
if (accepted < stack.getCount())
{
if (!simulate)

View File

@ -79,10 +79,11 @@ public class ICShulkerInventoryHandler implements IItemHandlerModifiable
}
else
{
if (!ItemHandlerHelper.canItemStacksStack(stack, currentStack))
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
if (accepted <= 0 || !ItemHandlerHelper.canItemStacksStack(stack, currentStack))
return stack;
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
if (accepted < stack.getCount())
{
if (!simulate)