diff --git a/core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index b6c8e3e2..c64f3ec3 100644 --- a/core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -73,14 +73,14 @@ public class HeightMap { int bz = min.getBlockZ(); Iterable flat = Regions.asFlatRegion(region).asFlatRegion(); Iterator iter = new Fast2DIterator(flat, session).iterator(); - int y = 0; + int layer = 0; MutableBlockVector mutable = new MutableBlockVector(); while (iter.hasNext()) { Vector2D pos = iter.next(); int x = pos.getBlockX(); int z = pos.getBlockZ(); - y = session.getNearestSurfaceLayer(x, z, y, 0, maxY); - data[(z - bz) * width + (x - bx)] = y; + layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY); + data[(z - bz) * width + (x - bx)] = layer; } } else { // Store current heightmap data