1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-16 03:24:31 +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 3215dd0be5
commit 7b368313fa

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());
} }
@@ -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)
if (loc.getBlockY() - y > 1 || y < 0)
{ {
return true; return true;
} }
return false; }
return y < 0 ? true : false;
} }
} }