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

    • 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.

            Assignee:
            Unassigned
            Reporter:
            Marcel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: