SPIGOT-7857: Improve ItemMeta block data deserialization

This commit is contained in:
blablubbabc 2024-08-08 07:44:52 +10:00 committed by md_5
parent 8f26c30c69
commit 8ee6fd1b8d
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -519,9 +519,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
if (blockData != null) {
Map<String, String> mapBlockData = new HashMap<>();
NBTTagCompound nbtBlockData = (NBTTagCompound) CraftNBTTagConfigSerializer.deserialize(blockData);
for (String key : nbtBlockData.getAllKeys()) {
mapBlockData.put(key, nbtBlockData.getString(key));
if (blockData instanceof Map) {
for (Entry<?, ?> entry : ((Map<?, ?>) blockData).entrySet()) {
mapBlockData.put(entry.getKey().toString(), entry.getValue().toString());
}
} else {
// Legacy pre 1.20.5:
NBTTagCompound nbtBlockData = (NBTTagCompound) CraftNBTTagConfigSerializer.deserialize(blockData);
for (String key : nbtBlockData.getAllKeys()) {
mapBlockData.put(key, nbtBlockData.getString(key));
}
}
this.blockData = mapBlockData;