I've spent a few hours on this and looked around on the minecraft wiki and I cannot work out how to go about this. The aim is to add motion to a minecart a player is riding in when looking in a certain direction.
The following two commands work as intended:
execute as @e[type=minecart,distance=..18] run data merge entity @s {Motion:[-1.0d, 0.0d, 0.0d]}
execute if entity @p[team=red,distance=..20,y_rotation=0..90]
But I can't merge the two together to work as one.
Previous version command that used to work:
execute @a[team=red,r=200,rym=-64,ry=-26] ~ ~ ~ entitydata @e[type=minecart,r=1] {Motion:[4.5,0.04,4.5]}
Command so far, not working:
execute as @p if entity @p[distance=..20,y_rotation=0..359] run data merge entity @s[distance=..20] {Motion:[0.0,0.04,5.0]}
Apologies if I've missed something simple, I have learning difficulties that can make certain tasks difficult.
as
", never "at
" does everything work like you want if you use your "as
" part, then "at @s
", then the "if
" part? – Fabian Röling Oct 15 '19 at 23:42