From 177e2252cc9d4e0108aa5327a965953c138834cb Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 10 Mar 2017 08:39:39 +1100 Subject: [PATCH] Stencil brush depth --- .../com/boydti/fawe/object/brush/StencilBrush.java | 8 ++++++-- .../com/sk89q/worldedit/command/BrushCommands.java | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java b/core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java index af4ee7af..9f176de4 100644 --- a/core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java +++ b/core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java @@ -12,10 +12,12 @@ import java.io.InputStream; public class StencilBrush extends HeightBrush { private final boolean onlyWhite; + private final int depth; - public StencilBrush(InputStream stream, int rotation, double yscale, boolean onlyWhite, Clipboard clipboard) { + public StencilBrush(InputStream stream, int depth, int rotation, double yscale, boolean onlyWhite, Clipboard clipboard) { super(stream, rotation, yscale, clipboard); this.onlyWhite = onlyWhite; + this.depth = depth; } @Override @@ -44,7 +46,9 @@ public class StencilBrush extends HeightBrush { if (val >= 255 || PseudoRandom.random.random(maxY) < val) { int zz = position.getBlockZ() + z; int y = editSession.getNearestSurfaceTerrainBlock(xx, zz, position.getBlockY(), 0, maxY); - editSession.setBlock(xx, y, zz, pattern); + for (int i = 0; i < depth; i++) { + editSession.setBlock(xx, y - i, zz, pattern); + } } } } diff --git a/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index b300e421..2114bb10 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -34,10 +34,10 @@ import com.boydti.fawe.object.brush.HeightBrush; import com.boydti.fawe.object.brush.LineBrush; import com.boydti.fawe.object.brush.RaiseBrush; import com.boydti.fawe.object.brush.RecurseBrush; +import com.boydti.fawe.object.brush.ShatterBrush; import com.boydti.fawe.object.brush.SplineBrush; import com.boydti.fawe.object.brush.StencilBrush; import com.boydti.fawe.object.brush.TargetMode; -import com.boydti.fawe.object.brush.ShatterBrush; import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap; import com.boydti.fawe.object.brush.scroll.ScrollClipboard; import com.boydti.fawe.object.brush.scroll.ScrollMask; @@ -533,7 +533,7 @@ public class BrushCommands { @Command( aliases = { "stencil", "color"}, - usage = " [radius] [file|#clipboard|null] [rotation] [yscale]", + usage = " [radius] [depth] [file|#clipboard|null] [rotation] [yscale]", desc = "Use a height map to paint a surface", help = "Chooses the stencil brush.\n" + @@ -542,16 +542,16 @@ public class BrushCommands { max = -1 ) @CommandPermissions("worldedit.brush.stencil") - public void stencilBrush(Player player, LocalSession session, Pattern fill, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale, @Switch('w') boolean onlyWhite) throws WorldEditException { + public void stencilBrush(Player player, LocalSession session, Pattern fill, @Optional("5") double radius, @Optional("1") double depth, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale, @Switch('w') boolean onlyWhite) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); BrushTool tool = session.getBrushTool(player); InputStream stream = getHeightmapStream(filename); tool.setFill(fill); tool.setSize(radius); try { - tool.setBrush(new StencilBrush(stream, rotation, yscale, onlyWhite, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null), "worldedit.brush.height", player); + tool.setBrush(new StencilBrush(stream, (int) depth, rotation, yscale, onlyWhite, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null), "worldedit.brush.height", player); } catch (EmptyClipboardException ignore) { - tool.setBrush(new StencilBrush(stream, rotation, yscale, onlyWhite, null), "worldedit.brush.height", player); + tool.setBrush(new StencilBrush(stream, (int) depth, rotation, yscale, onlyWhite, null), "worldedit.brush.height", player); } player.print(BBC.getPrefix() + BBC.BRUSH_STENCIL.f(radius));