From 4d62867cb60d5ea9e53ff42f265c1cc3704c739e Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 28 Apr 2018 06:59:23 +1000 Subject: [PATCH] Optional distance for angle patterns/masks --- .../com/boydti/fawe/object/DataAnglePattern.java | 12 +++++++----- .../fawe/object/pattern/AngleColorPattern.java | 4 ++-- .../com/sk89q/worldedit/command/MaskCommands.java | 2 +- .../com/sk89q/worldedit/command/PatternCommands.java | 9 ++++----- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java b/core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java index 9003744b..d7acea8f 100644 --- a/core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java +++ b/core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java @@ -12,10 +12,12 @@ public class DataAnglePattern extends AbstractPattern { public final Extent extent; public final int maxY; public final double factor = 1d / 255; + public final int distance; - public DataAnglePattern(Extent extent) { + public DataAnglePattern(Extent extent, int distance) { this.extent = new ExtentHeightCacher(extent); this.maxY = extent.getMaximumPoint().getBlockY(); + this.distance = distance; } public int getSlope(BaseBlock block, Vector vector) { @@ -27,10 +29,10 @@ public class DataAnglePattern extends AbstractPattern { } int slope; boolean aboveMin; - slope = Math.abs(extent.getNearestSurfaceTerrainBlock(x + 1, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - 1, z, y, 0, maxY)) * 7; - slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x, z + 1, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x, z - 1, y, 0, maxY)) * 7; - slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x + 1, z + 1, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - 1, z - 1, y, 0, maxY)) * 5; - slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x - 1, z + 1, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x + 1, z - 1, y, 0, maxY)) * 5; + slope = Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z, y, 0, maxY)) * 7; + slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x, z - distance, y, 0, maxY)) * 7; + slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z - distance, y, 0, maxY)) * 5; + slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x - distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x + distance, z - distance, y, 0, maxY)) * 5; return slope; } diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java index 49e7d2c9..012a39d4 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java @@ -17,8 +17,8 @@ public class AngleColorPattern extends DataAnglePattern { private final boolean randomize; private final int complexity; - public AngleColorPattern(Extent extent, int complexity, boolean randomize) { - super(extent); + public AngleColorPattern(Extent extent, int complexity, boolean randomize, int distance) { + super(extent, distance); this.complexity = complexity; this.randomize = randomize; this.util = Fawe.get().getCachedTextureUtil(randomize, 0, complexity); diff --git a/core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java b/core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java index f6af4597..f0f9b9c6 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java @@ -264,7 +264,7 @@ public class MaskCommands extends MethodCommands { "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" + "Example: /[3][20]\n" + "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below", - usage = " ", + usage = " [distance=1]", min = 2, max = 2 ) diff --git a/core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java b/core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java index e55cc523..01f4db15 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java @@ -71,7 +71,6 @@ import java.util.Set; " - Use , to OR multiple\n" + "e.g. #surfacespread[10][#existing],andesite\n" + "More Info: https://git.io/vSPmA" - ) public class PatternCommands extends MethodCommands { public PatternCommands(WorldEdit worldEdit) { @@ -125,13 +124,13 @@ public class PatternCommands extends MethodCommands { @Command( aliases = {"#anglecolor"}, desc = "A darker block based on the existing terrain angle", - usage = "[randomize=true] [max-complexity=100]", + usage = "[randomize=true] [max-complexity=100] [distance=1]", min = 0, max = 2 ) - public Pattern anglecolor(Extent extent, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) { + public Pattern anglecolor(Extent extent, @Optional("true") boolean randomize, @Optional("100") double maxComplexity, @Optional("1") int distance) { TextureUtil util = Fawe.get().getCachedTextureUtil(randomize, 0, (int) maxComplexity); - return new AngleColorPattern(extent, (int) maxComplexity, randomize); + return new AngleColorPattern(extent, (int) maxComplexity, randomize, distance); } @Command( @@ -139,7 +138,7 @@ public class PatternCommands extends MethodCommands { desc = "Block data based on the existing terrain angle" ) public Pattern angledata(Extent extent) { - return new DataAnglePattern(extent); + return new DataAnglePattern(extent, 1); } @Command(