From 141a2bb1908383657dbb405324a10bd9dc9473e1 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 17 Jul 2012 01:28:20 +0100 Subject: [PATCH] Add small optimization tweak to new safe block function. --- Essentials/src/com/earth2me/essentials/Util.java | 15 ++++++++++----- 1 file 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; + } } }