What behaviour is expected:
An undamaged item may or may not have an nbt tag Damage which is set to 0. Absence of this tag and the actual item durability/damage being 0 would be considered equal for gameplay purposes. In rare cases a damage of zero might have the tag omitted. This affects CraftItemStack specifically (not its ItemStack.class counterpart) due to the different way in which these two classes hold their state.
What behaviour is observed:
CraftItemStack's equal does a "dumb" recursive equals check on the NBTCompound "tag" of its handle (the NMS itemstack). It doesn't recognize the context so it will not consider the items equal.
Steps/models to reproduce:
Items might have Damage:0 after any setDurability((short) 0); call (they will be spawned, if undamaged, without such a tag). serializing and unserializing an item through YAML (using Bukkit's built-in serialization methods) is a reliable way to strip a "Damage: 0" tag from a CraftItemStack. Serializing a CraftItemStack that IS damaged will not have this issue as the nbt tag would be conserved between (de)serialization.
Be aware that items that otherwise have no meta may not reproduce this bug because hasItemMeta explicitly checks for getDamage in those cases.
Plugin list:
irrelevant its vanilla.
Paper build number:
Paper version git-Paper-588
Anything else:
pls
What behaviour is expected:
An undamaged item may or may not have an nbt tag Damage which is set to 0. Absence of this tag and the actual item durability/damage being 0 would be considered equal for gameplay purposes. In rare cases a damage of zero might have the tag omitted. This affects CraftItemStack specifically (not its ItemStack.class counterpart) due to the different way in which these two classes hold their state.
What behaviour is observed:
CraftItemStack's equal does a "dumb" recursive equals check on the NBTCompound "tag" of its handle (the NMS itemstack). It doesn't recognize the context so it will not consider the items equal.
Steps/models to reproduce:
Items might have Damage:0 after any setDurability((short) 0); call (they will be spawned, if undamaged, without such a tag). serializing and unserializing an item through YAML (using Bukkit's built-in serialization methods) is a reliable way to strip a "Damage: 0" tag from a CraftItemStack. Serializing a CraftItemStack that IS damaged will not have this issue as the nbt tag would be conserved between (de)serialization.
Be aware that items that otherwise have no meta may not reproduce this bug because hasItemMeta explicitly checks for getDamage in those cases.
Plugin list:
irrelevant its vanilla.
Paper build number:
Paper version git-Paper-588
Anything else:
pls