From bf82b93dbf2a5ac03f08b39e91765ff7a298e0c8 Mon Sep 17 00:00:00 2001 From: NichtStudioCode <51272202+NichtStudioCode@users.noreply.github.com> Date: Sat, 30 Apr 2022 14:19:42 +0200 Subject: [PATCH] Clone ItemStack before modifying NBT data in BaseWindow#redrawItem --- .../main/java/de/studiocode/invui/window/impl/BaseWindow.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/InvUI/src/main/java/de/studiocode/invui/window/impl/BaseWindow.java b/InvUI/src/main/java/de/studiocode/invui/window/impl/BaseWindow.java index 13b3217..2dee112 100644 --- a/InvUI/src/main/java/de/studiocode/invui/window/impl/BaseWindow.java +++ b/InvUI/src/main/java/de/studiocode/invui/window/impl/BaseWindow.java @@ -68,6 +68,9 @@ public abstract class BaseWindow implements Window { // This makes every item unique to prevent Shift-DoubleClick "clicking" multiple items at the same time. if (itemStack.hasItemMeta()) { + // clone ItemStack in order to not modify the original + itemStack = itemStack.clone(); + ItemMeta itemMeta = itemStack.getItemMeta(); itemMeta.getPersistentDataContainer().set(SLOT_KEY, PersistentDataType.BYTE, (byte) index); itemStack.setItemMeta(itemMeta);