From 774a3b134207c66141c1d8f3b4e5b3d6a55c319e Mon Sep 17 00:00:00 2001 From: Tahg Date: Mon, 9 Jan 2012 23:44:46 -0500 Subject: Improved some debug in Location. --- src/main/java/org/bukkit/Location.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java index 4afabd88..f4b8c989 100644 --- a/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java @@ -360,7 +360,11 @@ public class Location implements Cloneable { * @throws IllegalArgumentException for differing worlds */ public double distance(Location o) { - return Math.sqrt(distanceSquared(o)); + if (o == null || o.getWorld() != getWorld()) { + throw new IllegalArgumentException("Cannot measure distance between worlds or to null"); + } + + return Math.sqrt(Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) + Math.pow(z - o.z, 2)); } /** @@ -372,10 +376,8 @@ public class Location implements Cloneable { * @throws IllegalArgumentException for differing worlds */ public double distanceSquared(Location o) { - if (o == null) { - throw new IllegalArgumentException("Cannot measure distance to a null world"); - } else if (o == null || o.getWorld() != getWorld()) { - throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName()); + if (o == null || o.getWorld() != getWorld()) { + throw new IllegalArgumentException("Cannot measure distance between worlds or to null"); } return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) + Math.pow(z - o.z, 2); -- cgit v1.2.3