summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorTahg <tahgtahv@gmail.com>2012-01-09 23:44:46 -0500
committerTahg <tahgtahv@gmail.com>2012-01-09 23:44:46 -0500
commit774a3b134207c66141c1d8f3b4e5b3d6a55c319e (patch)
treed931e408de99818e2dfe8787f84aa6b687bff2e4 /src/main
parentb063a7246a2fc62f795ea9bc89a059c17ce86c2e (diff)
downloadbukkit-774a3b134207c66141c1d8f3b4e5b3d6a55c319e.tar
bukkit-774a3b134207c66141c1d8f3b4e5b3d6a55c319e.tar.gz
bukkit-774a3b134207c66141c1d8f3b4e5b3d6a55c319e.tar.lz
bukkit-774a3b134207c66141c1d8f3b4e5b3d6a55c319e.tar.xz
bukkit-774a3b134207c66141c1d8f3b4e5b3d6a55c319e.zip
Improved some debug in Location.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/Location.java12
1 files changed, 7 insertions, 5 deletions
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);