1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-13 18:14:38 +02:00

Fix safety tp check above world height

Performance tweak to fly check
This commit is contained in:
KHobbits
2014-02-23 17:41:25 +00:00
parent 088c54e386
commit 2d5c1fd51c

View File

@@ -215,6 +215,10 @@ public class LocationUtil
static boolean isBlockAboveAir(final World world, final int x, final int y, final int z) static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
{ {
if (y > world.getMaxHeight())
{
return true;
}
return HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId()); return HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
} }
@@ -248,7 +252,7 @@ public class LocationUtil
} }
return false; return false;
} }
// Not needed if using getSafeDestination(loc) // Not needed if using getSafeDestination(loc)
public static Location getRoundedDestination(final Location loc) public static Location getRoundedDestination(final Location loc)
{ {
@@ -273,7 +277,7 @@ public class LocationUtil
} }
return getSafeDestination(loc); return getSafeDestination(loc);
} }
public static Location getSafeDestination(final Location loc) throws Exception public static Location getSafeDestination(final Location loc) throws Exception
{ {
if (loc == null || loc.getWorld() == null) if (loc == null || loc.getWorld() == null)
@@ -347,15 +351,17 @@ public class LocationUtil
final int x = loc.getBlockX(); final int x = loc.getBlockX();
int y = (int)Math.round(loc.getY()); int y = (int)Math.round(loc.getY());
final int z = loc.getBlockZ(); final int z = loc.getBlockZ();
int count = 0;
while (LocationUtil.isBlockUnsafe(world, x, y, z) && y > -1) while (LocationUtil.isBlockUnsafe(world, x, y, z) && y > -1)
{ {
y--; y--;
count++;
if (count > 2)
{
return true;
}
} }
if (loc.getBlockY() - y > 1 || y < 0) return y < 0 ? true : false;
{
return true;
}
return false;
} }
} }