On Minecraft 1.12, I'm making a thing for a boss fight, and it has baby zombies riding chickens. You can kill the zombies and they will die but the chicken won't. How should I detect the chicken no longer having a passenger?
-
1Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins!– FrankCommented Nov 4, 2017 at 18:25
1 Answer
Sadly you can't just test for an empty list of passengers, because the game removes the Passengers
tag when the zombie is killed instead of just emptying it.
But you can detect all chickens and you can detect all chickens with passengers, so you can do something like this:
/scoreboard players tag @e[type=chicken] add noPassenger
/scoreboard players tag @e[type=chicken] remove noPassenger {Passengers:[{id:"minecraft:zombie"}]}
This first adds the tag noPassenger
to all chickens and then removes it from every chicken that is ridden by a zombie. You can later select all tagged chickens with @e[tag=noPassenger]
.
-
1More generally, you can do
{Passengers:[{}]}
to detect whether an entity has any passengers, not just zombies.– AjaxGbCommented Nov 4, 2017 at 20:04 -