So I'm trying to make a command that tests for a named item in a players inventory, and executes if they have that item. I know that you can test for an item type, but how do I make it test for a name too? Please bear in mind: I am trying to figure this out for Minecraft 1.13, not any previous versions.

*Edit: I have already tried this command with no success:

execute at @a[nbt={Inventory:[{id:"minecraft:blaze_rod",Count:1b,tag:{display:{Name:"{\"text\":\"Doomstick\"}"}}}]}] run say hi

Edit 2: So after some testing I think it has to do with the attribute modifiers or text color I'm using with the name. Any ideas?

  • Please search before asking or at least look at the question list on the right. The first question there already answers this. Commented Sep 23, 2018 at 10:22
  • 2
    @FabianRöling That seems like a material difference to me considering the accepted answer there will straight up not work here.
    – Unionhawk
    Commented Sep 28, 2018 at 12:27
  • 2
    @FabianRöling SelectedItem is still not Inventory. "Held item" is a different issue. We may have a duplicate, but "how do I test for an item in a player's hand" is not it. As such I am voting to reopen.
    – Unionhawk
    Commented Sep 28, 2018 at 22:16
  • 1
    The closer match here would be gaming.stackexchange.com/questions/286927/…
    – Unionhawk
    Commented Sep 28, 2018 at 22:17
  • 2
    @Unionhawk As of Minecraft 1.13 the top answer for that question is incorrect because testfor has been removed and scoreboard players tag has been changed to tag, therefore it is not a duplicate because Warloch is specifically asking about Minecraft 1.13.
    – Pharap
    Commented Oct 26, 2018 at 22:12

4 Answers 4


So, after a few hours of debugging and fruitless research, I realized that: a: My conjecture in Edit 2 about text format was correct, and b: it can be solved by including the other text json like so (Please pardon any errors in my json format):

execute at @a[nbt={Inventory:[{id:"minecraft:blaze_rod",Count:1b,tag:{display:{Name:"{\"text\":\"Doomstick\",\"color\":\"dark_red\",\"bold\":\"true\",\"italic\":\"true\"}"}}}]}] run say hi

Hopefully this helped anyone out there experiencing a similar issue.

execute as @a if entity @s[nbt={Inventory:[{id:"minecraft:emerald",Count:3b}]}]

Just change "Emerald" to whwatever item you want, and you can change "3" to the amount of items you're looking for. That should work for Minecraft 1.13+. I'm currently on Minecraft 1.14.3 Java Edition.


Just Figured the problem out with enchanted items. It doesn't work up until 1.14.4 yet, but I found a solution, easier faster, and better.

/give @p minecraft:red_banner{D2Quest1Item:1b,display:{Name:"{\"text\":\"Red Flag\"}"},Unbreakable:1,Enchantments:[{id:"minecraft:binding_curse",lvl:1}]} 1

/execute if entity @a[distance=..3,gamemode=adventure,team=Blue,nbt={Inventory:[{id:"minecraft:red_banner",tag:{D2Quest1Item:1b}}]}]

This just adds a custom tag, which is easily detected by the command block.


/execute as @a if entity @s[nbt={inventory:[{id:"minecraft:<name>"}]}] would do the trick for computer users

/execute as @a if entity @s[nbt={inventory:[{id:"<name>"}]}] i think would work for mobile users(pe edition)

  • didnt work: execute as @a[nbt={inventory:[{id:"minecraft:dried_kelp"}]}] run say hi
    – Aceplante
    Commented Apr 14, 2022 at 17:26
  • this did: execute as @a[nbt={Inventory:[{id:"minecraft:chicken_spawn_egg"}]}] run say hi
    – Aceplante
    Commented Apr 14, 2022 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .