Avoid unnecessary NBT copy (#404)

This commit is contained in:
attempt0 authored and GitHub committed 2026-06-18 21:01:29 +02:00
1 parent 14f49170d9
commit 78dcccc892
1 file changed
+9 -3
@@ -90,9 +90,15 @@ public class StandardInventoryIterator extends AbstractInventoryIterator {
int toExtract = Math.min(inSlot.stackSize, amount);
ItemStack extracted = inSlot.splitStack(toExtract);
setInventorySlotContents(slotIndex, inSlot.stackSize == 0 ? null : inSlot);
final ItemStack extracted;
if (inSlot.stackSize <= toExtract) {
// We can avoid NBT copy by just directly passing the stack here
extracted = inSlot;
setInventorySlotContents(slotIndex, null);
} else {
extracted = inSlot.splitStack(toExtract);
setInventorySlotContents(slotIndex, inSlot);
}
markDirty();