Don't copy stack unless it changed (#1116)

Co-authored-by: slprime <[email protected]>
This commit is contained in:
DarkShadow44andslprime authored and GitHub committed 2026-11-13 01:53:07 +02:00
1 parent 0185cd64b1
commit 1a27b02412
2 files changed
+32 -2

No files matched your search

+6 -1
View File
@@ -127,7 +127,12 @@ public class ItemZoom extends Widget implements IContainerInputHandler {
this.displayName = "Unnamed";
}
this.stack = StackInfo.loadFromNBT(StackInfo.itemStackToNBT(stack), 0);
// Copying the stack copies its whole NBT, so it is only done when the hovered stack changes
final boolean sameStack = this.stack != null && this.stack.isItemEqual(stack)
&& ItemStack.areItemStackTagsEqual(this.stack, stack);
if (!sameStack) {
this.stack = StackInfo.loadFromNBT(StackInfo.itemStackToNBT(stack), 0);
}
} else {
this.stack = null;
this.displayName = "";