Mojira Archive
MC-73887

NBT list comparison tests if item in list, but ignores position

The NBT list comparison (like it is used for the /testfor or /scoreboard command only tests if an item is in the list, but ignores the position.

Example:

Test command
/summon item ~2 ~ ~ {Item:{id:stone,Count:1,tag:{display:{Lore:[A,B,C]}}}}
Comparison commands
/execute if entity @e[type=item,limit=1,nbt={Item:{tag:{display:{Lore:[A]}}}}] run say test (works as "A" is in "Lore")
/execute if entity @e[type=item,limit=1,nbt={Item:{tag:{display:{Lore:[A,C,B]}}}}] run say test (works as "A", "C" and "B" are in "Lore")
/execute if entity @e[type=item,limit=1,nbt={Item:{tag:{display:{Lore:[A,C,B,D]}}}}] run say test (doesn't work as "D" is not in "Lore") 

This is mostly problematic when testing for numbers like for example:

/execute if entity @s[nbt={Motion:[0d,0d,0d]}] run say test

as this would return true if 0d is in "Motion", that means however that the other two numbers in "Motion" can be anything.

Note: Maybe this is the intended feature, if so it would be appreciated if the developers find a way to make direct comparison possible (maybe by saying if a list contains the same amount of items as the to-compare list, then try comparing it directly).


Original description:

There is a bug where using the /testfor ArmorStand command with a specified NBT Rotation value of

{0.0f, 0.0f} returns all Armor Stands, regardless of rotation. Using a Rotation value other than {0.0f, 0.0f}

works as expected. This happens when your command is run in a command block or from the chat. I haven't tested this with anything other than armor stands.

This command returns only armor stands with the specified rotation:

/testfor @e[type=ArmorStand] {Rotation:[45.0f,0.0f]}

This command returns all armor stands, regardless of rotation.

/testfor @e[type=ArmorStand] {Rotation:[0.0f,0.0f]}

To reproduce, place stand with 45 degree rotation, and place a stand with 0 degree rotation. Run the two commands above. The first will give one result, the second will return two results.