Get entity player is looking at

Discussion in 'Plugin Development' started by leimekiller, Feb 2, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    leimekiller

    Hello,

    How can I get the entity the player is looking at?
     
  2. Offline

    Maurdekye

    KraZ__ That's not what he meant.
    leimekiller
    You can use a BlockIterator to trace along the line of sight of the player, and test every block's location for nearby entities.

    KraZ__ Uh, no, you wouldn't. You'd use Player.getLocation().getDirection() to get the player's look direction. That wouldn't even work well enough for his above purposes anyway, so you'd have to end up using a BlockIterator.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 11, 2022
Thread Status:
Not open for further replies.

Share This Page