From 34afc034433e3be1575ea4697b5453a56b7e2e62 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Nov 2019 23:49:16 +0000 Subject: [PATCH] fix walls --- .../implementation/chunk/ChunkHolder.java | 2 +- .../worldedit/regions/AbstractRegion.java | 20 +++---- .../sk89q/worldedit/regions/CuboidRegion.java | 8 +-- .../worldedit/regions/RegionIntersection.java | 52 +++++++++++++++++++ 4 files changed, 64 insertions(+), 18 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java index 05dc69ab1..2aea39ee4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java @@ -316,10 +316,10 @@ public class ChunkHolder> implements IQueueChunk { final IChunkGet get = getOrCreateGet(); final IChunkSet set = getOrCreateSet(); try { + block = block.init(chunkX, chunkZ, get); if (region != null) { region.filter(this, filter, block, get, set, full); } else { - block = block.init(chunkX, chunkZ, get); for (int layer = 0; layer < 16; layer++) { if ((!full && !get.hasSection(layer)) || !filter.appliesLayer(this, layer)) { continue; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java index b79dbca1c..5c0049c87 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.regions; +import com.boydti.fawe.FaweCache; import com.boydti.fawe.object.collection.BlockVectorSet; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; @@ -169,21 +170,14 @@ public abstract class AbstractRegion extends AbstractSet implement public Set getChunks() { final Set chunks = new HashSet<>(); - final BlockVector3 min = getMinimumPoint(); - final BlockVector3 max = getMaximumPoint(); + final BlockVector3 min = getMinimumPoint().divide(16); + final BlockVector3 max = getMaximumPoint().divide(16); - final int minY = min.getBlockY(); - - for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { - if (!contains(BlockVector3.at(x, minY, z))) { - continue; + for (int X = min.getBlockX(); X <= max.getBlockX(); ++X) { + for (int Z = min.getBlockZ(); Z <= max.getBlockZ(); ++Z) { + if (containsChunk(X, Z)) { + chunks.add(BlockVector2.at(X, Z)); } - - chunks.add(BlockVector2.at( - x >> ChunkStore.CHUNK_SHIFTS, - z >> ChunkStore.CHUNK_SHIFTS - )); } } 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 255143706..3882bfec3 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 @@ -148,7 +148,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { * * @return a new complex region */ - public Region getFaces() { + public RegionIntersection getFaces() { BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); @@ -172,7 +172,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { * * @return a new complex region */ - public Region getWalls() { + public RegionIntersection getWalls() { BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); @@ -182,8 +182,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { new CuboidRegion(pos1.withX(max.getX()), pos2.withX(max.getX())), // Project to X-Y plane - new CuboidRegion(pos1.withZ(min.getZ()), pos2.withZ(min.getZ())), - new CuboidRegion(pos1.withZ(max.getZ()), pos2.withZ(max.getZ()))); + new CuboidRegion(pos1.withZ(min.getZ()).add(BlockVector3.UNIT_X), pos2.withZ(min.getZ()).subtract(BlockVector3.UNIT_X)), + new CuboidRegion(pos1.withZ(max.getZ()).add(BlockVector3.UNIT_X), pos2.withZ(max.getZ()).subtract(BlockVector3.UNIT_X))); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java index 8ea1c780c..c56d9413f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java @@ -23,13 +23,17 @@ import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; import com.google.common.collect.Iterators; +import com.google.common.collect.Sets; +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -169,4 +173,52 @@ public class RegionIntersection extends AbstractRegion { } return null; } + + public List getRegions() { + return regions; + } + + @Override + public Set getChunks() { + Set set = null; + for (Region region : regions) { + if (set == null) { + set = region.getChunks(); + } else { + set = Sets.union(set, region.getChunks()); + } + } + return set; + } + + @Override + public Set getChunkCubes() { + Set set = null; + for (Region region : regions) { + if (set == null) { + set = region.getChunkCubes(); + } else { + set = Sets.union(set, region.getChunkCubes()); + } + } + return set; + } + + @Override + public boolean containsChunk(int chunkX, int chunkZ) { + for (Region region : regions) if (region.containsChunk(chunkX, chunkZ)) return true; + return false; + } + + @Override + public boolean contains(int x, int z) { + for (Region region : regions) if (region.contains(x, z)) return true; + return false; + } + + @Override + public boolean contains(int x, int y, int z) { + for (Region region : regions) if (region.contains(x, y, z)) return true; + return false; + } }