mojira.dev
MC-164450

Selector "sort=" does not work properly with newly summoned entities

summon area_effect_cloud 0 0 0 {CustomName:"{\"text\":\"0\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.1 0 0 {CustomName:"{\"text\":\"1\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.2 0 0 {CustomName:"{\"text\":\"2\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.3 0 0 {CustomName:"{\"text\":\"3\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.4 0 0 {CustomName:"{\"text\":\"4\"}",Duration:1,Tags:[test_e]}

execute positioned 0 0 0 run say @e[tag=test_e,limit=1,sort=furthest]
execute positioned 0 0 0 run kill @e[tag=test_e,limit=1,sort=furthest]
execute positioned 0 0 0 run say @e[tag=test_e,limit=1,sort=furthest]

Running this function should output:

4
3
but the actual output is:
1
2

summon area_effect_cloud 0 0 0 {CustomName:"{\"text\":\"0\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.1 0 0 {CustomName:"{\"text\":\"1\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.2 0 0 {CustomName:"{\"text\":\"2\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.3 0 0 {CustomName:"{\"text\":\"3\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.4 0 0 {CustomName:"{\"text\":\"4\"}",Duration:1,Tags:[test_e]}

execute positioned 0 0 0 run say @e[tag=test_e,limit=1,sort=nearest]
execute positioned 0 0 0 run kill @e[tag=test_e,limit=1,sort=nearest]
execute positioned 0 0 0 run say @e[tag=test_e,limit=1,sort=nearest]

Running this function should output:

0
1
but the actual output is:
0
4

 

Comments 3

The x and z coordinates will be center-corrected (which is a helpful feature in some cases but a bit confusing in other cases), that means 0 0 0 will be treated as 0.5 0 0.5. You have to change all 0 in x and z coordinates to 0.0:

summon area_effect_cloud 0.0 0 0.0 {CustomName:"{\"text\":\"0\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.1 0 0.0 {CustomName:"{\"text\":\"1\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.2 0 0.0 {CustomName:"{\"text\":\"2\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.3 0 0.0 {CustomName:"{\"text\":\"3\"}",Duration:1,Tags:[test_e]}

summon area_effect_cloud 0.4 0 0.0 {CustomName:"{\"text\":\"4\"}",Duration:1,Tags:[test_e]}

execute positioned 0.0 0 0.0 run say @e[tag=test_e,limit=1,sort=furthest]
execute positioned 0.0 0 0.0 run kill @e[tag=test_e,limit=1,sort=furthest]
execute positioned 0.0 0 0.0 run say @e[tag=test_e,limit=1,sort=furthest]

Everything works as your intention now.

The default offset by 0.5 is an intended feature.

Does @unknown's comment explain your problem or is there still a bug here?

Thanks, the allignment was is the problem actually.
I got confused since the exact same function did work as I originally expected in an older version. 

So this works as intended!

NOPEname

(Unassigned)

Unconfirmed

(Unassigned)

1.14.4

Retrieved