-
Bug
-
Resolution: Unresolved
-
None
-
Minecraft 1.8.3, Minecraft 1.8.4, Minecraft 1.8.9, Minecraft 16w07b, Minecraft 1.10.2, Minecraft 16w33a, Minecraft 16w40a, 20w07a, 1.16.3, 1.16.4 Release Candidate 1, 1.16.4, 1.20.2, 23w41a
-
None
-
Confirmed
-
(Unassigned)
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 marcono1234 can be found in this comment
- relates to
-
MC-80400 Sizelimited entity selectors (@e with c=1,@r with type=!entity) in commands prefer players
- Resolved