From 3962e6c9d8e0b433402f673e669344896a0703e9 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Tue, 25 Oct 2011 01:02:50 +0200 Subject: [PATCH] Added LocalPlayer.getCardinalDirection(int yawOffset) --- src/main/java/com/sk89q/worldedit/LocalPlayer.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldedit/LocalPlayer.java b/src/main/java/com/sk89q/worldedit/LocalPlayer.java index 37fe8abb6..26f688199 100644 --- a/src/main/java/com/sk89q/worldedit/LocalPlayer.java +++ b/src/main/java/com/sk89q/worldedit/LocalPlayer.java @@ -349,6 +349,16 @@ public abstract class LocalPlayer { * @return */ public PlayerDirection getCardinalDirection() { + return getCardinalDirection(0); + } + + /** + * Get the player's cardinal direction (N, W, NW, etc.) with an offset. May return null. + * @param yawOffset offset that is added to the player's yaw before determining the cardinal direction + * + * @return + */ + public PlayerDirection getCardinalDirection(int yawOffset) { if (getPitch() > 67.5) { return PlayerDirection.DOWN; } @@ -357,7 +367,7 @@ public abstract class LocalPlayer { } // From hey0's code - double rot = (getYaw() - 90) % 360; + double rot = (getYaw() + yawOffset - 90) % 360; if (rot < 0) { rot += 360.0; }