I tried to get the direction, like North, South, West, East, of a Players Facing. I created this code, but sometimes it doesn't work...
package me.Nightfighter001.GlobalSystem.WorldEditor;
import org.bukkit.entity.Player;
public enum Yaw {
NORTH, SOUTH, EAST, WEST;
public static Yaw getYaw(Player p) {
float yaw = p.getLocation().getYaw();
if (yaw > 135 || yaw < -135) {
return Yaw.NORTH;
} else if (yaw < -45) {
return Yaw.EAST;
} else if (yaw > 45) {
return Yaw.WEST;
} else {
return Yaw.SOUTH;
}
}
}
Can someone help me, please? Sorry for my bad English and thank you :)