summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2014-02-23 17:41:25 +0000
committerKHobbits <rob@khobbits.co.uk>2014-02-23 17:41:25 +0000
commit2d5c1fd51ce7f37ea07a62c41f2fa835eb5cb1f5 (patch)
treead92f3ed0b647d7338619f7829fb9ced2d29a87b
parent088c54e3868ebd8c27f7a9dde98ccd6e6b81542e (diff)
downloadEssentials-2d5c1fd51ce7f37ea07a62c41f2fa835eb5cb1f5.tar
Essentials-2d5c1fd51ce7f37ea07a62c41f2fa835eb5cb1f5.tar.gz
Essentials-2d5c1fd51ce7f37ea07a62c41f2fa835eb5cb1f5.tar.lz
Essentials-2d5c1fd51ce7f37ea07a62c41f2fa835eb5cb1f5.tar.xz
Essentials-2d5c1fd51ce7f37ea07a62c41f2fa835eb5cb1f5.zip
Fix safety tp check above world height
Performance tweak to fly check
-rw-r--r--Essentials/src/com/earth2me/essentials/utils/LocationUtil.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
index 1accd6d6e..1d2cbb6ae 100644
--- a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
+++ b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java
@@ -215,6 +215,10 @@ public class LocationUtil
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());
}
@@ -248,7 +252,7 @@ public class LocationUtil
}
return false;
}
-
+
// Not needed if using getSafeDestination(loc)
public static Location getRoundedDestination(final Location loc)
{
@@ -273,7 +277,7 @@ public class LocationUtil
}
return getSafeDestination(loc);
}
-
+
public static Location getSafeDestination(final Location loc) throws Exception
{
if (loc == null || loc.getWorld() == null)
@@ -347,15 +351,17 @@ public class LocationUtil
final int x = loc.getBlockX();
int y = (int)Math.round(loc.getY());
final int z = loc.getBlockZ();
+ int count = 0;
while (LocationUtil.isBlockUnsafe(world, x, y, z) && y > -1)
{
y--;
+ count++;
+ if (count > 2)
+ {
+ return true;
+ }
}
- if (loc.getBlockY() - y > 1 || y < 0)
- {
- return true;
- }
- return false;
+ return y < 0 ? true : false;
}
}