From f7a0c14a1bad142d7f0ae50f6adf09951706aa30 Mon Sep 17 00:00:00 2001 From: Jordan Date: Thu, 17 Feb 2022 19:34:07 +0100 Subject: [PATCH] Correctly use getNearestSurfaceTerrainBlock in SurfaceSpline and SchemGen (#1616) Fixes #1609 --- .../core/command/tool/brush/SurfaceSpline.java | 16 ++++++++++++---- .../core/function/generator/SchemGen.java | 12 ++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSpline.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSpline.java index 2ab71c1cf..f652c4f94 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSpline.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSpline.java @@ -72,8 +72,8 @@ public class SurfaceSpline implements Brush { final int tipx = MathMan.roundInt(tipv.getX()); final int tipz = (int) tipv.getZ(); int tipy = MathMan.roundInt(tipv.getY()); - tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, minY, maxY); - if (tipy == -1) { + tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE); + if (tipy == Integer.MIN_VALUE || tipy == Integer.MAX_VALUE) { continue; } if (radius == 0) { @@ -93,8 +93,16 @@ public class SurfaceSpline implements Brush { for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) { for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) { if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) { - int y = editSession.getNearestSurfaceTerrainBlock(loopx, loopz, v.getBlockY(), 0, maxY); - if (y == -1) { + int y = editSession.getNearestSurfaceTerrainBlock( + loopx, + loopz, + v.getBlockY(), + minY, + maxY, + Integer.MIN_VALUE, + Integer.MAX_VALUE + ); + if (y == Integer.MIN_VALUE || y == Integer.MAX_VALUE) { continue; } newSet.add(loopx, y, loopz); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/SchemGen.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/SchemGen.java index dcf2d7a36..1ced63f19 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/SchemGen.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/SchemGen.java @@ -33,8 +33,16 @@ public class SchemGen implements Resource { public boolean spawn(Random random, int x, int z) throws WorldEditException { mutable.mutX(x); mutable.mutZ(z); - int y = extent.getNearestSurfaceTerrainBlock(x, z, mutable.getBlockY(), this.extent.getMinY(), this.extent.getMaxY()); - if (y == -1) { + int y = extent.getNearestSurfaceTerrainBlock( + x, + z, + mutable.getBlockY(), + this.extent.getMinY(), + this.extent.getMaxY(), + Integer.MIN_VALUE, + Integer.MAX_VALUE + ); + if (y == Integer.MIN_VALUE || y == Integer.MAX_VALUE) { return false; } mutable.mutY(y);