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.

  • How precise does this need to be? – user232393 Aug 19 '19 at 20:33
  • Making a game for 3 disposable players, eh? – Matthew Wells Jan 16 at 22:46

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.