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

Closest entity selector doesn't always find itself.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: Minecraft 1.8.3, Minecraft 1.8.4, Minecraft 1.8.9, Minecraft 16w07b, Minecraft 1.10.2, Minecraft 16w33a, Minecraft 16w40a, 20w07a
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Operating system: OSX 10.9.5
      Java Version: 1.6.0_65
    • Confirmation Status:
      Confirmed
    • Category:
      (Unassigned)

      Description

      If you use a selector that searches for the nearest entity (@p, @e[c=1], etc), it will always find the entity executing the command (if possible), even if there is another equally close entity. Essentially, entities are always closer to themselves than to any other entity, regardless of actual location. This is extremely useful, and is not a bug. However, this behavior only occurs when specifically searching for the one closest entity. If you search for the 2 closest entities, or the farthest entity, this property will not be taken into account.

      To reproduce, execute these commands:

      /summon minecraft:armor_stand ~ ~ ~ {Tags:["test1"]}
      /execute as @e[tag=test1] at @s run summon minecraft:armor_stand ~ ~ ~ {Tags:["test2"]}
      /execute as @e[tag=test1] at @s run summon minecraft:armor_stand ~ ~ ~ {Tags:["test3"]}
      /execute as @e[tag=test3] at @s run tag @e[limit=2,sort=nearest] list
      

      Or these

      /summon armor_stand ~ ~ ~ {CustomName:"test1",NoGravity:1b}
      /execute @e[name=test1] ~ ~ ~ /summon armor_stand ~ ~ ~ {CustomName:"test2",NoGravity:1b}
      /execute @e[name=test1] ~ ~ ~ /summon armor_stand ~ ~ ~ {CustomName:"test3",NoGravity:1b}
      /execute @e[name=test3] ~ ~ ~ /say @e[c=2]
      

      The last command will find "test1" and "test2", while you executed it from "test3"


      Code analysis by [Mod] Marcono1234 can be found in this comment

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              KingSupernova KingSupernova
              Votes:
              7 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                CHK: