3

I tried this:

/execute if entity @e[type=minecraft:player] facing entity @e[type=minecraft:pig,tag=173] feet run say hello

But it didn't work.

3
  • How precise does this need to be?
    – user232393
    Commented Aug 19, 2019 at 20:33
  • Making a game for 3 disposable players, eh? Commented Jan 16, 2020 at 22:46
  • Duplicate of How to kill an Entity a Player is looking at?. Unfortunately I already cast and retracted a close vote for a different target so can't cast another close vote.
    – pppery
    Commented Jul 25, 2022 at 23:56

1 Answer 1

1

facing is completely separate from if entity <selector>, it just changes how the command is run (with a different rotation). Detecting if a player looks at something is very hard and requires something called "raytracing" (one example is here).
It might be possible to somehow check if the player looks at an enderman, but even if they're "invisible", you can still see the eyes, so that's probably not what you want.

I recommend changing something else about your setup so that you don't require to check for looking at a pig.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .