mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 17:58:36 +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:
@ -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);
|
||||
|
Reference in New Issue
Block a user