mirror of
https://github.com/GTNewHorizons/GTNHLib.git
synced 2026-11-26 14:53:14 +00:00
Avoid unnecessary NBT copy (#404)
This commit is contained in:
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();
|
||||
|
||||
|
||||
Reference in new issue
Block a user