Minecraft – Why won’t this execute if block command work in Minecraft

minecraft-commandsminecraft-java-edition

I'm playing in the new snapshot, 18w01a.

I'm trying to detect if a hopper has a specific renamed item in it using this command:

/execute if block "x" "y" "z" minecraft:hopper{Items:[{id:"minecraft:paper",tag:{display:{Name:"12345"}}}]} run say hi

I have a piece of paper renamed 12345 in the hopper and the command fails when I try to run it. If I remove the tag/display/Name argument, the command runs fine, but that's no help to me. I'm sure I don't have the syntax wrong, so what gives? Is this a bug? If it's not a bug, I won't report it on the bug tracker, but right now I'm a little iffy.

Best Answer

In 1.13, the syntax for display names changed to text components. In my case, we'd have to write it as:

/execute if block "x" "y" "z" minecraft:hopper{Items:[{id:"minecraft:paper",tag:{display:{Name:"{\"text:\":\"12345\"}"}}}]} run say hi