diff --git a/src/main/java/com/onarandombox/utils/LocationManipulation.java b/src/main/java/com/onarandombox/utils/LocationManipulation.java index 4a583fff..723c8fc3 100644 --- a/src/main/java/com/onarandombox/utils/LocationManipulation.java +++ b/src/main/java/com/onarandombox/utils/LocationManipulation.java @@ -5,19 +5,20 @@ import java.util.Map; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.block.BlockFace; +import org.bukkit.util.Vector; public class LocationManipulation { private static Map orientationInts = new HashMap(); static { - orientationInts.put("n", 0); - orientationInts.put("nw", 45); - orientationInts.put("w", 90); - orientationInts.put("sw", 135); - orientationInts.put("s", 180); - orientationInts.put("se", 225); + orientationInts.put("n", 180); + orientationInts.put("ne", 225); orientationInts.put("e", 270); - orientationInts.put("ne", 315); + orientationInts.put("se", 315); + orientationInts.put("s", 0); + orientationInts.put("sw", 45); + orientationInts.put("w", 90); + orientationInts.put("nw", 135); + } /** @@ -104,8 +105,12 @@ public class LocationManipulation { public static float getYaw(String orientation) { if (orientationInts.containsKey(orientation)) { - return (orientationInts.get(orientation) + 90) % 360; + return orientationInts.get(orientation); } return 0; } + + public static float getSpeed(Vector v) { + return (float) Math.sqrt(v.getX() *v.getX() + v.getZ() *v.getZ()); + } }