mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-13 11:18:23 +01:00
Improved some debug in Location.
By: Tahg <tahgtahv@gmail.com>
This commit is contained in:
parent
387d09faa1
commit
21e1a5b725
1 changed files with 7 additions and 5 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue