13
0
geforkt von Mirrors/Paper

Improved some debug in Location.

By: Tahg <tahgtahv@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-01-09 23:44:46 -05:00
Ursprung 387d09faa1
Commit 21e1a5b725

Datei anzeigen

@ -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);