Created
August 25, 2010 00:52
Revisions
-
jonathonw created this gist
Aug 25, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ :100644 100644 1010a25... 0000000... M etc.java :100644 100644 a6cb6c9... 0000000... M ia.java diff --git a/etc.java b/etc.java index 1010a25..41670dd 100644 --- a/etc.java +++ b/etc.java @@ -1045,4 +1045,28 @@ public class etc { return true; return false; } + + public static String getCompassPointForDirection(double degrees) { + if(0 <= degrees && degrees < 22.5) { + return "N"; + } else if(22.5 <= degrees && degrees < 67.5) { + return "NE"; + } else if(67.5 <= degrees && degrees < 112.5) { + return "E"; + } else if(112.5 <= degrees && degrees < 157.5) { + return "SE"; + } else if(157.5 <= degrees && degrees < 202.5) { + return "S"; + } else if(202.5 <= degrees && degrees < 247.5) { + return "SW"; + } else if(247.5 <= degrees && degrees < 292.5) { + return "W"; + } else if(292.5 <= degrees && degrees < 337.5) { + return "NW"; + } else if(337.5 <= degrees && degrees < 360.0) { + return "N"; + } else { + return "ERR"; + } + } } diff --git a/ia.java b/ia.java index a6cb6c9..f9cb2f1 100644 --- a/ia.java +++ b/ia.java @@ -801,6 +801,11 @@ public class ia extends eh implements ed { } else if (split[0].equalsIgnoreCase("/getpos")) { msg("Pos X: " + e.k + " Y: " + e.l + " Z " + e.m); msg("Rotation X: " + e.q + " Y: " + e.r); + double degreeRotation = ((e.q - 90) % 360); + if(degreeRotation < 0) { + degreeRotation += 360.0; + } + msg("Compass: " + etc.getCompassPointForDirection(degreeRotation) + " (" + (Math.round(degreeRotation * 10) / 10.0) + ")"); } else if (split[0].equalsIgnoreCase("/motd")) { for (String str : etc.getInstance(d).motd) msg(str);