Skip to content

Commit

Permalink
SPIGOT-7857: Improve ItemMeta block data deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
blablubbabc authored and md-5 committed Aug 7, 2024
1 parent 8f26c30 commit 8ee6fd1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,16 @@ static Multimap<Attribute, AttributeModifier> buildModifiers(ItemAttributeModifi
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;
Expand Down

0 comments on commit 8ee6fd1

Please sign in to comment.