Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-73887

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.8, Minecraft 15w49b, Minecraft 16w04a, Minecraft 1.10.2, Minecraft 16w32b, Minecraft 16w36a, Minecraft 16w38a, Minecraft 16w39a, Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w40a, Minecraft 16w41a, Minecraft 16w42a, Minecraft 16w43a, Minecraft 16w44a, Minecraft 1.11 Pre-Release 1, Minecraft 1.11, Minecraft 16w50a, Minecraft 1.11.1, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w13b, Minecraft 17w15a, Minecraft 17w16b, Minecraft 17w17a, Minecraft 17w18b, Minecraft 1.12 Pre-Release 2, Minecraft 1.12.2, Minecraft 17w50a, Minecraft 18w06a, Minecraft 1.13-pre7, 1.15.2, 20w06a, 20w13b, 1.16.1, 1.16.2 Pre-release 2, 1.16.2 Release Candidate 1, 1.16.2, 1.17.1, 1.20.4, 1.21 Pre-Release 1
    • None
    • Confirmed
    • Commands
    • Low
    • Platform

      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.

            Unassigned Unassigned
            Ben_R_R Ben Reddersen
            Votes:
            28 Vote for this issue
            Watchers:
            21 Start watching this issue

              Created:
              Updated:
              CHK: