Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 02:50:05 +01: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>
Dieser Commit ist enthalten in:
Ursprung
1fa0777d3b
Commit
de199a0e59
@ -33,7 +33,7 @@ public class MaskFilter<T extends Filter> extends DelegateFilter<T> {
|
||||
|
||||
@Override
|
||||
public void applyBlock(FilterBlock block) {
|
||||
if (mask.test(block, block)) {
|
||||
if (mask.test(block)) {
|
||||
getParent().applyBlock(block);
|
||||
this.changes++;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class XAxisMask extends AbstractMask implements ResettableMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (layer == -1) {
|
||||
layer = vector.getBlockX();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class YAxisMask extends AbstractMask implements ResettableMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (layer == -1) {
|
||||
layer = vector.getBlockY();
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe.function.mask;
|
||||
|
||||
import com.boydti.fawe.object.mask.ResettableMask;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
@ -9,11 +8,11 @@ public class ZAxisMask extends AbstractMask implements ResettableMask {
|
||||
|
||||
private transient int layer = -1;
|
||||
|
||||
public ZAxisMask(Extent extent) {
|
||||
public ZAxisMask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (layer == -1) {
|
||||
layer = vector.getBlockZ();
|
||||
}
|
||||
|
@ -4,14 +4,13 @@ import com.boydti.fawe.config.Caption;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualExtent;
|
||||
import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder;
|
||||
import com.boydti.fawe.object.function.NullRegionFunction;
|
||||
import com.boydti.fawe.object.function.mask.AbstractDelegateMask;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.mask.DelegateExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
@ -67,11 +66,11 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
||||
}
|
||||
final ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld());
|
||||
final int minY = position.getBlockY();
|
||||
mask = new DelegateExtentMask(editSession, mask) {
|
||||
mask = new AbstractDelegateMask(mask) {
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
if (super.test(extent, vector) && vector.getBlockY() >= minY) {
|
||||
BaseBlock block = vector.getFullBlock(editSession);
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (super.test(vector) && vector.getBlockY() >= minY) {
|
||||
BaseBlock block = editSession.getFullBlock(vector);
|
||||
if (!block.getBlockType().getMaterial().isAir()) {
|
||||
builder.add(vector, BlockTypes.AIR.getDefaultState().toBaseBlock(), block);
|
||||
return true;
|
||||
@ -81,7 +80,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
||||
}
|
||||
};
|
||||
// Add origin
|
||||
mask.test(editSession, position);
|
||||
mask.test(position);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, new NullRegionFunction(), (int) size);
|
||||
visitor.visit(position);
|
||||
Operations.completeBlindly(visitor);
|
||||
|
@ -88,8 +88,8 @@ public class ImageBrush implements Brush {
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
||||
private final MutableVector3 mutable = new MutableVector3();
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
if (solid.test(extent, vector)) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (solid.test(vector)) {
|
||||
int dx = vector.getBlockX() - cx;
|
||||
int dy = vector.getBlockY() - cy;
|
||||
int dz = vector.getBlockZ() - cz;
|
||||
|
@ -6,7 +6,6 @@ import com.boydti.fawe.object.mask.RadiusMask;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
@ -39,8 +38,8 @@ public class LayerBrush implements Brush {
|
||||
final RadiusMask radius = new RadiusMask(0, (int) size);
|
||||
visitor = new RecursiveVisitor(new Mask() {
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return solid.test(extent, vector) && radius.test(extent, vector) && adjacent.test(extent, vector);
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return solid.test(vector) && radius.test(vector) && adjacent.test(vector);
|
||||
}
|
||||
}, function -> true);
|
||||
visitor.visit(position);
|
||||
@ -49,7 +48,7 @@ public class LayerBrush implements Brush {
|
||||
BlockVectorSet visited = visitor.getVisited();
|
||||
visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 pos) {
|
||||
public boolean test(BlockVector3 pos) {
|
||||
int depth = visitor.getDepth() + 1;
|
||||
if (depth > 1) {
|
||||
boolean found = false;
|
||||
@ -71,7 +70,7 @@ public class LayerBrush implements Brush {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !adjacent.test(extent, pos);
|
||||
return !adjacent.test(pos);
|
||||
}
|
||||
}, pos -> {
|
||||
int depth = visitor.getDepth();
|
||||
|
@ -27,8 +27,6 @@ public class RecurseBrush implements Brush {
|
||||
Mask mask = editSession.getMask();
|
||||
if (mask == null) {
|
||||
mask = Masks.alwaysTrue();
|
||||
} else {
|
||||
mask = mask.withExtent(editSession);
|
||||
}
|
||||
final int radius = (int) size;
|
||||
BlockState block = editSession.getBlock(position);
|
||||
@ -44,7 +42,7 @@ public class RecurseBrush implements Brush {
|
||||
@Override
|
||||
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
||||
int y = to.getBlockY();
|
||||
return y < maxY && radMask.test(editSession, to) && super.isVisitable(from, to);
|
||||
return y < maxY && radMask.test(to) && super.isVisitable(from, to);
|
||||
}
|
||||
};
|
||||
visitor.visit(position);
|
||||
|
@ -8,7 +8,6 @@ import com.boydti.fawe.object.mask.SurfaceMask;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
@ -52,7 +51,7 @@ public class ScatterBrush implements Brush {
|
||||
|
||||
final int distance = Math.min((int) size, this.distance);
|
||||
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(radius, surface).withExtent(editSession), function -> true);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(radius, surface), function -> true);
|
||||
visitor.visit(position);
|
||||
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||
Operations.completeBlindly(visitor);
|
||||
@ -67,7 +66,7 @@ public class ScatterBrush implements Brush {
|
||||
for (int i = 0; i < count; i++) {
|
||||
int index = ThreadLocalRandom.current().nextInt(length);
|
||||
BlockVector3 pos = visited.get(index);
|
||||
if (pos != null && canApply(editSession, pos)) {
|
||||
if (pos != null && canApply(pos)) {
|
||||
int x = pos.getBlockX();
|
||||
int y = pos.getBlockY();
|
||||
int z = pos.getBlockZ();
|
||||
@ -88,12 +87,12 @@ public class ScatterBrush implements Brush {
|
||||
public void finish(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pos, Pattern pattern, double size) {
|
||||
}
|
||||
|
||||
public boolean canApply(EditSession editSession, BlockVector3 pos) {
|
||||
return mask.test(editSession, pos);
|
||||
public boolean canApply(BlockVector3 pos) {
|
||||
return mask.test(pos);
|
||||
}
|
||||
|
||||
public BlockVector3 getDirection(Extent extent, BlockVector3 pt) {
|
||||
return surface.direction(extent, pt);
|
||||
public BlockVector3 getDirection(BlockVector3 pt) {
|
||||
return surface.direction(pt);
|
||||
}
|
||||
|
||||
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws MaxChangedBlocksException {
|
||||
|
@ -16,7 +16,7 @@ public class ScatterOverlayBrush extends ScatterBrush {
|
||||
int x = pt.getBlockX();
|
||||
int y = pt.getBlockY();
|
||||
int z = pt.getBlockZ();
|
||||
BlockVector3 dir = getDirection(editSession, pt);
|
||||
BlockVector3 dir = getDirection(pt);
|
||||
editSession.setBlock(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ(), p);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class ShatterBrush extends ScatterBrush {
|
||||
int dSqr = (dx * dx) + (dy * dy) + (dz * dz);
|
||||
if (dSqr <= radius2) {
|
||||
BlockVector3 bv = mutable.setComponents(x2, y2, z2);
|
||||
if (surfaceTest.test(editSession, bv) && finalMask.test(editSession, bv)) {
|
||||
if (surfaceTest.test(bv) && finalMask.test( bv)) {
|
||||
// (collision) If it's visited and part of another frontier, set the block
|
||||
if (!placed.add(x2, y2, z2)) {
|
||||
if (!frontierVisited.contains(x2, y2, z2)) {
|
||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||
import com.boydti.fawe.object.mask.SurfaceMask;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
@ -38,10 +37,10 @@ public class SplatterBrush extends ScatterBrush {
|
||||
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
double dist = vector.distanceSq(position);
|
||||
if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2
|
||||
&& surface.test(extent, vector)) {
|
||||
&& surface.test(vector)) {
|
||||
placed.add(vector);
|
||||
return true;
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ public class SplineBrush implements Brush, ResettableTool {
|
||||
} else {
|
||||
mask = new MaskIntersection(mask, new IdMask(editSession));
|
||||
}
|
||||
mask = mask.withExtent(editSession);
|
||||
boolean visualization = editSession.getExtent() instanceof VisualExtent;
|
||||
if (visualization && positionSets.isEmpty()) {
|
||||
return;
|
||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.object.brush.heightmap.HeightMap;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
@ -48,7 +47,7 @@ public class StencilBrush extends HeightBrush {
|
||||
map.setSize(size);
|
||||
int cutoff = onlyWhite ? maxY : 0;
|
||||
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
||||
|
||||
|
||||
Location loc = editSession.getPlayer().getLocation();
|
||||
float yaw = loc.getYaw();
|
||||
float pitch = loc.getPitch();
|
||||
@ -58,7 +57,7 @@ public class StencilBrush extends HeightBrush {
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
||||
private final MutableVector3 mutable = new MutableVector3();
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (solid.test(vector)) {
|
||||
int dx = vector.getBlockX() - cx;
|
||||
int dy = vector.getBlockY() - cy;
|
||||
|
@ -21,7 +21,7 @@ public class SurfaceSphereBrush implements Brush {
|
||||
SurfaceMask surface = new SurfaceMask(editSession);
|
||||
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
||||
final RadiusMask radius = new RadiusMask(0, (int) size);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(surface, radius).withExtent(editSession), vector -> editSession.setBlock(vector, pattern));
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(surface, radius), vector -> editSession.setBlock(vector, pattern));
|
||||
visitor.visit(position);
|
||||
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||
Operations.completeBlindly(visitor);
|
||||
|
@ -579,7 +579,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int y = heights[index] & 0xFF;
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (mask.test(this, mutable)) {
|
||||
if (mask.test(mutable)) {
|
||||
int newHeight = table.average(x, z, index);
|
||||
setLayerHeightRaw(index, newHeight);
|
||||
}
|
||||
@ -641,7 +641,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (!mask.test(this, mutable)) {
|
||||
if (!mask.test(mutable)) {
|
||||
continue;
|
||||
}
|
||||
if (placed.containsRadius(x, z, distance)) {
|
||||
@ -691,7 +691,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (!mask.test(this, mutable)) {
|
||||
if (!mask.test(mutable)) {
|
||||
continue;
|
||||
}
|
||||
if (placed.containsRadius(x, z, distance)) {
|
||||
@ -1151,7 +1151,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
if (mask != null) {
|
||||
mutable.mutX(z);
|
||||
mutable.mutY(heights.getByte(index) & 0xFF);
|
||||
if (!mask.test(this, mutable)) {
|
||||
if (!mask.test(mutable)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1281,7 +1281,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(heights.getByte(index) & 0xFF);
|
||||
if (mask.test(this, mutable)) {
|
||||
if (mask.test(mutable)) {
|
||||
int color = img.getRGB(x, z);
|
||||
BlockType block = textureUtil.getNearestBlock(color);
|
||||
if (block != null) {
|
||||
@ -1358,7 +1358,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int y = heights.getByte(index) & 0xFF;
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (mask.test(this, mutable)) {
|
||||
if (mask.test(mutable)) {
|
||||
biomes.setByte(index, biomeByte);
|
||||
}
|
||||
}
|
||||
@ -1501,7 +1501,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int z = 0; z < getLength(); z++) {
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
filter.init(x, z, index);
|
||||
if (mask.test(this, filter)) {
|
||||
if (mask.test(filter)) {
|
||||
pattern.apply(this, filter, filter);
|
||||
}
|
||||
}
|
||||
@ -1522,7 +1522,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int z = 0; z < getLength(); z++) {
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
filter.init(x, z, index);
|
||||
if (mask.test(this, filter)) {
|
||||
if (mask.test(filter)) {
|
||||
pattern.apply(this, filter, filter);
|
||||
}
|
||||
}
|
||||
@ -1542,7 +1542,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int index = 0;
|
||||
for (int z = 0; z < getLength(); z++) {
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
if (mask.test(this, filter)) {
|
||||
if (mask.test(filter)) {
|
||||
pattern.apply(this, filter, filter);
|
||||
}
|
||||
}
|
||||
@ -1566,10 +1566,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
floorFilter.init(x, z, index);
|
||||
mainFilter.init(x, z, index);
|
||||
if (mask.test(this, mainFilter)) {
|
||||
if (mask.test(mainFilter)) {
|
||||
pattern.apply(this, mainFilter, mainFilter);
|
||||
}
|
||||
if (mask.test(this, floorFilter)) {
|
||||
if (mask.test(floorFilter)) {
|
||||
pattern.apply(this, floorFilter, floorFilter);
|
||||
}
|
||||
}
|
||||
@ -1887,7 +1887,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int y = heights.getByte(index) & 0xFF;
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (mask.test(this, mutable)) {
|
||||
if (mask.test(mutable)) {
|
||||
overlay.setInt(index, combined);
|
||||
}
|
||||
}
|
||||
@ -1902,7 +1902,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int y = heights.getByte(index) & 0xFF;
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (mask.test(this, mutable)) {
|
||||
if (mask.test(mutable)) {
|
||||
floor.setInt(index, combined);
|
||||
}
|
||||
}
|
||||
@ -1918,7 +1918,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int y = heights.getByte(index) & 0xFF;
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (mask.test(this, mutable)) {
|
||||
if (mask.test(mutable)) {
|
||||
main.setInt(index, combined);
|
||||
}
|
||||
}
|
||||
@ -1934,7 +1934,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int y = heights.getByte(index) & 0xFF;
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (mask.test(this, mutable)) {
|
||||
if (mask.test(mutable)) {
|
||||
floor.setInt(index, combined);
|
||||
main.setInt(index, combined);
|
||||
}
|
||||
|
@ -11,18 +11,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class SourceMaskExtent extends TemporalExtent {
|
||||
private Mask mask;
|
||||
private Extent get;
|
||||
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
public SourceMaskExtent(Extent extent, Mask mask) {
|
||||
this(extent, extent, mask);
|
||||
}
|
||||
|
||||
public SourceMaskExtent(Extent get, Extent set, Mask mask) {
|
||||
super(set);
|
||||
checkNotNull(get);
|
||||
super(extent);
|
||||
checkNotNull(mask);
|
||||
this.get = get;
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
@ -48,7 +41,7 @@ public class SourceMaskExtent extends TemporalExtent {
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||
set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
||||
return mask.test(get, location) && super.setBlock(location, block);
|
||||
return mask.test(location) && super.setBlock(location, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,6 +50,6 @@ public class SourceMaskExtent extends TemporalExtent {
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
mutable.mutZ(z);
|
||||
return mask.test(get, mutable) && super.setBlock(x, y, z, block);
|
||||
return mask.test(mutable) && super.setBlock(x, y, z, block);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
@ -25,20 +24,10 @@ public class AbstractDelegateMask extends AbstractMask {
|
||||
return mask.test(vector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 pos) {
|
||||
return mask.test(extent, pos);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return mask.toMask2D();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask withExtent(Extent extent) {
|
||||
mask.withExtent(extent);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -29,25 +29,25 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 v) {
|
||||
return direction(extent, v) != null;
|
||||
public boolean test(BlockVector3 v) {
|
||||
return direction(v) != null;
|
||||
}
|
||||
|
||||
public BlockVector3 direction(Extent extent, BlockVector3 v) {
|
||||
public BlockVector3 direction(BlockVector3 v) {
|
||||
int x = v.getBlockX();
|
||||
int y = v.getBlockY();
|
||||
int z = v.getBlockZ();
|
||||
if (mask.test(extent, x + 1, y, z)) {
|
||||
if (mask.test(x + 1, y, z)) {
|
||||
return mutable.setComponents(1, 0, 0);
|
||||
} else if (mask.test(extent, x - 1, y, z)) {
|
||||
} else if (mask.test(x - 1, y, z)) {
|
||||
return mutable.setComponents(-1, 0, 0);
|
||||
} else if (mask.test(extent, x, y, z + 1)) {
|
||||
} else if (mask.test(x, y, z + 1)) {
|
||||
return mutable.setComponents(0, 0, 1);
|
||||
} else if (mask.test(extent, x, y, z - 1)) {
|
||||
} else if (mask.test(x, y, z - 1)) {
|
||||
return mutable.setComponents(0, 0, -1);
|
||||
} else if (y < 256 && mask.test(extent, x, y + 1, z)) {
|
||||
} else if (y < 256 && mask.test(x, y + 1, z)) {
|
||||
return mutable.setComponents(0, 1, 0);
|
||||
} else if (y > 0 && mask.test(extent, x, y - 1, z)) {
|
||||
} else if (y > 0 && mask.test(x, y - 1, z)) {
|
||||
return mutable.setComponents(0, -1, 0);
|
||||
} else {
|
||||
return null;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -20,41 +19,41 @@ public class AdjacentMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 bv) {
|
||||
public boolean test(BlockVector3 bv) {
|
||||
vector.setComponents(bv);
|
||||
double x = bv.getX();
|
||||
double y = bv.getY();
|
||||
double z = bv.getZ();
|
||||
vector.mutX(x + 1);
|
||||
int count = 0;
|
||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutX(x);
|
||||
return true;
|
||||
}
|
||||
vector.mutX(x - 1);
|
||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutX(x);
|
||||
return true;
|
||||
}
|
||||
vector.mutX(x);
|
||||
vector.mutY(y + 1);
|
||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutY(y);
|
||||
return true;
|
||||
}
|
||||
vector.mutY(y - 1);
|
||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutY(y);
|
||||
return true;
|
||||
}
|
||||
vector.mutY(y);
|
||||
vector.mutZ(z + 1);
|
||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutZ(z);
|
||||
return true;
|
||||
}
|
||||
vector.mutZ(z - 1);
|
||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutZ(z);
|
||||
return true;
|
||||
}
|
||||
|
@ -124,53 +124,53 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean adjacentAir(Extent extent, BlockVector3 v) {
|
||||
public boolean adjacentAir(BlockVector3 v) {
|
||||
int x = v.getBlockX();
|
||||
int y = v.getBlockY();
|
||||
int z = v.getBlockZ();
|
||||
if (!mask.test(extent, x + 1, y, z)) {
|
||||
if (!mask.test(x + 1, y, z)) {
|
||||
return true;
|
||||
}
|
||||
if (!mask.test(extent, x - 1, y, z)) {
|
||||
if (!mask.test(x - 1, y, z)) {
|
||||
return true;
|
||||
}
|
||||
if (!mask.test(extent, x, y, z + 1)) {
|
||||
if (!mask.test(x, y, z + 1)) {
|
||||
return true;
|
||||
}
|
||||
if (!mask.test(extent, x, y, z - 1)) {
|
||||
if (!mask.test(x, y, z - 1)) {
|
||||
return true;
|
||||
}
|
||||
if (y < 255 && !mask.test(extent, x, y + 1, z)) {
|
||||
if (y < 255 && !mask.test(x, y + 1, z)) {
|
||||
return true;
|
||||
}
|
||||
if (y > 0 && !mask.test(extent, x, y - 1, z)) {
|
||||
if (y > 0 && !mask.test(x, y - 1, z)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
int x = vector.getBlockX();
|
||||
int y = vector.getBlockY();
|
||||
int z = vector.getBlockZ();
|
||||
|
||||
if ((lastX == (lastX = x) & lastZ == (lastZ = z))) {
|
||||
int height = getHeight(extent, x, y, z);
|
||||
int height = getHeight(getExtent(), x, y, z);
|
||||
if (y <= height) {
|
||||
return overlay ? (lastValue && y == height) : lastValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mask.test(extent, x, y, z)) {
|
||||
if (!mask.test(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
if (overlay) {
|
||||
if (y < 255 && !adjacentAir(extent, vector)) {
|
||||
if (y < 255 && !adjacentAir(vector)) {
|
||||
return lastValue = false;
|
||||
}
|
||||
}
|
||||
return testSlope(extent, x, y, z);
|
||||
return testSlope(getExtent(), x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||
import com.boydti.fawe.object.function.mask.AbstractDelegateMask;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
@ -42,21 +41,21 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return test(extent, vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return test(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
}
|
||||
|
||||
public boolean test(Extent extent, int x, int y, int z) {
|
||||
public boolean test(int x, int y, int z) {
|
||||
try {
|
||||
boolean check = cache_checked.add(x, y, z);
|
||||
if (!check) {
|
||||
return cache_results.contains(x, y, z);
|
||||
}
|
||||
boolean result = getMask().test(extent, mutable.setComponents(x, y, z));
|
||||
boolean result = getMask().test(mutable.setComponents(x, y, z));
|
||||
if (result) cache_results.add(x, y, z);
|
||||
return result;
|
||||
} catch (UnsupportedOperationException ignore) {
|
||||
boolean result = getMask().test(extent, mutable.setComponents(x, y, z));
|
||||
} catch (UnsupportedOperationException ignored) {
|
||||
boolean result = getMask().test(mutable.setComponents(x, y, z));
|
||||
if (y < 0 || y > 255) return result;
|
||||
resetCache();
|
||||
cache_checked.setOffset(x, z);
|
||||
|
@ -13,11 +13,11 @@ public class DataMask extends AbstractExtentMask implements ResettableMask {
|
||||
private transient int data = -1;
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (data != -1) {
|
||||
return extent.getBlock(vector).getInternalPropertiesId() == data;
|
||||
return getExtent().getBlock(vector).getInternalPropertiesId() == data;
|
||||
} else {
|
||||
data = extent.getBlock(vector).getInternalPropertiesId();
|
||||
data = getExtent().getBlock(vector).getInternalPropertiesId();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (combined != -1) {
|
||||
return extent.getBlock(vector).getInternalId() == combined;
|
||||
return getExtent().getBlock(vector).getInternalId() == combined;
|
||||
} else {
|
||||
combined = extent.getBlock(vector).getInternalId();
|
||||
combined = getExtent().getBlock(vector).getInternalId();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (id != -1) {
|
||||
return extent.getBlock(vector).getInternalBlockTypeId() == id;
|
||||
return getExtent().getBlock(vector).getInternalBlockTypeId() == id;
|
||||
} else {
|
||||
id = extent.getBlock(vector).getInternalBlockTypeId();
|
||||
id = getExtent().getBlock(vector).getInternalBlockTypeId();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class MaskedTargetBlock extends TargetBlock {
|
||||
Location lastBlock = null;
|
||||
while (getNextBlock() != null) {
|
||||
Location current = getCurrentBlock();
|
||||
if (!mask.test(world, current.toBlockPoint())) {
|
||||
if (!mask.test(current.toBlockPoint())) {
|
||||
if (searchForLastBlock) {
|
||||
lastBlock = current;
|
||||
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
@ -10,7 +9,7 @@ public class PlaneMask extends AbstractMask implements ResettableMask {
|
||||
private transient int originX = Integer.MAX_VALUE, originY = Integer.MAX_VALUE, originZ = Integer.MAX_VALUE;
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
switch (mode) {
|
||||
case -1:
|
||||
originX = vector.getBlockX();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
@ -20,7 +19,7 @@ public class RadiusMask extends AbstractMask implements ResettableMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 to) {
|
||||
public boolean test(BlockVector3 to) {
|
||||
if (pos == null) {
|
||||
pos = to.toImmutable();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
@ -16,7 +15,7 @@ public class RandomMask extends AbstractMask implements ResettableMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return random.nextInt() <= threshold;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.boydti.fawe.object.random.SimplexNoise;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
@ -15,7 +14,7 @@ public class SimplexMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
double value = SimplexNoise.noise(vector.getBlockX() * scale, vector.getBlockY() * scale, vector.getBlockZ() * scale);
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class SurfaceMask extends AdjacentAnyMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 v) {
|
||||
return !getParentMask().test(extent, v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(extent, v);
|
||||
public boolean test(BlockVector3 v) {
|
||||
return !getParentMask().test(v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(v);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -19,30 +18,30 @@ public class WallMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 bv) {
|
||||
public boolean test(BlockVector3 bv) {
|
||||
v.setComponents(bv);
|
||||
int count = 0;
|
||||
double x = v.getX();
|
||||
double y = v.getY();
|
||||
double z = v.getZ();
|
||||
v.mutX(x + 1);
|
||||
if (mask.test(extent, v) && ++count == min && max >= 8) {
|
||||
if (mask.test(v) && ++count == min && max >= 8) {
|
||||
v.mutX(x);
|
||||
return true;
|
||||
}
|
||||
v.mutX(x - 1);
|
||||
if (mask.test(extent, v) && ++count == min && max >= 8) {
|
||||
if (mask.test(v) && ++count == min && max >= 8) {
|
||||
v.mutX(x);
|
||||
return true;
|
||||
}
|
||||
v.mutX(x);
|
||||
v.mutZ(z + 1);
|
||||
if (mask.test(extent, v) && ++count == min && max >= 8) {
|
||||
if (mask.test(v) && ++count == min && max >= 8) {
|
||||
v.mutZ(z);
|
||||
return true;
|
||||
}
|
||||
v.mutZ(z - 1);
|
||||
if (mask.test(extent, v) && ++count == min && max >= 8) {
|
||||
if (mask.test(v) && ++count == min && max >= 8) {
|
||||
v.mutZ(z);
|
||||
return true;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class MaskedPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
if (mask.test(extent, get)) {
|
||||
if (mask.test(get)) {
|
||||
return primary.apply(extent, get, set);
|
||||
}
|
||||
return secondary.apply(extent, get, set);
|
||||
|
@ -42,7 +42,7 @@ public class FuzzyRegion extends AbstractRegion {
|
||||
}
|
||||
|
||||
public void select(int x, int y, int z) {
|
||||
RecursiveVisitor search = new RecursiveVisitor(mask.withExtent(extent), p -> {
|
||||
RecursiveVisitor search = new RecursiveVisitor(mask, p -> {
|
||||
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
|
||||
return true;
|
||||
}, 256);
|
||||
|
@ -376,7 +376,7 @@ public class TextureUtil implements TextureHolder {
|
||||
for (int typeId : tu.getValidBlockIds()) {
|
||||
BlockType block = BlockTypes.get(typeId);
|
||||
extent.init(0, 0, 0, block.getDefaultState().toBaseBlock());
|
||||
if (mask.test(extent, extent)) {
|
||||
if (mask.test(extent)) {
|
||||
blocks.add(block);
|
||||
}
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -53,6 +53,8 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -76,6 +78,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
super(worldEdit, new BlocksMaskParser(worldEdit));
|
||||
|
||||
register(new ExistingMaskParser(worldEdit));
|
||||
register(new AirMaskParser(worldEdit));
|
||||
register(new SolidMaskParser(worldEdit));
|
||||
register(new LazyRegionMaskParser(worldEdit));
|
||||
register(new RegionMaskParser(worldEdit));
|
||||
@ -84,11 +87,11 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
register(new BlockStateMaskParser(worldEdit));
|
||||
register(new NegateMaskParser(worldEdit));
|
||||
register(new ExpressionMaskParser(worldEdit));
|
||||
|
||||
register(new BlockCategoryMaskParser(worldEdit));
|
||||
register(new BiomeMaskParser(worldEdit));
|
||||
// Mask Parsers from FAWE
|
||||
register(new AdjacentMaskParser(worldEdit));
|
||||
register(new AirMaskParser(worldEdit));
|
||||
register(new AngleMaskParser(worldEdit));
|
||||
register(new ExtremaMaskParser(worldEdit));
|
||||
register(new FalseMaskParser(worldEdit));
|
||||
@ -124,18 +127,23 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
continue;
|
||||
}
|
||||
|
||||
Mask match = null;
|
||||
for (InputParser<Mask> parser : getParsers()) {
|
||||
Mask match = parser.parseFromInput(component, context);
|
||||
match = parser.parseFromInput(component, context);
|
||||
|
||||
if (match != null) {
|
||||
masks.add(match);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match == null) {
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(component)));
|
||||
}
|
||||
masks.add(match);
|
||||
}
|
||||
|
||||
switch (masks.size()) {
|
||||
case 0:
|
||||
throw new NoMatchException("No match for '" + input + "'");
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
case 1:
|
||||
return masks.get(0).optimize();
|
||||
default:
|
||||
|
@ -1,10 +1,31 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.boydti.fawe.function.mask.AirMask;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
|
||||
import java.util.List;
|
||||
@ -23,7 +44,7 @@ public class AirMaskParser extends SimpleInputParser<Mask> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
||||
return new AirMask(context.getExtent());
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
|
||||
return Masks.negate(new ExistingBlockMask(context.requireExtent()));
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,6 @@ public class ZAxisMaskParser extends SimpleInputParser<Mask> {
|
||||
|
||||
@Override
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
||||
return new ZAxisMask(context.getExtent());
|
||||
return new ZAxisMask();
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
maxY = Math.min(maxY, Math.max(0, maxY));
|
||||
minY = Math.max(0, minY);
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (filter.test(this, MutableBlockVector3.get(x, y, z))) {
|
||||
if (filter.test(MutableBlockVector3.get(x, y, z))) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
@ -276,22 +276,22 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
int clearanceAbove = maxY - y;
|
||||
int clearanceBelow = y - minY;
|
||||
int clearance = Math.min(clearanceAbove, clearanceBelow);
|
||||
boolean state = !mask.test(this, MutableBlockVector3.get(x, y, z));
|
||||
boolean state = !mask.test(MutableBlockVector3.get(x, y, z));
|
||||
int offset = state ? 0 : 1;
|
||||
for (int d = 0; d <= clearance; d++) {
|
||||
int y1 = y + d;
|
||||
if (mask.test(this, MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset;
|
||||
int y2 = y - d;
|
||||
if (mask.test(this, MutableBlockVector3.get(x, y2, z)) != state) return y2 + offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, y2, z)) != state) return y2 + offset;
|
||||
}
|
||||
if (clearanceAbove != clearanceBelow) {
|
||||
if (clearanceAbove < clearanceBelow) {
|
||||
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
||||
if (mask.test(this, MutableBlockVector3.get(x, layer, z)) != state) return layer + offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer + offset;
|
||||
}
|
||||
} else {
|
||||
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
||||
if (mask.test(this, MutableBlockVector3.get(x, layer, z)) != state) return layer - offset;
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer - offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -508,7 +508,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
* @return the number of blocks that matched the mask
|
||||
*/
|
||||
default int countBlocks(Region region, Mask searchMask) {
|
||||
RegionVisitor visitor = new RegionVisitor(region, position -> searchMask.test(this, position));
|
||||
RegionVisitor visitor = new RegionVisitor(region, position -> searchMask.test(position));
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
|
@ -79,17 +79,17 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||
return mask.test(getExtent(), location) && super.setBlock(location, block);
|
||||
return mask.test(location) && super.setBlock(location, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return mask.test(getExtent(), position.toBlockVector3()) && super.setBiome(position, biome);
|
||||
return mask.test(position.toBlockVector3()) && super.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return mask.test(getExtent(), BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome);
|
||||
return mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,7 +102,7 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
||||
public void applyBlock(FilterBlock block) {
|
||||
//TODO: Find a way to make masking thread safe without having to synchonise the whole extent
|
||||
synchronized (this) {
|
||||
if (!mask.test(getExtent(), block)) {
|
||||
if (!mask.test(block)) {
|
||||
block.setOrdinal(0);
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class ExtentBuffer extends AbstractBufferingExtent {
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||
if (mask.test(getExtent(), location)) {
|
||||
if (mask.test(location)) {
|
||||
buffer.put(location, block.toBaseBlock());
|
||||
return true;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
max = max.getMaximum(location);
|
||||
}
|
||||
|
||||
if (mask.test(getExtent(), location)) {
|
||||
if (mask.test( location)) {
|
||||
buffer.put(location, block.toBaseBlock());
|
||||
return true;
|
||||
} else {
|
||||
@ -131,7 +131,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
max2d = max2d.getMaximum(position);
|
||||
}
|
||||
|
||||
if (biomeMask.test(getExtent(), position)) {
|
||||
if (biomeMask.test(position)) {
|
||||
biomeBuffer.put(position, biome);
|
||||
return true;
|
||||
} else {
|
||||
@ -155,7 +155,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
max2d = max2d.getMaximum(BlockVector2.at(x,z));
|
||||
}
|
||||
|
||||
if (biomeMask.test(getExtent(), BlockVector2.at(x,z))) {
|
||||
if (biomeMask.test(BlockVector2.at(x,z))) {
|
||||
biomeBuffer.put(BlockVector2.at(x,z), biome);
|
||||
return true;
|
||||
} else {
|
||||
|
@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
@ -53,7 +52,7 @@ public class RegionMaskTestFunction implements RegionFunction {
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
if (mask.test(NullExtent.INSTANCE, position)) {
|
||||
if (mask.test(position)) {
|
||||
return pass.apply(position);
|
||||
} else {
|
||||
return fail.apply(position);
|
||||
|
@ -54,7 +54,7 @@ public class RegionMaskingFilter implements RegionFunction {
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return mask.test(extent, position) && function.apply(position);
|
||||
return mask.test(position) && function.apply(position);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class Naturalizer implements LayerFunction {
|
||||
|
||||
@Override
|
||||
public boolean isGround(BlockVector3 position) {
|
||||
return mask.test(editSession, position);
|
||||
return mask.test(position);
|
||||
}
|
||||
|
||||
private BlockState getTargetBlock(int depth) {
|
||||
@ -95,7 +95,7 @@ public class Naturalizer implements LayerFunction {
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||
if (mask.test(editSession, position)) {
|
||||
if (mask.test(position)) {
|
||||
if (naturalize(position, depth)) {
|
||||
++affected;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class OreGen implements Resource {
|
||||
@Override
|
||||
public boolean spawn(Random rand, int x, int z) throws WorldEditException {
|
||||
int y = rand.nextInt(maxY - minY) + minY;
|
||||
if (!mask.test(extent, mutable.setComponents(x, y, z))) {
|
||||
if (!mask.test(mutable.setComponents(x, y, z))) {
|
||||
return false;
|
||||
}
|
||||
double f = rand.nextDouble() * Math.PI;
|
||||
@ -102,7 +102,7 @@ public class OreGen implements Resource {
|
||||
double dz = (zz + 0.5D - d9) * id11o2;
|
||||
double dxyz2 = dxy2 + dz * dz;
|
||||
if ((dxyz2 < 1)) {
|
||||
if (mask.test(extent, mutable))
|
||||
if (mask.test(mutable))
|
||||
pattern.apply(extent, mutable, mutable);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class SchemGen implements Resource {
|
||||
int y = extent.getNearestSurfaceTerrainBlock(x, z, mutable.getBlockY(), 0, 255);
|
||||
if (y == -1) return false;
|
||||
mutable.mutY(y);
|
||||
if (!mask.test(extent, mutable)) {
|
||||
if (!mask.test(mutable)) {
|
||||
return false;
|
||||
}
|
||||
mutable.mutY(y + 1);
|
||||
|
@ -15,8 +15,8 @@ public abstract class ABlockMask extends AbstractExtentMask {
|
||||
super(extent);
|
||||
}
|
||||
|
||||
@Override public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return test(vector.getBlock(extent));
|
||||
@Override public boolean test(BlockVector3 vector) {
|
||||
return test(getExtent().getBlock(vector));
|
||||
}
|
||||
|
||||
public abstract boolean test(BlockState state);
|
||||
|
@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -40,10 +39,6 @@ public abstract class AbstractExtentMask extends AbstractMask {
|
||||
setExtent(extent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return test(getExtent(), vector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the extent.
|
||||
@ -64,9 +59,4 @@ public abstract class AbstractExtentMask extends AbstractMask {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask withExtent(Extent extent) {
|
||||
setExtent(extent);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A base class of {@link Mask} that all masks should inherit from.
|
||||
*/
|
||||
public abstract class AbstractMask implements Mask, Serializable {
|
||||
public abstract class AbstractMask implements Mask {
|
||||
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class BiomeMask2D extends AbstractMask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector2 vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
BiomeType biome = extent.getBiome(vector);
|
||||
return biomes.contains(biome);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class BlockCategoryMask extends AbstractExtentMask {
|
||||
|
||||
private BlockCategory category;
|
||||
private final BlockCategory category;
|
||||
|
||||
public BlockCategoryMask(Extent extent, BlockCategory category) {
|
||||
super(extent);
|
||||
@ -42,8 +42,8 @@ public class BlockCategoryMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return category.contains(vector.getBlock(extent));
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return category.contains(getExtent().getBlock(vector));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -188,8 +188,8 @@ public class BlockMask extends ABlockMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
int test = vector.getOrdinal(extent);
|
||||
public boolean test(BlockVector3 vector) {
|
||||
int test = getExtent().getBlock(vector).getOrdinal();
|
||||
return ordinals[test] || replacesAir() && test == 0;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class BlockStateMask extends AbstractExtentMask {
|
||||
|
||||
private final Map<String, String> states;
|
||||
private final boolean strict;
|
||||
private Map<BlockType, Map<Property<Object>, Object>> cache = Maps.newHashMap();
|
||||
private final Map<BlockType, Map<Property<Object>, Object>> cache = Maps.newHashMap();
|
||||
|
||||
/**
|
||||
* Creates a mask that checks if a given block has the desired properties set to the desired value.
|
||||
@ -53,8 +53,8 @@ public class BlockStateMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return test(vector.getBlock(extent));
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return test(getExtent().getBlock(vector));
|
||||
}
|
||||
|
||||
public boolean test(BlockState block) {
|
||||
|
@ -110,8 +110,8 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return test(vector.getBlock(extent).getBlockType());
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return test(getExtent().getBlock(vector).getBlockType());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -48,7 +47,7 @@ public class BoundedHeightMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return vector.getY() >= minY && vector.getY() <= maxY;
|
||||
}
|
||||
|
||||
|
@ -1,24 +1,11 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.boydti.fawe.object.function.mask.AbstractDelegateMask;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
public class DelegateExtentMask extends AbstractDelegateMask {
|
||||
private final Extent extent;
|
||||
|
||||
public DelegateExtentMask(Extent extent, Mask parent) {
|
||||
public DelegateExtentMask(Mask parent) {
|
||||
super(parent);
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return super.test(extent, vector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask withExtent(Extent extent) {
|
||||
return new DelegateExtentMask(extent, getMask());
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return !vector.getBlock(extent).getMaterial().isAir();
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.internal.expression.EvaluationException;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
@ -68,7 +67,7 @@ public class ExpressionMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
try {
|
||||
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
|
||||
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.internal.expression.EvaluationException;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
@ -61,7 +60,7 @@ public class ExpressionMask2D extends AbstractMask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector2 vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
try {
|
||||
if (timeout == null) {
|
||||
return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -13,8 +12,8 @@ public class InverseMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 pos) {
|
||||
return !mask.test(extent, pos);
|
||||
public boolean test(BlockVector3 pos) {
|
||||
return !mask.test(pos);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -19,8 +19,8 @@ public class InverseSingleBlockStateMask extends ABlockMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
int test = vector.getOrdinal(extent);
|
||||
public boolean test(BlockVector3 vector) {
|
||||
int test = getExtent().getBlock(vector).getOrdinal();
|
||||
if (isAir && test == 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -15,11 +14,6 @@ public class InverseSingleBlockTypeMask extends ABlockMask {
|
||||
this.internalId = type.getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return test(vector.getBlock(extent));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean test(BlockState state) {
|
||||
return state.getBlockType().getInternalId() != internalId;
|
||||
|
@ -22,10 +22,7 @@ package com.sk89q.worldedit.function.mask;
|
||||
import com.boydti.fawe.beta.Filter;
|
||||
import com.boydti.fawe.beta.implementation.filter.MaskFilter;
|
||||
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@ -41,26 +38,12 @@ public interface Mask {
|
||||
* @param vector the vector to test
|
||||
* @return true if the criteria is met
|
||||
*/
|
||||
default boolean test(BlockVector3 vector) {
|
||||
Extent extent = Request.request().getExtent();
|
||||
if (extent == null) {
|
||||
extent = NullExtent.INSTANCE;
|
||||
}
|
||||
return test(extent, vector);
|
||||
}
|
||||
|
||||
default boolean test(Extent extent, BlockVector3 vector) {
|
||||
return test(vector);
|
||||
}
|
||||
boolean test(BlockVector3 vector);
|
||||
|
||||
default <T extends Filter> MaskFilter<T> toFilter(T filter) {
|
||||
return new MaskFilter<>(filter, this);
|
||||
}
|
||||
|
||||
default Mask withExtent(Extent extent) {
|
||||
return new DelegateExtentMask(extent, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the 2D version of this mask if one exists.
|
||||
*
|
||||
@ -94,16 +77,6 @@ public interface Mask {
|
||||
return value == null ? this : value;
|
||||
}
|
||||
|
||||
default Mask and(Mask other) {
|
||||
Mask value = and(other);
|
||||
return value == null ? MaskIntersection.of(this, other) : value;
|
||||
}
|
||||
|
||||
default Mask or(Mask other) {
|
||||
Mask value = or(other);
|
||||
return value == null ? MaskUnion.of(this, other) : value;
|
||||
}
|
||||
|
||||
default Mask inverse() {
|
||||
if (this instanceof Masks.AlwaysTrue) {
|
||||
return Masks.ALWAYS_FALSE;
|
||||
@ -117,7 +90,7 @@ public interface Mask {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public void applyBlock(FilterBlock block) {
|
||||
if (test(block, block)) {
|
||||
if (test(block)) {
|
||||
run.accept(block);
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
|
||||
/**
|
||||
* Tests whether a given vector meets a criteria.
|
||||
@ -35,16 +32,6 @@ public interface Mask2D {
|
||||
* @param vector the vector to test
|
||||
* @return true if the criteria is met
|
||||
*/
|
||||
default boolean test(BlockVector2 vector) {
|
||||
Extent extent = Request.request().getExtent();
|
||||
if (extent == null) {
|
||||
extent = NullExtent.INSTANCE;
|
||||
}
|
||||
return test(extent, vector);
|
||||
}
|
||||
|
||||
default boolean test(Extent extent, BlockVector2 vector) {
|
||||
return test(vector);
|
||||
}
|
||||
boolean test(BlockVector2 vector);
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
@ -226,9 +225,9 @@ public class MaskIntersection extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
for (Mask mask : masksArray) {
|
||||
if (!mask.test(extent, vector)) {
|
||||
if (!mask.test( vector)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -84,13 +83,13 @@ public class MaskIntersection2D implements Mask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector2 vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
if (masks.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Mask2D mask : masks) {
|
||||
if (!mask.test(extent, vector)) {
|
||||
if (!mask.test(vector)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -86,11 +85,11 @@ public class MaskUnion extends MaskIntersection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
Mask[] masks = getMasksArray();
|
||||
|
||||
for (Mask mask : masks) {
|
||||
if (mask.test(extent, vector)) {
|
||||
if (mask.test(vector)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -48,11 +47,11 @@ public class MaskUnion2D extends MaskIntersection2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector2 vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
Collection<Mask2D> masks = getMasks();
|
||||
|
||||
for (Mask2D mask : masks) {
|
||||
if (mask.test(extent, vector)) {
|
||||
if (mask.test(vector)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
@ -43,7 +42,7 @@ public final class Masks {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 3D mask that always returns true;
|
||||
* Return a 3D mask that always returns true.
|
||||
*
|
||||
* @return a mask
|
||||
*/
|
||||
@ -56,7 +55,7 @@ public final class Masks {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 2D mask that always returns true;
|
||||
* Return a 2D mask that always returns true.
|
||||
*
|
||||
* @return a mask
|
||||
*/
|
||||
@ -90,8 +89,8 @@ public final class Masks {
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask2D() {
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector2 vector) {
|
||||
return !mask.test(extent, vector);
|
||||
public boolean test(BlockVector2 vector) {
|
||||
return !mask.test(vector);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -105,8 +104,8 @@ public final class Masks {
|
||||
public static Mask asMask(final Mask2D mask) {
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return mask.test(extent, vector.toBlockVector2());
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return mask.test(vector.toBlockVector2());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -119,12 +118,12 @@ public final class Masks {
|
||||
|
||||
protected static class AlwaysTrue implements Mask, Mask2D {
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector2 vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -144,20 +143,16 @@ public final class Masks {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask withExtent(Extent extent) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected static class AlwaysFalse implements Mask, Mask2D {
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector2 vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -177,10 +172,6 @@ public final class Masks {
|
||||
return other;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask withExtent(Extent extent) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableVector3;
|
||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||
@ -87,7 +86,7 @@ public class NoiseFilter extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return noiseGenerator.noise(MutableVector3.get(vector.getX(), vector.getY(), vector.getZ())) <= density;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||
|
||||
@ -84,7 +83,7 @@ public class NoiseFilter2D extends AbstractMask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector2 pos) {
|
||||
public boolean test(BlockVector2 pos) {
|
||||
return noiseGenerator.noise(pos.toVector2()) <= density;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -87,12 +86,12 @@ public class OffsetMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 pos) {
|
||||
BlockVector3 testPos = pos.add(offset);
|
||||
public boolean test(BlockVector3 vector) {
|
||||
BlockVector3 testPos = vector.add(offset);
|
||||
if (testPos.getBlockY() < 0 || testPos.getBlockY() > 255) {
|
||||
return false;
|
||||
}
|
||||
return getMask().test(extent, pos.add(offset));
|
||||
return getMask().test(vector.add(offset));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
|
||||
@ -88,9 +87,9 @@ public class OffsetMask2D extends AbstractMask2D {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector2 vector) {
|
||||
public boolean test(BlockVector2 vector) {
|
||||
mutable.setComponents(vector.getX() + offset.getX(), vector.getZ() + offset.getZ());
|
||||
return getMask().test(extent, mutable);
|
||||
return getMask().test(mutable);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
@ -63,7 +62,7 @@ public class RegionMask extends AbstractMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return region.contains(vector);
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ public class SingleBlockStateMask extends ABlockMask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
int test = vector.getOrdinal(extent);
|
||||
public boolean test(BlockVector3 vector) {
|
||||
int test = getExtent().getBlock(vector).getOrdinal();
|
||||
return ordinal == test || isAir && test == 0;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class SnapshotRestore {
|
||||
}
|
||||
|
||||
private void checkAndAddBlock(BlockVector3 pos) {
|
||||
if (editSession.getMask() != null && !editSession.getMask().test(editSession, pos))
|
||||
if (editSession.getMask() != null && !editSession.getMask().test(pos))
|
||||
return;
|
||||
|
||||
BlockVector2 chunkPos = ChunkStore.toChunk(pos);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren