mojira.dev
MC-46838

testfor NBT parsing error

When trying to use testfor to detect an item entity with a specific name, the game fails to correctly parse the testfor command. The command in question is:
/testfor @e[type=Item,r=5] {OnGround:1b,Item:{id:"minecraft:bow",tag:{display:{Name:"Reds Bow"}}}}
For testing purposes, you can give yourself a bow to test this with using:
/give @p minecraft:bow 1 0 {display:{Name:"Reds Bow"}}

Running the testfor command above returns:
"/testfor <player> [dataTag]"
...which means that it did not correctly parse the NBT and is telling you the proper parameters for the command. If you remove the "tag" tag, and use the following command:
/testfor @e[type=Item,r=5] {OnGround:1b,Item:{id:"minecraft:bow"}}
The game will output:
"Found item.item.bow"

Curiously the command will work if you expand it as far as:
/testfor @e[type=Item,r=5] {OnGround:1b,Item:{id:"minecraft:bow",tag:{display:{}}}}
But as soon as the Name tag is added, the game fails to parse the command.

UPDATE:
It looks like the problem is actually being caused by the space inside of the string. Other commands that also parse NBT strings, such as "clear," have this same behavior.

Comments 4

Yes; please get this fixed. I asked him for help and then it turned out to be a bug! Please help!

  • TheDestruc7i0n

The problem is not in the Name tag, the problem is that /testfor cuts data tags, just like the /clear command. Seems like Mojang doesn't even see those reports, so, please vote for this report and for [MC-44688].

The /testfor command still sometimes fails with spaces in NBT tags.

Elf Elf

michael

Unconfirmed

Minecraft 14w05b

Minecraft 14w07a

Retrieved