I am working on a command block contraption on my server that involves armor giving you certain potion effects.

/execute if entity @p[nbt={Inventory[{Slot:100b,id:"minecraft:leather_boots",tag:{display:{Name:"{\"text\":\"Frog Boots\"}"}}}]}] run effect give @s jump_boost 1 1 true

However, it only works if the boots are named in an anvil. How would I write the command if I wanted to test if the player was wearing boots named "Frog Boots" in bold and green text?


The NBT syntax for testing for an item with a certain name is exactly the same as the NBT syntax for giving a player an item with that name. Thus, if you give a player boots using the command:

/give <player> leather_boots{display:{Name:"{\"text\":\"Frog Boots\",\"color\":\"green\",\"bold\":true}"}}

(per my answer to Colored item names in Minecraft?), you check if the player is wearing those boots using the command:

/execute if entity @p[nbt={Inventory:[{Slot:100b,id:"minecraft:leather_boots",tag:{display:{Name:"{\"text\":\"Frog Boots\",\"color\":\"green\",\"bold\":true}"}}}]}] run ...

You can figure out the exact NBT name of an item by selecting it, and running the command:

/data get entity @s SelectedItem.tag.display.Name
  • I don’t know how to use the items data, and use it in an execute command. I’ve tried /execute if entity @p[nbt={Inventory:[{Slot:100b,id:"minecraft:leather_boots",tag:{Display:{Name:"{\"text\":\"Frog Boots\",\"color\":\"green\",\"bold\":true}"}}}]}] but it doesn’t seem to work – Cpisy Meemz May 6 '20 at 16:37
  • Try using the second command listed by @pppery but with @a instead of @p because @p only checks the nearest player relative to the command block (or the player typing the command) also @a is compatible with more than one player using the item. – Firestryke Jun 3 '20 at 19:19

Answer from the OP, posted in the question body:

I found out you can test if the player is wearing dyed armor, so I’m doing that instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.