summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-07-17 01:28:20 +0100
committerKHobbits <rob@khobbits.co.uk>2012-07-17 01:28:20 +0100
commitb4e75f0c0b742ed5595dac0e33eda78673cf293e (patch)
treececb814ffaa9710849048a14eaea3f1d1735d17a
parentb6f73ddb3c5037a7351cae9c0a2ec1733513bf90 (diff)
downloadEssentials-b4e75f0c0b742ed5595dac0e33eda78673cf293e.tar
Essentials-b4e75f0c0b742ed5595dac0e33eda78673cf293e.tar.gz
Essentials-b4e75f0c0b742ed5595dac0e33eda78673cf293e.tar.lz
Essentials-b4e75f0c0b742ed5595dac0e33eda78673cf293e.tar.xz
Essentials-b4e75f0c0b742ed5595dac0e33eda78673cf293e.zip
Add small optimization tweak to new safe block function.
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
index 643a66729..c17e196fa 100644
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ b/Essentials/src/com/earth2me/essentials/Util.java
@@ -296,14 +296,14 @@ public class Util
int x = loc.getBlockX();
int y = (int)Math.round(loc.getY());
int z = loc.getBlockZ();
- final int oy = y;
+ final int origY = y;
while (isBlockAboveAir(world, x, y, z))
{
y -= 1;
if (y < 0)
{
- y = oy;
+ y = origY;
break;
}
}
@@ -315,7 +315,7 @@ public class Util
{
x -= 3;
z -= 3;
- y = oy + 4;
+ y = origY + 4;
break;
}
}
@@ -323,10 +323,9 @@ public class Util
while (isBlockUnsafe(world, x, y, z))
{
y -= 1;
- if (y + 4 < oy)
+ if (y + 4 < origY)
{
x += 1;
- y = oy + 4;
if (x - 3 > loc.getBlockX())
{
x = loc.getBlockX() - 3;
@@ -339,6 +338,12 @@ public class Util
break;
}
}
+
+ y = origY + 4;
+ if (origY - 4 > world.getHighestBlockYAt(x, z))
+ {
+ y = origY - 4;
+ }
}
}