Direction Player is looking?

Discussion in 'Plugin Development' started by nicholasntp, Oct 21, 2011.

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

    nicholasntp

    What is the org.bukkit..... thing for the direction the player is looking? Thanks.

    ~Nicholasntp
     
  2. Offline

    md_5

    Code:
    private String getDirection(Player player) {
            int degrees = (Math.round(player.getLocation().getYaw()) + 270) % 360;
            if (degrees <= 22) return "North";
            if (degrees <= 67) return "Northeast";
            if (degrees <= 112) return "East";
            if (degrees <= 157) return "Southeast";
            if (degrees <= 202) return "South";
            if (degrees <= 247) return "Southwest";
            if (degrees <= 292) return "West";
            if (degrees <= 337) return "Northwest";
            if (degrees <= 359) return "North";
            return null;
        }
     
    ZNickq likes this.
  3. Offline

    nicholasntp

    Thanks so much. Now how do I make all that into a variable? Im still learning java, so bear with me. ;)
     
  4. Offline

    md_5

    String direction = getDirection(player);
     
  5. Offline

    nicholasntp

    Dude, your amazing. Thank you so much.
     
Thread Status:
Not open for further replies.

Share This Page