13
0
geforkt von Mirrors/Paper

improved some debug in Location

By: Tahg <tahgtahv@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-12-27 06:05:24 -05:00
Ursprung e73be72fae
Commit 0d95472921

Datei anzeigen

@ -360,11 +360,7 @@ public class Location implements Cloneable {
* @throws IllegalArgumentException for differing worlds * @throws IllegalArgumentException for differing worlds
*/ */
public double distance(Location o) { public double distance(Location o) {
if (o == null || o.getWorld() != getWorld()) { return Math.sqrt(distanceSquared(o));
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));
} }
/** /**
@ -376,8 +372,10 @@ public class Location implements Cloneable {
* @throws IllegalArgumentException for differing worlds * @throws IllegalArgumentException for differing worlds
*/ */
public double distanceSquared(Location o) { public double distanceSquared(Location o) {
if (o == null || o.getWorld() != getWorld()) { if (o == null) {
throw new IllegalArgumentException("Cannot measure distance between worlds or to 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());
} }
return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) + Math.pow(z - o.z, 2); return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) + Math.pow(z - o.z, 2);