mojira.dev
MC-49772

The [c=-1] selector doesn't select the youngest entity

If you want to teleport for example the Zombie which was most recently added, you would do "/tp @e[type=Zombie,c=-1] ~ ~1 ~". Summon a few more Zombies and if you run the tp command again, it wom't tp the most recently added Zombie. Same with c=1 (the oldest entity).

Steps to reproduce:

  • Do /gamerule doMobSpawning false

  • Do /kill @e[type=Zombie]

  • Summon four Zombies with the CustomName 1, 2, 3 and 4 in exactly this order. ( /summon Zombie ~ ~ ~ {CustomName:1} )

  • Do /kill @e[type=Zombie,c=-1] 4x times (This should kill the Zombies in this order: 4, 3, 2, 1)

  • Repeat
    You will see it doesn't kill the Zombies in this order.

Do this again in Snapshot 14w06a and the Zombies get killed in the right order!

Linked issues

Comments 5

Cannot reproduce, you probably had another zombie spawn. Try /kill @e[type=Zombie] then spawn a zombie before issuing the command. Worked every time for me except when a new zombie spawned out of view in which case it teleported that zombie. Tested in command line and command block.

Happens to me as well, when using /tp @e[type=Zombie,c=1] @p it teleports the nearest zombie to me and /tp @e[type=Zombie,c=-1] teleports the zombie that's longest away from me. I tested this by spawning 3 zombies and teleporting them around using the two commands. I expected the first zombie I spawned to tp to me everytime I used c=1 and the last one everytime I used c=-1, but it didn't.

Sorry, I forgot to say you need to summon multiple Zombies and you will see that they won't tp in the order you summoned them.

This is very likely working as intended to make the @e selector work more like the @p selector.

Still a problem in 14w11b - Not the youngest or oldest mob - uses the distance instead.

Onik

(Unassigned)

Unconfirmed

Minecraft 14w07a, Minecraft 14w08a

Retrieved