Both of these target selectors are going to be very useful in tandem with execute commands.
@t, selecting attackable targets
With @s, we can execute as a mob, and then from there, select what they see as their immediate target.
For example, Let's assume that in a repeating command block, we wanted to make a villager being chased by a zombie to run away faster by using a Speed II potion effect for 10 seconds. The command could be:
/execute as @e[type=zombie] as @t run effect @s speed 10 1 true
Similar to other target selectors, arguments can filter these things down. Maybe you'd only want this to occur if the villager being chased was named Bob. In that case:
/execute as @e[type=zombie] as @t[name=Bob] run effect @s speed 10 1 true
@o, selecting entity owners
For example, let's say we've wanted all arrows that were shot by an entity to be teleported 5 blocks above the shooter. The command we would use for that is:
/execute as @e[type=arrow] at @o run tp @s ~ ~5 ~
Similar to other target selectors, arguments can filter these things down. Maybe you'd only want this to occur if the owner of the arrow were a skeleton. In that case:
/execute as @e[type=arrow] at @o[type=skeleton] run tp @s ~ ~5 ~
Please sign in to leave a comment.
0 Comments