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
commit141a2bb1908383657dbb405324a10bd9dc9473e1 (patch)
treeaacb0e474aa6e10fd1a715b73dba0c49ebf73db7
parentfb71ebdfdfa1a24aa535b3f6596bdef1827def2f (diff)
downloadEssentials-141a2bb1908383657dbb405324a10bd9dc9473e1.tar
Essentials-141a2bb1908383657dbb405324a10bd9dc9473e1.tar.gz
Essentials-141a2bb1908383657dbb405324a10bd9dc9473e1.tar.lz
Essentials-141a2bb1908383657dbb405324a10bd9dc9473e1.tar.xz
Essentials-141a2bb1908383657dbb405324a10bd9dc9473e1.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;
+ }
}
}