Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7646

Old PDC values of ItemMeta gets applied even if the last entry gets removed

XMLWordPrintable

    • 1.20.5
    • Yes

      See the following code within CraftMetaItem#applyToItem:

              if (!persistentDataContainer.isEmpty()) {
                  NBTTagCompound bukkitCustomCompound = new NBTTagCompound();
                  Map<String, NBTBase> rawPublicMap = persistentDataContainer.getRaw();
      
                  for (Map.Entry<String, NBTBase> nbtBaseEntry : rawPublicMap.entrySet()) {
                      bukkitCustomCompound.put(nbtBaseEntry.getKey(), nbtBaseEntry.getValue());
                  }
      
                  if (customTag == null) {
                      customTag = new NBTTagCompound();
                  }
                  customTag.put(BUKKIT_CUSTOM_TAG.BUKKIT, bukkitCustomCompound);
              }
      
              if (customTag != null) {
                  itemTag.put(CUSTOM_DATA, CustomData.of(customTag));
              }
          }
      
      

      As you can see the customTag is only being updated in case there is any entry, meaning that it does not get updated if the last entry within the PDC gets removed. The proper solution would be to remove the

      BUKKIT_CUSTOM_TAG.BUKKIT

      in case the PDC is empty.

            Unassigned Unassigned
            Marcel Marcel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: