This issue occurs with the following command
execute as @s store result score @s om_break run data get entity @s Inventory[2].tag.Damage 1;
while holding a damaged (diamond) pickaxe in the third and any other hotbar slot (when changing the slot number accordingly).
What's supposed to happen:
The damage value of the item is translated/carried over into the "om_break" scoreboard.
What's actually happening:
The Value sometimes gets set to 0, as if the item wasn't found, or was fully repaired.
Steps to recreate:
/scoreboard objectives add om_break dummy
/scoreboard objesctives setdisplay sidebar om_break
Then give yourself a damaged pickaxe:
/give @a minecraft:diamond_pickaxe{Damage:1550s} 1
Then put it in your third inventory slot from the left and run the command (in chat):
execute store result score @s om_break run data get entity @s Inventory[2].tag.Damage 1
The slot numbers of the hotbar start with 0 and go to 8, so this should find the item, and the score should then display 1550, but it shows 0!
Through a bit of testing, the condition for when the Value gets 0 is fulfilled when there are empty inventory slots (here: slot 0 and 1) before the targetted one. Why would this command be dependent from items that are in the other slots?
The
Inventory
list does not contain empty entries. Therefore, if that's the only item in your inventory, the index you need to use is[0]
, regardless of which slot it's in 🙂