Whenever the world is (re)loaded, a tool with 0 damage (full durability) will load in the Damage tag as Damage: 0
. However, when the tool is spawned, (through commands, crafting, creative menu or otherwise..) The Damage: 0
is omitted.
To visualise this, here is a comparison:
New carrot on a stick:
[media]
Same carrot on a stick after quitting to menu and reopening the world:
[media]
Notice the ... tag: {Damage: 0} ...
Clearly this is an inconsistency in the code, which makes writing mcfunctions more difficult. For example, testing if a tool has 0 damage is impossible. Testing for "Execute this function IF Damage NBT tag is absent" or "Execute this function IF Damage NBT tag is equal to 0" are 2 entirely different commands, with the same principal to figure out if the damage on a tool is 0. Except either will only work in each different case. The first will only work on newly spawned tools, but after a world reload, only the second method would work.
Here are the commands in question:
Only works when tool is initially spawned:
/execute unless data entity @s SelectedItem.tag.Damage run say hi
Only works when world is reloaded:/execute if data entity @s {SelectedItem:{tag: {Damage:0s} } } run say hi
To reproduce:
Spawn a tool in a fresh world and verify it's nbt. It should not contain any "tag: {Damage: 0}"
Close and reopen the world
Verify that the nbt has changed to include "tag: {Damage: 0}"
Linked issues
duplicates 1
Attachments
Comments 3
Yes, Actually. I couldn't find this ticket however by performing a search, hence the duplicate ticket. However with the same keywords I can find my own report. I think the other ticket might need some new tags or keywords to clear up visibility.
Alright. I resolved this ticket as a duplicate of MC-136352 and added a few new tags to that ticket.
Does MC-136352 describe your issue?