Don't markDirty() when inserting into a full slot (#177)
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:
parent
6acfe334f1
commit
a91739d57b
|
|
@ -79,10 +79,11 @@ public class ICChestInventoryHandler implements IItemHandlerModifiable
|
||||||
}
|
}
|
||||||
else
|
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;
|
return stack;
|
||||||
|
|
||||||
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
|
|
||||||
if (accepted < stack.getCount())
|
if (accepted < stack.getCount())
|
||||||
{
|
{
|
||||||
if (!simulate)
|
if (!simulate)
|
||||||
|
|
|
||||||
|
|
@ -79,10 +79,11 @@ public class ICShulkerInventoryHandler implements IItemHandlerModifiable
|
||||||
}
|
}
|
||||||
else
|
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;
|
return stack;
|
||||||
|
|
||||||
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
|
|
||||||
if (accepted < stack.getCount())
|
if (accepted < stack.getCount())
|
||||||
{
|
{
|
||||||
if (!simulate)
|
if (!simulate)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue