This commit is contained in:
Jesse Boyd 2018-02-27 01:58:29 +11:00
commit d450b8f0bc
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 15 additions and 2 deletions

View File

@ -27,7 +27,7 @@ public class SurfaceRegionFunction implements FlatRegionFunction {
public boolean apply(Vector2D position) throws WorldEditException {
int x = position.getBlockX();
int z = position.getBlockZ();
int layer = extent.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY);
int layer = extent.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY, false);
if (layer != -1) {
lastY = layer;
return function.apply(mutable.setComponents(x, layer, z));

View File

@ -163,11 +163,19 @@ public interface Extent extends InputExtent, OutputExtent {
return (state ? minY : maxY) << 4;
}
public default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
return getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, minY, maxY, ignoreAir);
}
public default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
return getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, minY, maxY);
}
public default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
return getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, true);
}
public default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
y = Math.max(minY, Math.min(maxY, y));
int clearanceAbove = maxY - y;
int clearanceBelow = y - minY;
@ -196,7 +204,12 @@ public interface Extent extends InputExtent, OutputExtent {
}
}
}
return state ? failedMin : failedMax;
int result = state ? failedMin : failedMax;
if(result > 0 && !ignoreAir) {
block = getLazyBlock(x, result, z);
return block.isAir() ? -1 : result;
}
return result;
}
default public void addCaves(Region region) throws WorldEditException {