mojira.dev
MC-124822

execute facing always works if the entity is existing (igonred the player's facing)

When type this command:
/execute as @a at @s facing entity @e[type=villager,limit=1] feet run tp @s ~ ~1 ~
When the entity is existing, the player is always teleported no matter what the player is facing.

Example(imgur gif)

Comments 2

I'm not sure I understand what you expect that command to do

For clarity, the command executes as though the player is facing that entity, it is not used to check if the player is facing that entity. I believe it is mainly meant to be used in conjunction with local coordinates. For example, if you change the teleport command to: tp @s ^ ^ ^1, I would assume that it would teleport each player 1 block in the direction of the entity.

For what you want, I can only think of using a recursive function. Have something that checks a small distance (0.1 maybe) in the direction the player is facing (using at @p positioned ^ ^ ^0.1), and if the entity isn't found within a small radius of that spot, run the function recursively until the entity is found or until a certain range has been reached. Running positioned with local coordinates multiple times will stack rather than use the same position. This is the new form of ray casting in minecraft.

jellywayne

(Unassigned)

Unconfirmed

Minecraft 18w05a

Retrieved