From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Cryptite Date: Sat, 6 May 2023 18:14:26 -0500 Subject: [PATCH] Maybe can't tostring? diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java index 22106323902ceb4fc58a95918c754234a581f7a1..72d7f519a28bc76733e67e2d0d0fcda581999242 100644 --- a/src/main/java/net/minecraft/nbt/CompoundTag.java +++ b/src/main/java/net/minecraft/nbt/CompoundTag.java @@ -507,6 +507,9 @@ public class CompoundTag implements Tag { @Override public CompoundTag copy() { // Paper start - reduce memory footprint of NBTTagCompound + if (this.tags.size() < 0) { + net.minecraft.server.MinecraftServer.LOGGER.debug("Tried to copy an invalid item with negative tags: {}, {}, {}, {}", this.tags, this.tags.getClass().getName()); + } it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap ret = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(this.tags.size(), 0.8f); java.util.Iterator> iterator = (this.tags instanceof it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) ? ((it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)this.tags).object2ObjectEntrySet().fastIterator() : this.tags.entrySet().iterator(); while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java index 6bf4548902316b18e14821767868a9dce36c6d89..fce143bb16e4ee2e43fbcf6363b08a0dfeb8a2e1 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -765,7 +765,11 @@ public final class ItemStack { itemstack.setPopTime(this.getPopTime()); if (this.tag != null) { - itemstack.tag = this.tag.copy(); + if (this.tag.tags.size() < 0) { + ItemStack.LOGGER.debug("Tried to copy an invalid item with negative tags: {}, {}, {}, {}", this.tag, this.tag.tags, this.tag.tags.getClass().getName()); + } else { + itemstack.tag = this.tag.copy(); + } } return itemstack;