changed /f home enemy distance check to use simpler box shaped detection area instead of diamond shaped

This commit is contained in:
Brettflan 2011-06-08 20:33:12 -05:00
parent 85fd5eb04d
commit 19b1ceabdd

View File

@ -43,9 +43,9 @@ public class FCommandHome extends FBaseCommand {
if (Conf.homesTeleportAllowedEnemyDistance > 0 && ! faction.isSafeZone() && ! me.isInOwnTerritory()) {
Location loc = player.getLocation();
World w = loc.getWorld();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
double x = loc.getX();
double y = loc.getY();
double z = loc.getZ();
for (Player p : player.getServer().getOnlinePlayers())
{
@ -57,11 +57,13 @@ public class FCommandHome extends FBaseCommand {
continue;
Location l = p.getLocation();
int dx = Math.abs(x - l.getBlockX());
int dy = Math.abs(y - l.getBlockY());
int dz = Math.abs(z - l.getBlockZ());
int delta = dx + dy + dz;
if (delta > Conf.homesTeleportAllowedEnemyDistance)
double dx = Math.abs(x - l.getX());
double dy = Math.abs(y - l.getY());
double dz = Math.abs(z - l.getZ());
double max = Conf.homesTeleportAllowedEnemyDistance;
// box-shaped distance check
if (dx > max || dy > max || dz > max)
continue;
me.sendMessage("You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you.");