I’m not entirely sure how to get the exact entity the player is looking at, by i think you can do something with getting the directions of the player and the entity and then compare the two directions or something.. Check out my plugin InventoryTweaks – Enchant the behavior of your players inventorys!
How to execute a command for an entity?
This command calls the function as every player at the position of their eyes (1.5 blocks above their feet). Imagine walking in a straight line, you take a small step and check if there is an entity nearby. You take another step and check again if there is an entity nearby.
How do you find an entity in Minecraft?
Imagine walking in a straight line, you take a small step and check if there is an entity nearby. You take another step and check again if there is an entity nearby. You continue walking like this until you reach any block that isn’t air, find an entity, or walked 50 blocks away from where you started.
How do I make an entity face another entity’s head?
Im trying to make an auto turret but when teleporting the entity in place and making it face another using the tp “facing” argument it faces the entity’s feet, this is annoying because when the entity gets far enough away the arrows will undershoot seeing as the target is the feet How do I make it face the head so it will be more accurate?
How to execute if a player is looking at a target?
It does not check whether the player actually has a clear line of sight to the target. The idea is this: move forward in the correct direction to face, and then move back in the actual direction faced. If the player is looking in the right direction, these two moves should cancel each other out, and we’ll be back where we started.
How to check if player is looking up or down?
You can make the check more or less precise by changing the distance=..0.6 check near the end. Bigger values to make it less precise, smaller to make it more precise. You can also make it ignore whether the player is looking up or down by inserting rotated ~ 0 after the facing and rotated as lines.