2023-08-22 06:59:31 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: SoSeDiK <mrsosedik@gmail.com>
|
|
|
|
Date: Thu, 26 May 2022 03:30:05 +0300
|
|
|
|
Subject: [PATCH] Deep clone unhandled nbt tags
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
2023-12-25 23:51:56 +01:00
|
|
|
index f87b656c49b3524519e1976ae6b7ec80d9cd2423..c6575325ba341b6feccdcc6f32fd41a7c5c54b7a 100644
|
2023-08-22 06:59:31 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
@@ -304,7 +304,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
2023-08-22 06:59:31 +02:00
|
|
|
private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
|
|
|
|
|
|
|
|
private CompoundTag internalTag;
|
|
|
|
- final Map<String, Tag> unhandledTags = new TreeMap<String, Tag>(); // Visible for testing only // Paper
|
|
|
|
+ Map<String, Tag> unhandledTags = new TreeMap<String, Tag>(); // Visible for testing only // Paper // Paper - remove final
|
|
|
|
private CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftMetaItem.DATA_TYPE_REGISTRY);
|
|
|
|
|
|
|
|
private int version = CraftMagicNumbers.INSTANCE.getDataVersion(); // Internal use only
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
@@ -345,8 +345,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
2023-08-22 06:59:31 +02:00
|
|
|
this.destroyableKeys = new java.util.HashSet<>(meta.destroyableKeys);
|
|
|
|
}
|
|
|
|
// Paper end
|
|
|
|
- this.unhandledTags.putAll(meta.unhandledTags);
|
|
|
|
- this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw());
|
|
|
|
+ // Paper start - Deep clone unhandled nbt tags
|
|
|
|
+ meta.unhandledTags.forEach((key, tag) -> this.unhandledTags.put(key, tag.copy()));
|
|
|
|
+ this.persistentDataContainer.putAll(meta.persistentDataContainer.getTagsCloned());
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
this.internalTag = meta.internalTag;
|
|
|
|
if (this.internalTag != null) {
|
2023-12-25 23:51:56 +01:00
|
|
|
@@ -1392,7 +1394,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
2023-08-22 06:59:31 +02:00
|
|
|
if (this.hasAttributeModifiers()) {
|
|
|
|
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
|
|
|
|
}
|
|
|
|
- clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), CraftMetaItem.DATA_TYPE_REGISTRY);
|
|
|
|
+ // Paper start - Deep clone unhandled nbt tags
|
|
|
|
+ clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getTagsCloned(), CraftMetaItem.DATA_TYPE_REGISTRY);
|
|
|
|
+ clone.unhandledTags = new TreeMap<>(this.unhandledTags);
|
|
|
|
+ clone.unhandledTags.replaceAll((key, tag) -> tag.copy());
|
|
|
|
+ // Paper end - Deep clone unhandled nbt tags
|
|
|
|
clone.hideFlag = this.hideFlag;
|
|
|
|
clone.unbreakable = this.unbreakable;
|
|
|
|
clone.damage = this.damage;
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
|
2023-12-08 20:00:39 +01:00
|
|
|
index 416d2ca909d30e267fb97082a0aaac90444510de..9d61756689d1f5a71bcdb3ae4859cb0a60e7d850 100644
|
2023-08-22 06:59:31 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
|
2023-12-08 20:00:39 +01:00
|
|
|
@@ -203,4 +203,12 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
|
2023-08-22 06:59:31 +02:00
|
|
|
}
|
|
|
|
}
|
2023-12-08 20:00:39 +01:00
|
|
|
// Paper end - byte array serialization
|
2023-08-22 06:59:31 +02:00
|
|
|
+
|
2023-12-08 20:00:39 +01:00
|
|
|
+ // Paper start - deep clone tags
|
2023-08-22 06:59:31 +02:00
|
|
|
+ public Map<String, Tag> getTagsCloned() {
|
|
|
|
+ final Map<String, Tag> tags = new HashMap<>();
|
|
|
|
+ this.customDataTags.forEach((key, tag) -> tags.put(key, tag.copy()));
|
|
|
|
+ return tags;
|
|
|
|
+ }
|
2023-12-08 20:00:39 +01:00
|
|
|
+ // Paper end - deep clone tags
|
2023-08-22 06:59:31 +02:00
|
|
|
}
|