From 34ea713d293d8e005aa5819017fc3d74e23677bf Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 24 Jun 2022 15:04:11 +0100 Subject: [PATCH] Fix walls command on 1D/2D selection (#1821) --- .../main/java/com/sk89q/worldedit/EditSession.java | 10 ++++------ .../com/sk89q/worldedit/regions/CuboidRegion.java | 12 +++++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index f4bb7bd6a..75a010a75 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1671,12 +1671,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { checkNotNull(region); checkNotNull(pattern); - //FAWE start - int blocksChanged = 0; - for (Region wall : CuboidRegion.makeCuboid(region).getWalls().getRegions()) { - blocksChanged += setBlocks(wall, pattern); - } - return blocksChanged; + CuboidRegion cuboid = CuboidRegion.makeCuboid(region); + //FAWE start - specify RegionIntersection + Region faces = cuboid.getWalls(); + return setBlocks((Set) faces, pattern); //FAWE end } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 7f793d36b..4706a1186 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -215,9 +215,17 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { * * @return a new complex region */ - public RegionIntersection getWalls() { + public Region getWalls() { BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); + BlockVector3 dimensions = getDimensions(); + + //FAWE start + if (dimensions.getX() <= 2 || dimensions.getZ() <= 2) { + // The wall are the region + return new RegionIntersection(this); + } + //FAWE end return new RegionIntersection( // Project to Z-Y plane @@ -225,6 +233,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { new CuboidRegion(pos1.withX(max.getX()), pos2.withX(max.getX())), // Project to X-Y plane + //FAWE start = prevent overlap new CuboidRegion( pos1.withZ(min.getZ()).add(BlockVector3.UNIT_X), pos2.withZ(min.getZ()).subtract(BlockVector3.UNIT_X) @@ -233,6 +242,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { pos1.withZ(max.getZ()).add(BlockVector3.UNIT_X), pos2.withZ(max.getZ()).subtract(BlockVector3.UNIT_X) ) + //FAWE end ); }