mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-04 06:02:12 -07:00
Deep clone nbt tags in PDC
This commit is contained in:
@@ -376,7 +376,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||||||
this.maxDamage = meta.maxDamage;
|
this.maxDamage = meta.maxDamage;
|
||||||
this.unhandledTags.copy(meta.unhandledTags.build());
|
this.unhandledTags.copy(meta.unhandledTags.build());
|
||||||
this.removedTags.addAll(meta.removedTags);
|
this.removedTags.addAll(meta.removedTags);
|
||||||
this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw());
|
this.persistentDataContainer.putAll(meta.persistentDataContainer.getTagsCloned()); // Paper - deep clone NBT tags
|
||||||
|
|
||||||
this.customTag = meta.customTag;
|
this.customTag = meta.customTag;
|
||||||
|
|
||||||
@@ -1987,7 +1987,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||||||
clone.customTag = this.customTag.copy();
|
clone.customTag = this.customTag.copy();
|
||||||
}
|
}
|
||||||
clone.removedTags = Sets.newHashSet(this.removedTags);
|
clone.removedTags = Sets.newHashSet(this.removedTags);
|
||||||
clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), CraftMetaItem.DATA_TYPE_REGISTRY);
|
clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getTagsCloned(), CraftMetaItem.DATA_TYPE_REGISTRY); // Paper - deep clone NBT tags
|
||||||
clone.hideFlag = this.hideFlag;
|
clone.hideFlag = this.hideFlag;
|
||||||
clone.hideTooltip = this.hideTooltip;
|
clone.hideTooltip = this.hideTooltip;
|
||||||
clone.tooltipStyle = this.tooltipStyle;
|
clone.tooltipStyle = this.tooltipStyle;
|
||||||
|
@@ -207,4 +207,12 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Paper end - byte array serialization
|
// Paper end - byte array serialization
|
||||||
|
|
||||||
|
// Paper start - deep clone tags
|
||||||
|
public Map<String, Tag> getTagsCloned() {
|
||||||
|
final Map<String, Tag> tags = new HashMap<>();
|
||||||
|
this.customDataTags.forEach((key, tag) -> tags.put(key, tag.copy()));
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
// Paper end - deep clone tags
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user