Avoid NBT matching (#378)

Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
attempt0andMartin Robertz authored and GitHub committed 2026-06-07 23:13:09 +08:00
1 parent 1a4615bc19
commit 2b024fade4
1 file changed
+14 -6
@@ -107,18 +107,26 @@ public class StandardInventoryIterator extends AbstractInventoryIterator {
ItemStack inSlot = getStackInSlot(slotIndex);
if (!ItemUtil.isStackEmpty(inSlot) && !stack.matches(inSlot)) {
return stack.getStackSize();
}
ItemStack partialCopy = stack.toStackFast();
int maxStack = getSlotStackLimit(slotIndex, partialCopy);
if (!ItemUtil.isStackEmpty(inSlot)) {
if (!forced) {
// Skip expensive NBT check if the stack is full.
if (inSlot.stackSize >= maxStack || !inSlot.isStackable()) {
return stack.getStackSize();
}
}
if (!stack.matches(inSlot)) {
return stack.getStackSize();
}
}
if (!forced && !canInsert(partialCopy, slotIndex)) {
return stack.getStackSize();
}
int maxStack = getSlotStackLimit(slotIndex, partialCopy);
if (!ItemUtil.isStackEmpty(inSlot)) {
int toInsert = forced ? stack.getStackSize() : Math.min(maxStack - inSlot.stackSize, stack.getStackSize());