Skip to content

Commit

Permalink
Merge pull request #19 from xFier/master
Browse files Browse the repository at this point in the history
Fix problem with measuring distance between different worlds
  • Loading branch information
Maxopoly authored Jun 7, 2020
2 parents c7c027e + c64e828 commit 50155b6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/untamedears/jukealert/util/JAUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public final class JAUtility {
private JAUtility() {

}

private static double tanPiDiv = Math.sqrt(2.0) - 1.0;

public static Snitch findClosestSnitch(Location loc, PermissionType perm, UUID player) {
Snitch closestSnitch = null;
Expand Down Expand Up @@ -73,11 +75,14 @@ public static TextComponent genTextComponent(Snitch snitch) {
}

public static String genDirections(Snitch snitch, Player player) {
return String.format("%s[%sm %s%s%s]", ChatColor.GREEN, Math.round(player.getLocation().distance(snitch.getLocation())), ChatColor.RED, getCardinal(player.getLocation(), snitch.getLocation()), ChatColor.GREEN);
if (snitch.getLocation().getWorld().equals(player.getLocation().getWorld())) {
return String.format("%s[%sm %s%s%s]", ChatColor.GREEN, Math.round(player.getLocation().distance(snitch.getLocation())), ChatColor.RED, getCardinal(player.getLocation(), snitch.getLocation()), ChatColor.GREEN);
} else {
return ""; // Can't get directions to another world
}
}

public static String getCardinal(Location start, Location end) {
double tanPiDiv = Math.sqrt(2.0) - 1.0;
double dX = start.getBlockX() - end.getBlockX();
double dZ = start.getBlockZ() - end.getBlockZ();

Expand Down

0 comments on commit 50155b6

Please sign in to comment.