-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
1.14.3 a0e47473cea6bec287b67faea0ccbd576c7b6bce
-
Yes
The PersistentDataContainer does not work correctly on TileEntities.
Adding values as well as overwriting existing ones works, but removing them fails.
This is due to the nature of the CraftBlockState instances which "reload" but not recreate them. Therefore the container instance does not get rid of the previous values and old, now removed values keep on existing.
A possible fix for this would look something like this:
TileEntity.java
public void load(NBTTagCompound nbttagcompound) { this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z")); // CraftBukkit start - read container NBTTagCompound persistentDataTag = nbttagcompound.getCompound("PublicBukkitValues"); if (persistentDataTag != null) { this.persistentDataContainer.clear(); // This call would remove all old values from the container this.persistentDataContainer.putAll(persistentDataTag); } // CraftBukkit end }
CraftPersistentDataContainer.java
public void clear() { // Note that this method does not exist yet as till now the DataContainer instances were passed to the API directly from their NMS owner and never had to be "updated" against a different version of themselves. this.customDataTags.clear(); }
Quick credit for finding the bug: https://www.spigotmc.org/threads/persistentdatacontainer-remove-not-working.380890/