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

This commit is contained in:
md_5 2024-04-29 07:38:24 +10:00
parent 91b1fc3f1c
commit bb9a6e9904
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

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