mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
More work on masks (#607)
* Add a #air mask, the opposite of #existing (#1511) (cherry picked from commit 84fa2bbbc63de7bece01f41c0d5cb7d85cf129e6) * Remove unused methods in Mask.java * Remove `test(Extent, BlockVector3)` from Masks. This was a poorly planned idea. This should save some memory too. Authored-by: Matthew Miller <mnmiller1@me.com>
This commit is contained in:
@ -144,13 +144,13 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* An {@link Extent} that handles history, {@link BlockBag}s, change limits,
|
||||
@ -804,7 +804,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
*/
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (filter.test(getExtent(), mutablebv.setComponents(x, y, z))) {
|
||||
if (filter.test(mutablebv.setComponents(x, y, z))) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
@ -1135,7 +1135,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
if (direction.equals(BlockVector3.at(0, -1, 0))) {
|
||||
return fillXZ(origin, pattern, radius, depth, false);
|
||||
}
|
||||
Mask mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this))).withExtent(getExtent());
|
||||
Mask mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this)));
|
||||
// Want to replace blocks
|
||||
final BlockReplace replace = new BlockReplace(EditSession.this, pattern);
|
||||
|
||||
@ -1187,7 +1187,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
new BoundedHeightMask(
|
||||
Math.max(origin.getBlockY() - depth + 1, getMinimumPoint().getBlockY()),
|
||||
Math.min(getMaxY(), origin.getBlockY())),
|
||||
Masks.negate(new ExistingBlockMask(this))).withExtent(getExtent());
|
||||
Masks.negate(new ExistingBlockMask(this)));
|
||||
// Want to replace blocks
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
|
||||
@ -1399,7 +1399,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
} else {
|
||||
replaceBlocks(region, new Mask() {
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 position) {
|
||||
public boolean test(BlockVector3 position) {
|
||||
int x = position.getBlockX();
|
||||
int z = position.getBlockZ();
|
||||
return !region.contains(x, z + 1) || !region.contains(x, z - 1) || !region
|
||||
@ -1660,7 +1660,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
Mask mask = new MaskIntersection(
|
||||
new BoundedHeightMask(0, getWorld().getMaxY()),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||
liquidMask).withExtent(getExtent());
|
||||
liquidMask);
|
||||
BlockReplace replace;
|
||||
if (waterlogged) {
|
||||
replace = new BlockReplace(this, new WaterloggedRemover(this));
|
||||
@ -1671,7 +1671,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
// Around the origin in a 3x3 block
|
||||
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||
if (mask.test(getExtent(), position)) {
|
||||
if (mask.test(position)) {
|
||||
visitor.visit(position);
|
||||
}
|
||||
}
|
||||
@ -1705,13 +1705,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||
blockMask
|
||||
).withExtent(getExtent());
|
||||
);
|
||||
BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
|
||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||
|
||||
// Around the origin in a 3x3 block
|
||||
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||
if (liquidMask.test(getExtent(), position)) {
|
||||
if (liquidMask.test(position)) {
|
||||
visitor.visit(position);
|
||||
}
|
||||
}
|
||||
@ -2890,7 +2890,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
while (iter.hasNext()) {
|
||||
final BlockVector3 current = iter.next();
|
||||
iter.remove();
|
||||
if (mask.test(getExtent(), current)) {
|
||||
if (mask.test(current)) {
|
||||
continue;
|
||||
}
|
||||
if (!outside.add(current)) {
|
||||
|
Reference in New Issue
Block a user