mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Added a utility method for dealing with location precision to bukkit utilities.
This commit is contained in:
parent
126815fcf5
commit
b5c9f70e70
@ -86,4 +86,16 @@ public class BukkitUtil {
|
||||
public static World toWorld(WorldVector pt) {
|
||||
return ((BukkitWorld)pt.getWorld()).getWorld();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bukkit's Location class has serious problems with floating point
|
||||
* precision.
|
||||
*/
|
||||
public static boolean equals(Location a, Location b) {
|
||||
if (Math.abs(a.getX()-b.getX()) > EQUALS_PRECISION) return false;
|
||||
if (Math.abs(a.getY()-b.getY()) > EQUALS_PRECISION) return false;
|
||||
if (Math.abs(a.getZ()-b.getZ()) > EQUALS_PRECISION) return false;
|
||||
return true;
|
||||
}
|
||||
public static final double EQUALS_PRECISION = 0.0001;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user