Optional distance for angle patterns/masks

This commit is contained in:
Jesse Boyd 2018-04-28 06:59:23 +10:00
parent 2ec9a92268
commit 4d62867cb6
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 14 additions and 13 deletions

View File

@ -12,10 +12,12 @@ public class DataAnglePattern extends AbstractPattern {
public final Extent extent; public final Extent extent;
public final int maxY; public final int maxY;
public final double factor = 1d / 255; 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.extent = new ExtentHeightCacher(extent);
this.maxY = extent.getMaximumPoint().getBlockY(); this.maxY = extent.getMaximumPoint().getBlockY();
this.distance = distance;
} }
public int getSlope(BaseBlock block, Vector vector) { public int getSlope(BaseBlock block, Vector vector) {
@ -27,10 +29,10 @@ public class DataAnglePattern extends AbstractPattern {
} }
int slope; int slope;
boolean aboveMin; 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 + distance, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, 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, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x, z - distance, 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 + distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z - distance, 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 + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x + distance, z - distance, y, 0, maxY)) * 5;
return slope; return slope;
} }

View File

@ -17,8 +17,8 @@ public class AngleColorPattern extends DataAnglePattern {
private final boolean randomize; private final boolean randomize;
private final int complexity; private final int complexity;
public AngleColorPattern(Extent extent, int complexity, boolean randomize) { public AngleColorPattern(Extent extent, int complexity, boolean randomize, int distance) {
super(extent); super(extent, distance);
this.complexity = complexity; this.complexity = complexity;
this.randomize = randomize; this.randomize = randomize;
this.util = Fawe.get().getCachedTextureUtil(randomize, 0, complexity); this.util = Fawe.get().getCachedTextureUtil(randomize, 0, complexity);

View File

@ -264,7 +264,7 @@ public class MaskCommands extends MethodCommands {
"Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" + "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
"Example: /[3][20]\n" + "Example: /[3][20]\n" +
"Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below", "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below",
usage = "<min> <max>", usage = "<min> <max> [distance=1]",
min = 2, min = 2,
max = 2 max = 2
) )

View File

@ -71,7 +71,6 @@ import java.util.Set;
" - Use , to OR multiple\n" + " - Use , to OR multiple\n" +
"e.g. #surfacespread[10][#existing],andesite\n" + "e.g. #surfacespread[10][#existing],andesite\n" +
"More Info: https://git.io/vSPmA" "More Info: https://git.io/vSPmA"
) )
public class PatternCommands extends MethodCommands { public class PatternCommands extends MethodCommands {
public PatternCommands(WorldEdit worldEdit) { public PatternCommands(WorldEdit worldEdit) {
@ -125,13 +124,13 @@ public class PatternCommands extends MethodCommands {
@Command( @Command(
aliases = {"#anglecolor"}, aliases = {"#anglecolor"},
desc = "A darker block based on the existing terrain angle", 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, min = 0,
max = 2 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); 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( @Command(
@ -139,7 +138,7 @@ public class PatternCommands extends MethodCommands {
desc = "Block data based on the existing terrain angle" desc = "Block data based on the existing terrain angle"
) )
public Pattern angledata(Extent extent) { public Pattern angledata(Extent extent) {
return new DataAnglePattern(extent); return new DataAnglePattern(extent, 1);
} }
@Command( @Command(