SPIGOT-7646: Don't duplicate PDC in customTag / retain old values

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-04-29 07:38:24 +10:00
parent 4ae8689c1b
commit 1390477e34

View File

@ -372,6 +372,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
for (String key : keys) {
persistentDataContainer.put(key, compound.get(key).copy());
}
customTag.remove(BUKKIT_CUSTOM_TAG.NBT);
}
if (customTag.isEmpty()) {
customTag = null;
}
});
@ -778,6 +784,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
});
}
NBTTagCompound customTag = (this.customTag != null) ? this.customTag.copy() : null;
if (!persistentDataContainer.isEmpty()) {
NBTTagCompound bukkitCustomCompound = new NBTTagCompound();
Map<String, NBTBase> rawPublicMap = persistentDataContainer.getRaw();
@ -1583,7 +1590,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
builder.put(BUKKIT_CUSTOM_TAG.BUKKIT, persistentDataContainer.serialize());
}
if (customTag != null && !customTag.isEmpty()) {
if (customTag != null) {
try {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
NBTCompressedStreamTools.writeCompressed(customTag, buf);