From 164601644a4bbe09144b9e0c745aec79780ecaf5 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sun, 3 Nov 2013 10:15:28 +0100 Subject: [PATCH] //walls on non-cuboid regions no longer introduces gaps in walls beyond 45 degrees (aka slanted roofs :)). This is a better way to solve #273. --- .../java/com/sk89q/worldedit/EditSession.java | 15 ++++++++++++++- .../sk89q/worldedit/shape/ArbitraryShape.java | 19 ------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index 6f893dd71..0a1b49d61 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1654,7 +1654,20 @@ public class EditSession { * @throws MaxChangedBlocksException */ public int makeWalls(final Region region, Pattern pattern) throws MaxChangedBlocksException { - return new RegionShape(region).generate(this, pattern, true, true); + final int minY = region.getMinimumPoint().getBlockY(); + final int maxY = region.getMaximumPoint().getBlockY(); + final ArbitraryShape shape = new RegionShape(region) { + @Override + protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) { + if (y > maxY || y < minY) { + // Put holes into the floor and ceiling by telling ArbitraryShape that the shape goes on outside the region + return defaultMaterial; + } + + return super.getMaterial(x, y, z, defaultMaterial); + } + }; + return shape.generate(this, pattern, true); } /** diff --git a/src/main/java/com/sk89q/worldedit/shape/ArbitraryShape.java b/src/main/java/com/sk89q/worldedit/shape/ArbitraryShape.java index 868cb3e0a..785a10013 100644 --- a/src/main/java/com/sk89q/worldedit/shape/ArbitraryShape.java +++ b/src/main/java/com/sk89q/worldedit/shape/ArbitraryShape.java @@ -148,20 +148,6 @@ public abstract class ArbitraryShape { * @throws MaxChangedBlocksException */ public int generate(EditSession editSession, Pattern pattern, boolean hollow) throws MaxChangedBlocksException { - return generate(editSession, pattern, hollow, false); - } - - /** - * Generates the shape. - * - * @param editSession The EditSession to use. - * @param pattern The pattern to generate default materials from. - * @param hollow Specifies whether to generate a hollow shape. - * @param flat If hollow mode is enabled, disregard blocks above/below - * @return number of affected blocks. - * @throws MaxChangedBlocksException - */ - public int generate(EditSession editSession, Pattern pattern, boolean hollow, boolean flat) throws MaxChangedBlocksException { int affected = 0; for (BlockVector position : getExtent()) { @@ -201,11 +187,6 @@ public abstract class ArbitraryShape { draw = true; break; } - - if (flat) { - break; - } - if (!isInsideCached(x, y + 1, z, pattern)) { draw = true; break;