How do I use the RootVehicle tag on other entities in Minecraft?
I am attempting to make a contraption that gives Horses the AI of Skeletons. I am working on the backbone of the contraption and I'll add details later but currently I want the Skeleton to be killed when the Horse is killed by detecting if it has fallen off the Horse. I try to use the RootVehicle tag but the RootVehicle tag does not appear to be on the Skeleton when I did
/entitydata @e[type=Skeleton] {}
with only one skeleton in the world and I got this:
And the /summon command for the Horse and Skeleton combo is listed above the /entitydata return.
The commands I have running 20Hz:
/scoreboard players add @e[type=Skeleton,name=pony] ponyAge 1
/scoreboard players tag @e[type=Skeleton,name=pony,score_ponyAge_min=3] remove onPony
/scoreboard players tag @e[type=Skeleton,name=pony,score_ponyAge_min=3] add onPony {RootVehicle:{Entity:{id:"EntityHorse"}}}
kill @e[type=Skeleton,name=pony,tag=!onPony,score_ponyAge_min=4]
And there is a dummy scoreboard called "ponyAge." What happens when this runs is the Horse/Skeleton combo spawns and the Skeleton instantly dies. Am I using the RootVehicle tag incorrectly? Is there a different tag for these things? Is this a bug? If it is intended behavior, it is ridiculous. All entities should have the RootVehicle tag if they are riding something.
Solution 1:
RootVehicle
is a player-only tag. You cannot directly detect if a non-player entity is riding something.
You would need to rely on the host, which makes multi-target situations unreliable (such that you can only reliably have 1 set of those mobs at a time for it to work perfectly).
For example, you would mark the skeleton for death but cause the horse to remove that label. If the horse dies, it no longer exists to remove the label and the skeleton would die.
/scoreboard players tag @e[type=Skeleton,name=pony] add kill
/execute @e[type=EntityHorse,tag=pony] ~ ~ ~ /scoreboard players tag @e[type=Skeleton,name=pony] remove kill
/kill @e[type=Skeleton,name=pony,tag=kill]