Minecraft command gives an error

minecraft-commandsminecraft-java-edition

I'm using the command:

/scoreboard players tag @e[type=Item] add example {Item:{id:"minecraft:leather_chestplate",tag:{ench:[{id:0,lvl:1,OnGround:b1}]}}}

But when I drop the item I find the error:

[16:15:15] The dataTag does not match for 17f82d3c-a5c2-48b6-ad19-b6f9cbb0e4d6

How can I fix it?

Best Answer

You have the OnGround portion inside the enchantment section which is inside the item section. You want it to be a part of the data tag but outside the item section. Also, you have OnGround value at b1 but that should be 1b. Similarly with the enchant values, they are missing s after id:0 and lvl:1.

Here is the corrected command:

/scoreboard players tag @e[type=Item] add example {Item:{id:"minecraft:leather_chestplate",tag:{ench:[{id:0s,lvl:1s}]}},OnGround:1b}