From f1e98da01f7e5833e0f440db142766e87d741628 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 29 Jun 2019 03:29:53 +1000 Subject: [PATCH] d0a31691e1e2fffcc370fe3a854429d8e406fa8b --- .../fawe/object/brush/heightmap/HeightMap.java | 2 +- .../worldedit/function/block/Naturalizer.java | 11 +++-------- .../function/pattern/RepeatingExtentPattern.java | 8 ++++---- .../worldedit/math/convolution/HeightMap.java | 14 +++++++------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java index 3e52e8f30..5ebf33175 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java @@ -26,6 +26,7 @@ public interface HeightMap { default void applyHeightMapData(int[][] data, EditSession session, BlockVector3 pos, int size, double yscale, boolean smooth, boolean towards, boolean layers) throws MaxChangedBlocksException { BlockVector3 top = session.getMaximumPoint(); int maxY = top.getBlockY(); + int diameter = 2 * size + 1; Location min = new Location(session.getWorld(), pos.subtract(size, maxY, size).toVector3()); BlockVector3 max = pos.add(size, maxY, size); Region region = new CuboidRegion(session.getWorld(), min.toBlockPoint(), max); @@ -33,7 +34,6 @@ public interface HeightMap { if (smooth) { try { HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1)); - int diameter = 2 * size + 1; data[1] = filter.filter(data[1], diameter, diameter); } catch (Throwable e) { e.printStackTrace(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java index 40787ac76..a96275d67 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java @@ -76,15 +76,10 @@ public class Naturalizer implements LayerFunction { default: return BlockTypes.STONE.getDefaultState(); } - } - private boolean naturalize(BlockVector3 position, int depth) throws WorldEditException { - BlockState block = editSession.getBlock(position); - BlockState targetBlock = getTargetBlock(depth); - - if (block.equalsFuzzy(targetBlock)) { - return false; } - return editSession.setBlock(position, targetBlock); + + private boolean naturalize(BlockVector3 position, int depth) throws WorldEditException { + return editSession.setBlock(position, getTargetBlock(depth)); } @Override public boolean apply(BlockVector3 position, int depth) throws WorldEditException { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java index e2076c2c3..12add6726 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java @@ -90,10 +90,10 @@ public class RepeatingExtentPattern extends AbstractExtentPattern { @Override public BaseBlock apply(BlockVector3 position) { - int x = Math.abs(position.getX() + offset.getX()) % size.getBlockX(); - int y = Math.abs(position.getY() + offset.getY()) % size.getBlockY(); - int z = Math.abs(position.getZ() + offset.getZ()) % size.getBlockZ(); - return getExtent().getFullBlock(mutable.setComponents(x, y, z).add(origin)); + int x = Math.abs(position.getX() + offset.getX()) % size.getBlockX() + origin.getX(); + int y = Math.abs(position.getY() + offset.getY()) % size.getBlockY() + origin.getY(); + int z = Math.abs(position.getZ() + offset.getZ()) % size.getBlockZ() + origin.getZ(); + return getExtent().getFullBlock(mutable.setComponents(x, y, z)); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index c1bc08f28..c88ff812d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -182,9 +182,10 @@ public class HeightMap { // Apply heightmap for (int z = 0; z < height; ++z) { + int zr = z + originZ; for (int x = 0; x < width; ++x) { - int curHeight = this.data[index]; if (this.invalid != null && this.invalid[index]) continue; + int curHeight = this.data[index]; //Clamp newHeight within the selection area int newHeight = Math.min(maxY4, data[index++]); @@ -194,7 +195,6 @@ public class HeightMap { // Offset x,z to be 'real' coordinates int xr = x + originX; - int zr = z + originZ; // Depending on growing or shrinking we need to start at the bottom or top if (newHeight > curHeight) { @@ -269,6 +269,7 @@ public class HeightMap { // Apply heightmap int index = 0; for (int z = 0; z < height; ++z) { + int zr = z + originZ; for (int x = 0; x < width; ++x, index++) { if (this.invalid != null && this.invalid[index]) continue; @@ -279,12 +280,11 @@ public class HeightMap { // Offset x,z to be 'real' coordinates int xr = x + originX; - int zr = z + originZ; // Depending on growing or shrinking we need to start at the bottom or top if (newHeight > curHeight) { // Set the top block of the column to be the same type (this might go wrong with rounding) - BlockState existing = session.getBlock(BlockVector3.at(xr, curHeight, zr)); + BlockState existing = session.getBlock(xr, curHeight, zr); // Skip water/lava if (existing.getBlockType().getMaterial().isMovementBlocker()) { @@ -295,18 +295,18 @@ public class HeightMap { session.setBlock(xr, setY, zr, tmpBlock); ++blocksChanged; } - session.setBlock(BlockVector3.at(xr, newHeight, zr), existing); + session.setBlock(xr, newHeight, zr, existing); ++blocksChanged; } } else if (curHeight > newHeight) { // Set the top block of the column to be the same type // (this could otherwise go wrong with rounding) - session.setBlock(BlockVector3.at(xr, newHeight, zr), session.getBlock(BlockVector3.at(xr, curHeight, zr))); + session.setBlock(xr, newHeight, zr, session.getBlock(xr, curHeight, zr)); ++blocksChanged; // Fill rest with air for (int y = newHeight + 1; y <= curHeight; ++y) { - session.setBlock(BlockVector3.at(xr, y, zr), fillerAir); + session.setBlock(xr, y, zr, fillerAir); ++blocksChanged; } }