diff --git a/src/main/java/fi/dy/masa/malilib/render/InventoryOverlay.java b/src/main/java/fi/dy/masa/malilib/render/InventoryOverlay.java index 866e82d557..5a132b193c 100644 --- a/src/main/java/fi/dy/masa/malilib/render/InventoryOverlay.java +++ b/src/main/java/fi/dy/masa/malilib/render/InventoryOverlay.java @@ -1116,6 +1116,7 @@ public static void renderStackToolTip(int x, int y, ItemStack stack, MinecraftCl List list = stack.getTooltip(Item.TooltipContext.create(mc.world), mc.player, mc.options.advancedItemTooltips ? TooltipType.ADVANCED : TooltipType.BASIC); List lines = new ArrayList<>(); + //dumpTooltip(list); for (int i = 0; i < list.size(); ++i) { if (i == 0) @@ -1144,14 +1145,27 @@ public static void renderStackToolTipStyled(int x, int y, ItemStack stack, Minec { if (stack.isEmpty() == false && mc.world != null && mc.player != null) { + List toolTips = stack.getTooltip(Item.TooltipContext.create(mc.world), mc.player, mc.options.advancedItemTooltips ? TooltipType.ADVANCED : TooltipType.BASIC); + dumpTooltip(toolTips); drawContext.drawTooltip(mc.textRenderer, - stack.getTooltip(Item.TooltipContext.create(mc.world), mc.player, mc.options.advancedItemTooltips ? TooltipType.ADVANCED : TooltipType.BASIC), + toolTips, stack.getTooltipData(), // Bundle/Optional Data x, y, stack.get(DataComponentTypes.TOOLTIP_STYLE)); } } + private static void dumpTooltip(List list) + { + int i = 0; + + for (Text entry : list) + { + System.out.printf("dumpTooltip[%d]: %s\n", i, entry.getString()); + i++; + } + } + public static class InventoryProperties { public int totalSlots = 1; diff --git a/src/main/java/fi/dy/masa/malilib/util/InventoryUtils.java b/src/main/java/fi/dy/masa/malilib/util/InventoryUtils.java index a56629ddf0..23cbc55c1f 100644 --- a/src/main/java/fi/dy/masa/malilib/util/InventoryUtils.java +++ b/src/main/java/fi/dy/masa/malilib/util/InventoryUtils.java @@ -640,7 +640,7 @@ public static Inventory getNbtInventory(@Nonnull NbtCompound nbt, int slotCount, } for (int i = 0; i < slotCount; i++) { - inv.setStack(i, items.get(i)); + inv.setStack(i, items.get(i).copy()); } return inv; @@ -678,7 +678,7 @@ else if (nbt.contains(NbtKeys.ITEM)) // item (DecoratedPot, ItemEntity) ItemStack entry = ItemStack.fromNbtOrEmpty(registry, nbt.getCompound(NbtKeys.ITEM)); SimpleInventory inv = new SimpleInventory(1); - inv.setStack(0, entry); + inv.setStack(0, entry.copy()); return inv; } @@ -687,7 +687,7 @@ else if (nbt.contains(NbtKeys.ITEM_2)) // Item (Item Frame) ItemStack entry = ItemStack.fromNbtOrEmpty(registry, nbt.getCompound(NbtKeys.ITEM_2)); SimpleInventory inv = new SimpleInventory(1); - inv.setStack(0, entry); + inv.setStack(0, entry.copy()); return inv; } @@ -696,7 +696,7 @@ else if (nbt.contains(NbtKeys.BOOK)) // Book (Lectern) ItemStack entry = ItemStack.fromNbtOrEmpty(registry, nbt.getCompound(NbtKeys.BOOK)); SimpleInventory inv = new SimpleInventory(1); - inv.setStack(0, entry); + inv.setStack(0, entry.copy()); return inv; } @@ -705,7 +705,7 @@ else if (nbt.contains(NbtKeys.RECORD)) // RecordItem (Jukebox) ItemStack entry = ItemStack.fromNbtOrEmpty(registry, nbt.getCompound(NbtKeys.RECORD)); SimpleInventory inv = new SimpleInventory(1); - inv.setStack(0, entry); + inv.setStack(0, entry.copy()); return inv; } @@ -754,7 +754,7 @@ public static Inventory getNbtInventoryHorseFix(@Nonnull NbtCompound nbt, int sl { return null; } - inv.setStack(0, saddle); + inv.setStack(0, saddle.copy()); for (int i = 0; i < slotCount; i++) { inv.setStack(i + 1, items.get(i)); @@ -766,7 +766,7 @@ public static Inventory getNbtInventoryHorseFix(@Nonnull NbtCompound nbt, int sl else if (!saddle.isEmpty()) { SimpleInventory inv = new SimpleInventory(1); - inv.setStack(0, saddle); + inv.setStack(0, saddle.copy()); return inv; } @@ -775,7 +775,7 @@ else if (nbt.contains(NbtKeys.ITEM)) // item (DecoratedPot, ItemEntity) ItemStack entry = ItemStack.fromNbtOrEmpty(registry, nbt.getCompound(NbtKeys.ITEM)); SimpleInventory inv = new SimpleInventory(1); - inv.setStack(0, entry); + inv.setStack(0, entry.copy()); } return null; @@ -963,7 +963,7 @@ public static DefaultedList getBundleItems(ItemStack stackIn) if (slot.isEmpty() == false) { - items.add(slot); + items.add(slot.copy()); } } @@ -1003,7 +1003,7 @@ public static DefaultedList getBundleItems(ItemStack stackIn, int max while (iter.hasNext() && limit < maxSlots) { - items.add(iter.next()); + items.add(iter.next().copy()); limit++; }