Fix walls command on 1D/2D selection (#1821)

This commit is contained in:
Jordan 2022-06-24 15:04:11 +01:00 committed by GitHub
parent 38d1a64bf5
commit 34ea713d29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -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<BlockVector3>) faces, pattern);
//FAWE end
}

View File

@ -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
);
}