How do I test for a named item in a players inventory? (Minecraft 1.13)

Solution 1:

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.

Solution 2:

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.

Solution 3:

/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)