geforkt von Mirrors/FastAsyncWorldEdit
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
|
@Override
|
||||||
public void applyBlock(FilterBlock block) {
|
public void applyBlock(FilterBlock block) {
|
||||||
if (mask.test(block, block)) {
|
if (mask.test(block)) {
|
||||||
getParent().applyBlock(block);
|
getParent().applyBlock(block);
|
||||||
this.changes++;
|
this.changes++;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class XAxisMask extends AbstractMask implements ResettableMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (layer == -1) {
|
if (layer == -1) {
|
||||||
layer = vector.getBlockX();
|
layer = vector.getBlockX();
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class YAxisMask extends AbstractMask implements ResettableMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (layer == -1) {
|
if (layer == -1) {
|
||||||
layer = vector.getBlockY();
|
layer = vector.getBlockY();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.boydti.fawe.function.mask;
|
package com.boydti.fawe.function.mask;
|
||||||
|
|
||||||
import com.boydti.fawe.object.mask.ResettableMask;
|
import com.boydti.fawe.object.mask.ResettableMask;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
@ -9,11 +8,11 @@ public class ZAxisMask extends AbstractMask implements ResettableMask {
|
|||||||
|
|
||||||
private transient int layer = -1;
|
private transient int layer = -1;
|
||||||
|
|
||||||
public ZAxisMask(Extent extent) {
|
public ZAxisMask() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (layer == -1) {
|
if (layer == -1) {
|
||||||
layer = vector.getBlockZ();
|
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.brush.visualization.VisualExtent;
|
||||||
import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder;
|
import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder;
|
||||||
import com.boydti.fawe.object.function.NullRegionFunction;
|
import com.boydti.fawe.object.function.NullRegionFunction;
|
||||||
|
import com.boydti.fawe.object.function.mask.AbstractDelegateMask;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
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.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.Masks;
|
import com.sk89q.worldedit.function.mask.Masks;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
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 ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld());
|
||||||
final int minY = position.getBlockY();
|
final int minY = position.getBlockY();
|
||||||
mask = new DelegateExtentMask(editSession, mask) {
|
mask = new AbstractDelegateMask(mask) {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (super.test(extent, vector) && vector.getBlockY() >= minY) {
|
if (super.test(vector) && vector.getBlockY() >= minY) {
|
||||||
BaseBlock block = vector.getFullBlock(editSession);
|
BaseBlock block = editSession.getFullBlock(vector);
|
||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
builder.add(vector, BlockTypes.AIR.getDefaultState().toBaseBlock(), block);
|
builder.add(vector, BlockTypes.AIR.getDefaultState().toBaseBlock(), block);
|
||||||
return true;
|
return true;
|
||||||
@ -81,7 +80,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Add origin
|
// Add origin
|
||||||
mask.test(editSession, position);
|
mask.test(position);
|
||||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, new NullRegionFunction(), (int) size);
|
RecursiveVisitor visitor = new RecursiveVisitor(mask, new NullRegionFunction(), (int) size);
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
|
@ -88,8 +88,8 @@ public class ImageBrush implements Brush {
|
|||||||
RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
||||||
private final MutableVector3 mutable = new MutableVector3();
|
private final MutableVector3 mutable = new MutableVector3();
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (solid.test(extent, vector)) {
|
if (solid.test(vector)) {
|
||||||
int dx = vector.getBlockX() - cx;
|
int dx = vector.getBlockX() - cx;
|
||||||
int dy = vector.getBlockY() - cy;
|
int dy = vector.getBlockY() - cy;
|
||||||
int dz = vector.getBlockZ() - cz;
|
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.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
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.AbstractExtentMask;
|
||||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
@ -39,8 +38,8 @@ public class LayerBrush implements Brush {
|
|||||||
final RadiusMask radius = new RadiusMask(0, (int) size);
|
final RadiusMask radius = new RadiusMask(0, (int) size);
|
||||||
visitor = new RecursiveVisitor(new Mask() {
|
visitor = new RecursiveVisitor(new Mask() {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return solid.test(extent, vector) && radius.test(extent, vector) && adjacent.test(extent, vector);
|
return solid.test(vector) && radius.test(vector) && adjacent.test(vector);
|
||||||
}
|
}
|
||||||
}, function -> true);
|
}, function -> true);
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
@ -49,7 +48,7 @@ public class LayerBrush implements Brush {
|
|||||||
BlockVectorSet visited = visitor.getVisited();
|
BlockVectorSet visited = visitor.getVisited();
|
||||||
visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 pos) {
|
public boolean test(BlockVector3 pos) {
|
||||||
int depth = visitor.getDepth() + 1;
|
int depth = visitor.getDepth() + 1;
|
||||||
if (depth > 1) {
|
if (depth > 1) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@ -71,7 +70,7 @@ public class LayerBrush implements Brush {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !adjacent.test(extent, pos);
|
return !adjacent.test(pos);
|
||||||
}
|
}
|
||||||
}, pos -> {
|
}, pos -> {
|
||||||
int depth = visitor.getDepth();
|
int depth = visitor.getDepth();
|
||||||
|
@ -27,8 +27,6 @@ public class RecurseBrush implements Brush {
|
|||||||
Mask mask = editSession.getMask();
|
Mask mask = editSession.getMask();
|
||||||
if (mask == null) {
|
if (mask == null) {
|
||||||
mask = Masks.alwaysTrue();
|
mask = Masks.alwaysTrue();
|
||||||
} else {
|
|
||||||
mask = mask.withExtent(editSession);
|
|
||||||
}
|
}
|
||||||
final int radius = (int) size;
|
final int radius = (int) size;
|
||||||
BlockState block = editSession.getBlock(position);
|
BlockState block = editSession.getBlock(position);
|
||||||
@ -44,7 +42,7 @@ public class RecurseBrush implements Brush {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
||||||
int y = to.getBlockY();
|
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);
|
visitor.visit(position);
|
||||||
|
@ -8,7 +8,6 @@ import com.boydti.fawe.object.mask.SurfaceMask;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
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.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||||
import com.sk89q.worldedit.function.mask.Masks;
|
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);
|
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.visit(position);
|
||||||
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
@ -67,7 +66,7 @@ public class ScatterBrush implements Brush {
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
int index = ThreadLocalRandom.current().nextInt(length);
|
int index = ThreadLocalRandom.current().nextInt(length);
|
||||||
BlockVector3 pos = visited.get(index);
|
BlockVector3 pos = visited.get(index);
|
||||||
if (pos != null && canApply(editSession, pos)) {
|
if (pos != null && canApply(pos)) {
|
||||||
int x = pos.getBlockX();
|
int x = pos.getBlockX();
|
||||||
int y = pos.getBlockY();
|
int y = pos.getBlockY();
|
||||||
int z = pos.getBlockZ();
|
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 void finish(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pos, Pattern pattern, double size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canApply(EditSession editSession, BlockVector3 pos) {
|
public boolean canApply(BlockVector3 pos) {
|
||||||
return mask.test(editSession, pos);
|
return mask.test(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockVector3 getDirection(Extent extent, BlockVector3 pt) {
|
public BlockVector3 getDirection(BlockVector3 pt) {
|
||||||
return surface.direction(extent, pt);
|
return surface.direction(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws MaxChangedBlocksException {
|
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 x = pt.getBlockX();
|
||||||
int y = pt.getBlockY();
|
int y = pt.getBlockY();
|
||||||
int z = pt.getBlockZ();
|
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);
|
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);
|
int dSqr = (dx * dx) + (dy * dy) + (dz * dz);
|
||||||
if (dSqr <= radius2) {
|
if (dSqr <= radius2) {
|
||||||
BlockVector3 bv = mutable.setComponents(x2, y2, z2);
|
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
|
// (collision) If it's visited and part of another frontier, set the block
|
||||||
if (!placed.add(x2, y2, z2)) {
|
if (!placed.add(x2, y2, z2)) {
|
||||||
if (!frontierVisited.contains(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.boydti.fawe.object.mask.SurfaceMask;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
@ -38,10 +37,10 @@ public class SplatterBrush extends ScatterBrush {
|
|||||||
|
|
||||||
RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
double dist = vector.distanceSq(position);
|
double dist = vector.distanceSq(position);
|
||||||
if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2
|
if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2
|
||||||
&& surface.test(extent, vector)) {
|
&& surface.test(vector)) {
|
||||||
placed.add(vector);
|
placed.add(vector);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ public class SplineBrush implements Brush, ResettableTool {
|
|||||||
} else {
|
} else {
|
||||||
mask = new MaskIntersection(mask, new IdMask(editSession));
|
mask = new MaskIntersection(mask, new IdMask(editSession));
|
||||||
}
|
}
|
||||||
mask = mask.withExtent(editSession);
|
|
||||||
boolean visualization = editSession.getExtent() instanceof VisualExtent;
|
boolean visualization = editSession.getExtent() instanceof VisualExtent;
|
||||||
if (visualization && positionSets.isEmpty()) {
|
if (visualization && positionSets.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.object.brush.heightmap.HeightMap;
|
|||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
@ -58,7 +57,7 @@ public class StencilBrush extends HeightBrush {
|
|||||||
RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
|
||||||
private final MutableVector3 mutable = new MutableVector3();
|
private final MutableVector3 mutable = new MutableVector3();
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (solid.test(vector)) {
|
if (solid.test(vector)) {
|
||||||
int dx = vector.getBlockX() - cx;
|
int dx = vector.getBlockX() - cx;
|
||||||
int dy = vector.getBlockY() - cy;
|
int dy = vector.getBlockY() - cy;
|
||||||
|
@ -21,7 +21,7 @@ public class SurfaceSphereBrush implements Brush {
|
|||||||
SurfaceMask surface = new SurfaceMask(editSession);
|
SurfaceMask surface = new SurfaceMask(editSession);
|
||||||
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
||||||
final RadiusMask radius = new RadiusMask(0, (int) size);
|
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.visit(position);
|
||||||
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
|
@ -579,7 +579,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
int y = heights[index] & 0xFF;
|
int y = heights[index] & 0xFF;
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
if (mask.test(this, mutable)) {
|
if (mask.test(mutable)) {
|
||||||
int newHeight = table.average(x, z, index);
|
int newHeight = table.average(x, z, index);
|
||||||
setLayerHeightRaw(index, newHeight);
|
setLayerHeightRaw(index, newHeight);
|
||||||
}
|
}
|
||||||
@ -641,7 +641,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
if (!mask.test(this, mutable)) {
|
if (!mask.test(mutable)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (placed.containsRadius(x, z, distance)) {
|
if (placed.containsRadius(x, z, distance)) {
|
||||||
@ -691,7 +691,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
if (!mask.test(this, mutable)) {
|
if (!mask.test(mutable)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (placed.containsRadius(x, z, distance)) {
|
if (placed.containsRadius(x, z, distance)) {
|
||||||
@ -1151,7 +1151,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
if (mask != null) {
|
if (mask != null) {
|
||||||
mutable.mutX(z);
|
mutable.mutX(z);
|
||||||
mutable.mutY(heights.getByte(index) & 0xFF);
|
mutable.mutY(heights.getByte(index) & 0xFF);
|
||||||
if (!mask.test(this, mutable)) {
|
if (!mask.test(mutable)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1281,7 +1281,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
for (int x = 0; x < getWidth(); x++, index++) {
|
for (int x = 0; x < getWidth(); x++, index++) {
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(heights.getByte(index) & 0xFF);
|
mutable.mutY(heights.getByte(index) & 0xFF);
|
||||||
if (mask.test(this, mutable)) {
|
if (mask.test(mutable)) {
|
||||||
int color = img.getRGB(x, z);
|
int color = img.getRGB(x, z);
|
||||||
BlockType block = textureUtil.getNearestBlock(color);
|
BlockType block = textureUtil.getNearestBlock(color);
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
@ -1358,7 +1358,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
int y = heights.getByte(index) & 0xFF;
|
int y = heights.getByte(index) & 0xFF;
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
if (mask.test(this, mutable)) {
|
if (mask.test(mutable)) {
|
||||||
biomes.setByte(index, biomeByte);
|
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 z = 0; z < getLength(); z++) {
|
||||||
for (int x = 0; x < getWidth(); x++, index++) {
|
for (int x = 0; x < getWidth(); x++, index++) {
|
||||||
filter.init(x, z, index);
|
filter.init(x, z, index);
|
||||||
if (mask.test(this, filter)) {
|
if (mask.test(filter)) {
|
||||||
pattern.apply(this, filter, 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 z = 0; z < getLength(); z++) {
|
||||||
for (int x = 0; x < getWidth(); x++, index++) {
|
for (int x = 0; x < getWidth(); x++, index++) {
|
||||||
filter.init(x, z, index);
|
filter.init(x, z, index);
|
||||||
if (mask.test(this, filter)) {
|
if (mask.test(filter)) {
|
||||||
pattern.apply(this, filter, filter);
|
pattern.apply(this, filter, filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1542,7 +1542,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (int z = 0; z < getLength(); z++) {
|
for (int z = 0; z < getLength(); z++) {
|
||||||
for (int x = 0; x < getWidth(); x++, index++) {
|
for (int x = 0; x < getWidth(); x++, index++) {
|
||||||
if (mask.test(this, filter)) {
|
if (mask.test(filter)) {
|
||||||
pattern.apply(this, filter, 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++) {
|
for (int x = 0; x < getWidth(); x++, index++) {
|
||||||
floorFilter.init(x, z, index);
|
floorFilter.init(x, z, index);
|
||||||
mainFilter.init(x, z, index);
|
mainFilter.init(x, z, index);
|
||||||
if (mask.test(this, mainFilter)) {
|
if (mask.test(mainFilter)) {
|
||||||
pattern.apply(this, mainFilter, mainFilter);
|
pattern.apply(this, mainFilter, mainFilter);
|
||||||
}
|
}
|
||||||
if (mask.test(this, floorFilter)) {
|
if (mask.test(floorFilter)) {
|
||||||
pattern.apply(this, floorFilter, floorFilter);
|
pattern.apply(this, floorFilter, floorFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1887,7 +1887,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
int y = heights.getByte(index) & 0xFF;
|
int y = heights.getByte(index) & 0xFF;
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
if (mask.test(this, mutable)) {
|
if (mask.test(mutable)) {
|
||||||
overlay.setInt(index, combined);
|
overlay.setInt(index, combined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1902,7 +1902,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
int y = heights.getByte(index) & 0xFF;
|
int y = heights.getByte(index) & 0xFF;
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
if (mask.test(this, mutable)) {
|
if (mask.test(mutable)) {
|
||||||
floor.setInt(index, combined);
|
floor.setInt(index, combined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1918,7 +1918,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
int y = heights.getByte(index) & 0xFF;
|
int y = heights.getByte(index) & 0xFF;
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
if (mask.test(this, mutable)) {
|
if (mask.test(mutable)) {
|
||||||
main.setInt(index, combined);
|
main.setInt(index, combined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1934,7 +1934,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
int y = heights.getByte(index) & 0xFF;
|
int y = heights.getByte(index) & 0xFF;
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
if (mask.test(this, mutable)) {
|
if (mask.test(mutable)) {
|
||||||
floor.setInt(index, combined);
|
floor.setInt(index, combined);
|
||||||
main.setInt(index, combined);
|
main.setInt(index, combined);
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
public class SourceMaskExtent extends TemporalExtent {
|
public class SourceMaskExtent extends TemporalExtent {
|
||||||
private Mask mask;
|
private Mask mask;
|
||||||
private Extent get;
|
|
||||||
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
public SourceMaskExtent(Extent extent, Mask mask) {
|
public SourceMaskExtent(Extent extent, Mask mask) {
|
||||||
this(extent, extent, mask);
|
super(extent);
|
||||||
}
|
|
||||||
|
|
||||||
public SourceMaskExtent(Extent get, Extent set, Mask mask) {
|
|
||||||
super(set);
|
|
||||||
checkNotNull(get);
|
|
||||||
checkNotNull(mask);
|
checkNotNull(mask);
|
||||||
this.get = get;
|
|
||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +41,7 @@ public class SourceMaskExtent extends TemporalExtent {
|
|||||||
@Override
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||||
set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
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
|
@Override
|
||||||
@ -57,6 +50,6 @@ public class SourceMaskExtent extends TemporalExtent {
|
|||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
mutable.mutZ(z);
|
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;
|
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.AbstractMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||||
@ -25,20 +24,10 @@ public class AbstractDelegateMask extends AbstractMask {
|
|||||||
return mask.test(vector);
|
return mask.test(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(Extent extent, BlockVector3 pos) {
|
|
||||||
return mask.test(extent, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Mask2D toMask2D() {
|
public Mask2D toMask2D() {
|
||||||
return mask.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
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 v) {
|
public boolean test(BlockVector3 v) {
|
||||||
return direction(extent, v) != null;
|
return direction(v) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockVector3 direction(Extent extent, BlockVector3 v) {
|
public BlockVector3 direction(BlockVector3 v) {
|
||||||
int x = v.getBlockX();
|
int x = v.getBlockX();
|
||||||
int y = v.getBlockY();
|
int y = v.getBlockY();
|
||||||
int z = v.getBlockZ();
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
return mutable.setComponents(0, -1, 0);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
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.AbstractMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@ -20,41 +19,41 @@ public class AdjacentMask extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 bv) {
|
public boolean test(BlockVector3 bv) {
|
||||||
vector.setComponents(bv);
|
vector.setComponents(bv);
|
||||||
double x = bv.getX();
|
double x = bv.getX();
|
||||||
double y = bv.getY();
|
double y = bv.getY();
|
||||||
double z = bv.getZ();
|
double z = bv.getZ();
|
||||||
vector.mutX(x + 1);
|
vector.mutX(x + 1);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||||
vector.mutX(x);
|
vector.mutX(x);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
vector.mutX(x - 1);
|
vector.mutX(x - 1);
|
||||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||||
vector.mutX(x);
|
vector.mutX(x);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
vector.mutX(x);
|
vector.mutX(x);
|
||||||
vector.mutY(y + 1);
|
vector.mutY(y + 1);
|
||||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||||
vector.mutY(y);
|
vector.mutY(y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
vector.mutY(y - 1);
|
vector.mutY(y - 1);
|
||||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||||
vector.mutY(y);
|
vector.mutY(y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
vector.mutY(y);
|
vector.mutY(y);
|
||||||
vector.mutZ(z + 1);
|
vector.mutZ(z + 1);
|
||||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||||
vector.mutZ(z);
|
vector.mutZ(z);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
vector.mutZ(z - 1);
|
vector.mutZ(z - 1);
|
||||||
if (mask.test(extent, vector) && ++count == min && max >= 8) {
|
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||||
vector.mutZ(z);
|
vector.mutZ(z);
|
||||||
return true;
|
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 x = v.getBlockX();
|
||||||
int y = v.getBlockY();
|
int y = v.getBlockY();
|
||||||
int z = v.getBlockZ();
|
int z = v.getBlockZ();
|
||||||
if (!mask.test(extent, x + 1, y, z)) {
|
if (!mask.test(x + 1, y, z)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!mask.test(extent, x - 1, y, z)) {
|
if (!mask.test(x - 1, y, z)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!mask.test(extent, x, y, z + 1)) {
|
if (!mask.test(x, y, z + 1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!mask.test(extent, x, y, z - 1)) {
|
if (!mask.test(x, y, z - 1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (y < 255 && !mask.test(extent, x, y + 1, z)) {
|
if (y < 255 && !mask.test(x, y + 1, z)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (y > 0 && !mask.test(extent, x, y - 1, z)) {
|
if (y > 0 && !mask.test(x, y - 1, z)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
int x = vector.getBlockX();
|
int x = vector.getBlockX();
|
||||||
int y = vector.getBlockY();
|
int y = vector.getBlockY();
|
||||||
int z = vector.getBlockZ();
|
int z = vector.getBlockZ();
|
||||||
|
|
||||||
if ((lastX == (lastX = x) & lastZ == (lastZ = z))) {
|
if ((lastX == (lastX = x) & lastZ == (lastZ = z))) {
|
||||||
int height = getHeight(extent, x, y, z);
|
int height = getHeight(getExtent(), x, y, z);
|
||||||
if (y <= height) {
|
if (y <= height) {
|
||||||
return overlay ? (lastValue && y == height) : lastValue;
|
return overlay ? (lastValue && y == height) : lastValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mask.test(extent, x, y, z)) {
|
if (!mask.test(x, y, z)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (overlay) {
|
if (overlay) {
|
||||||
if (y < 255 && !adjacentAir(extent, vector)) {
|
if (y < 255 && !adjacentAir(vector)) {
|
||||||
return lastValue = false;
|
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.collection.LocalBlockVectorSet;
|
||||||
import com.boydti.fawe.object.function.mask.AbstractDelegateMask;
|
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.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
@ -42,21 +41,21 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return test(extent, vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
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 {
|
try {
|
||||||
boolean check = cache_checked.add(x, y, z);
|
boolean check = cache_checked.add(x, y, z);
|
||||||
if (!check) {
|
if (!check) {
|
||||||
return cache_results.contains(x, y, z);
|
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);
|
if (result) cache_results.add(x, y, z);
|
||||||
return result;
|
return result;
|
||||||
} catch (UnsupportedOperationException ignore) {
|
} catch (UnsupportedOperationException ignored) {
|
||||||
boolean result = getMask().test(extent, mutable.setComponents(x, y, z));
|
boolean result = getMask().test(mutable.setComponents(x, y, z));
|
||||||
if (y < 0 || y > 255) return result;
|
if (y < 0 || y > 255) return result;
|
||||||
resetCache();
|
resetCache();
|
||||||
cache_checked.setOffset(x, z);
|
cache_checked.setOffset(x, z);
|
||||||
|
@ -13,11 +13,11 @@ public class DataMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
private transient int data = -1;
|
private transient int data = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (data != -1) {
|
if (data != -1) {
|
||||||
return extent.getBlock(vector).getInternalPropertiesId() == data;
|
return getExtent().getBlock(vector).getInternalPropertiesId() == data;
|
||||||
} else {
|
} else {
|
||||||
data = extent.getBlock(vector).getInternalPropertiesId();
|
data = getExtent().getBlock(vector).getInternalPropertiesId();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,11 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (combined != -1) {
|
if (combined != -1) {
|
||||||
return extent.getBlock(vector).getInternalId() == combined;
|
return getExtent().getBlock(vector).getInternalId() == combined;
|
||||||
} else {
|
} else {
|
||||||
combined = extent.getBlock(vector).getInternalId();
|
combined = getExtent().getBlock(vector).getInternalId();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (id != -1) {
|
if (id != -1) {
|
||||||
return extent.getBlock(vector).getInternalBlockTypeId() == id;
|
return getExtent().getBlock(vector).getInternalBlockTypeId() == id;
|
||||||
} else {
|
} else {
|
||||||
id = extent.getBlock(vector).getInternalBlockTypeId();
|
id = getExtent().getBlock(vector).getInternalBlockTypeId();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class MaskedTargetBlock extends TargetBlock {
|
|||||||
Location lastBlock = null;
|
Location lastBlock = null;
|
||||||
while (getNextBlock() != null) {
|
while (getNextBlock() != null) {
|
||||||
Location current = getCurrentBlock();
|
Location current = getCurrentBlock();
|
||||||
if (!mask.test(world, current.toBlockPoint())) {
|
if (!mask.test(current.toBlockPoint())) {
|
||||||
if (searchForLastBlock) {
|
if (searchForLastBlock) {
|
||||||
lastBlock = current;
|
lastBlock = current;
|
||||||
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
|
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
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.AbstractMask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
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;
|
private transient int originX = Integer.MAX_VALUE, originY = Integer.MAX_VALUE, originZ = Integer.MAX_VALUE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case -1:
|
case -1:
|
||||||
originX = vector.getBlockX();
|
originX = vector.getBlockX();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
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.AbstractMask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ public class RadiusMask extends AbstractMask implements ResettableMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 to) {
|
public boolean test(BlockVector3 to) {
|
||||||
if (pos == null) {
|
if (pos == null) {
|
||||||
pos = to.toImmutable();
|
pos = to.toImmutable();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
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.AbstractMask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ public class RandomMask extends AbstractMask implements ResettableMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return random.nextInt() <= threshold;
|
return random.nextInt() <= threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
package com.boydti.fawe.object.mask;
|
||||||
|
|
||||||
import com.boydti.fawe.object.random.SimplexNoise;
|
import com.boydti.fawe.object.random.SimplexNoise;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ public class SimplexMask extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
double value = SimplexNoise.noise(vector.getBlockX() * scale, vector.getBlockY() * scale, vector.getBlockZ() * scale);
|
||||||
return value >= min && value <= max;
|
return value >= min && value <= max;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class SurfaceMask extends AdjacentAnyMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 v) {
|
public boolean test(BlockVector3 v) {
|
||||||
return !getParentMask().test(extent, v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(extent, v);
|
return !getParentMask().test(v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
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.AbstractMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@ -19,30 +18,30 @@ public class WallMask extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 bv) {
|
public boolean test(BlockVector3 bv) {
|
||||||
v.setComponents(bv);
|
v.setComponents(bv);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
double x = v.getX();
|
double x = v.getX();
|
||||||
double y = v.getY();
|
double y = v.getY();
|
||||||
double z = v.getZ();
|
double z = v.getZ();
|
||||||
v.mutX(x + 1);
|
v.mutX(x + 1);
|
||||||
if (mask.test(extent, v) && ++count == min && max >= 8) {
|
if (mask.test(v) && ++count == min && max >= 8) {
|
||||||
v.mutX(x);
|
v.mutX(x);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
v.mutX(x - 1);
|
v.mutX(x - 1);
|
||||||
if (mask.test(extent, v) && ++count == min && max >= 8) {
|
if (mask.test(v) && ++count == min && max >= 8) {
|
||||||
v.mutX(x);
|
v.mutX(x);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
v.mutX(x);
|
v.mutX(x);
|
||||||
v.mutZ(z + 1);
|
v.mutZ(z + 1);
|
||||||
if (mask.test(extent, v) && ++count == min && max >= 8) {
|
if (mask.test(v) && ++count == min && max >= 8) {
|
||||||
v.mutZ(z);
|
v.mutZ(z);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
v.mutZ(z - 1);
|
v.mutZ(z - 1);
|
||||||
if (mask.test(extent, v) && ++count == min && max >= 8) {
|
if (mask.test(v) && ++count == min && max >= 8) {
|
||||||
v.mutZ(z);
|
v.mutZ(z);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class MaskedPattern extends AbstractPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
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 primary.apply(extent, get, set);
|
||||||
}
|
}
|
||||||
return secondary.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) {
|
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());
|
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
|
||||||
return true;
|
return true;
|
||||||
}, 256);
|
}, 256);
|
||||||
|
@ -376,7 +376,7 @@ public class TextureUtil implements TextureHolder {
|
|||||||
for (int typeId : tu.getValidBlockIds()) {
|
for (int typeId : tu.getValidBlockIds()) {
|
||||||
BlockType block = BlockTypes.get(typeId);
|
BlockType block = BlockTypes.get(typeId);
|
||||||
extent.init(0, 0, 0, block.getDefaultState().toBaseBlock());
|
extent.init(0, 0, 0, block.getDefaultState().toBaseBlock());
|
||||||
if (mask.test(extent, extent)) {
|
if (mask.test(extent)) {
|
||||||
blocks.add(block);
|
blocks.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,13 +144,13 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link Extent} that handles history, {@link BlockBag}s, change limits,
|
* 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) {
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
||||||
for (int y = maxY; y >= minY; --y) {
|
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;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1135,7 +1135,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
if (direction.equals(BlockVector3.at(0, -1, 0))) {
|
if (direction.equals(BlockVector3.at(0, -1, 0))) {
|
||||||
return fillXZ(origin, pattern, radius, depth, false);
|
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
|
// Want to replace blocks
|
||||||
final BlockReplace replace = new BlockReplace(EditSession.this, pattern);
|
final BlockReplace replace = new BlockReplace(EditSession.this, pattern);
|
||||||
|
|
||||||
@ -1187,7 +1187,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
new BoundedHeightMask(
|
new BoundedHeightMask(
|
||||||
Math.max(origin.getBlockY() - depth + 1, getMinimumPoint().getBlockY()),
|
Math.max(origin.getBlockY() - depth + 1, getMinimumPoint().getBlockY()),
|
||||||
Math.min(getMaxY(), origin.getBlockY())),
|
Math.min(getMaxY(), origin.getBlockY())),
|
||||||
Masks.negate(new ExistingBlockMask(this))).withExtent(getExtent());
|
Masks.negate(new ExistingBlockMask(this)));
|
||||||
// Want to replace blocks
|
// Want to replace blocks
|
||||||
BlockReplace replace = new BlockReplace(this, pattern);
|
BlockReplace replace = new BlockReplace(this, pattern);
|
||||||
|
|
||||||
@ -1399,7 +1399,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
} else {
|
} else {
|
||||||
replaceBlocks(region, new Mask() {
|
replaceBlocks(region, new Mask() {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 position) {
|
public boolean test(BlockVector3 position) {
|
||||||
int x = position.getBlockX();
|
int x = position.getBlockX();
|
||||||
int z = position.getBlockZ();
|
int z = position.getBlockZ();
|
||||||
return !region.contains(x, z + 1) || !region.contains(x, z - 1) || !region
|
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(
|
Mask mask = new MaskIntersection(
|
||||||
new BoundedHeightMask(0, getWorld().getMaxY()),
|
new BoundedHeightMask(0, getWorld().getMaxY()),
|
||||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||||
liquidMask).withExtent(getExtent());
|
liquidMask);
|
||||||
BlockReplace replace;
|
BlockReplace replace;
|
||||||
if (waterlogged) {
|
if (waterlogged) {
|
||||||
replace = new BlockReplace(this, new WaterloggedRemover(this));
|
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
|
// Around the origin in a 3x3 block
|
||||||
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||||
if (mask.test(getExtent(), position)) {
|
if (mask.test(position)) {
|
||||||
visitor.visit(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 BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
||||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||||
blockMask
|
blockMask
|
||||||
).withExtent(getExtent());
|
);
|
||||||
BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
|
BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
|
||||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||||
|
|
||||||
// Around the origin in a 3x3 block
|
// Around the origin in a 3x3 block
|
||||||
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||||
if (liquidMask.test(getExtent(), position)) {
|
if (liquidMask.test(position)) {
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2890,7 +2890,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
final BlockVector3 current = iter.next();
|
final BlockVector3 current = iter.next();
|
||||||
iter.remove();
|
iter.remove();
|
||||||
if (mask.test(getExtent(), current)) {
|
if (mask.test(current)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!outside.add(current)) {
|
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.function.mask.MaskIntersection;
|
||||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -76,6 +78,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
|||||||
super(worldEdit, new BlocksMaskParser(worldEdit));
|
super(worldEdit, new BlocksMaskParser(worldEdit));
|
||||||
|
|
||||||
register(new ExistingMaskParser(worldEdit));
|
register(new ExistingMaskParser(worldEdit));
|
||||||
|
register(new AirMaskParser(worldEdit));
|
||||||
register(new SolidMaskParser(worldEdit));
|
register(new SolidMaskParser(worldEdit));
|
||||||
register(new LazyRegionMaskParser(worldEdit));
|
register(new LazyRegionMaskParser(worldEdit));
|
||||||
register(new RegionMaskParser(worldEdit));
|
register(new RegionMaskParser(worldEdit));
|
||||||
@ -84,11 +87,11 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
|||||||
register(new BlockStateMaskParser(worldEdit));
|
register(new BlockStateMaskParser(worldEdit));
|
||||||
register(new NegateMaskParser(worldEdit));
|
register(new NegateMaskParser(worldEdit));
|
||||||
register(new ExpressionMaskParser(worldEdit));
|
register(new ExpressionMaskParser(worldEdit));
|
||||||
|
|
||||||
register(new BlockCategoryMaskParser(worldEdit));
|
register(new BlockCategoryMaskParser(worldEdit));
|
||||||
register(new BiomeMaskParser(worldEdit));
|
register(new BiomeMaskParser(worldEdit));
|
||||||
// Mask Parsers from FAWE
|
// Mask Parsers from FAWE
|
||||||
register(new AdjacentMaskParser(worldEdit));
|
register(new AdjacentMaskParser(worldEdit));
|
||||||
register(new AirMaskParser(worldEdit));
|
|
||||||
register(new AngleMaskParser(worldEdit));
|
register(new AngleMaskParser(worldEdit));
|
||||||
register(new ExtremaMaskParser(worldEdit));
|
register(new ExtremaMaskParser(worldEdit));
|
||||||
register(new FalseMaskParser(worldEdit));
|
register(new FalseMaskParser(worldEdit));
|
||||||
@ -124,18 +127,23 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mask match = null;
|
||||||
for (InputParser<Mask> parser : getParsers()) {
|
for (InputParser<Mask> parser : getParsers()) {
|
||||||
Mask match = parser.parseFromInput(component, context);
|
match = parser.parseFromInput(component, context);
|
||||||
|
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (match == null) {
|
||||||
|
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(component)));
|
||||||
|
}
|
||||||
masks.add(match);
|
masks.add(match);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (masks.size()) {
|
switch (masks.size()) {
|
||||||
case 0:
|
case 0:
|
||||||
throw new NoMatchException("No match for '" + input + "'");
|
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||||
case 1:
|
case 1:
|
||||||
return masks.get(0).optimize();
|
return masks.get(0).optimize();
|
||||||
default:
|
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;
|
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||||
|
|
||||||
import com.boydti.fawe.function.mask.AirMask;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
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.Mask;
|
||||||
|
import com.sk89q.worldedit.function.mask.Masks;
|
||||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,7 +44,7 @@ public class AirMaskParser extends SimpleInputParser<Mask> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
|
||||||
return new AirMask(context.getExtent());
|
return Masks.negate(new ExistingBlockMask(context.requireExtent()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,6 @@ public class ZAxisMaskParser extends SimpleInputParser<Mask> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
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));
|
maxY = Math.min(maxY, Math.max(0, maxY));
|
||||||
minY = Math.max(0, minY);
|
minY = Math.max(0, minY);
|
||||||
for (int y = maxY; y >= minY; --y) {
|
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;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,22 +276,22 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
int clearanceAbove = maxY - y;
|
int clearanceAbove = maxY - y;
|
||||||
int clearanceBelow = y - minY;
|
int clearanceBelow = y - minY;
|
||||||
int clearance = Math.min(clearanceAbove, clearanceBelow);
|
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;
|
int offset = state ? 0 : 1;
|
||||||
for (int d = 0; d <= clearance; d++) {
|
for (int d = 0; d <= clearance; d++) {
|
||||||
int y1 = y + 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;
|
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) {
|
||||||
if (clearanceAbove < clearanceBelow) {
|
if (clearanceAbove < clearanceBelow) {
|
||||||
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
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 {
|
} else {
|
||||||
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
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
|
* @return the number of blocks that matched the mask
|
||||||
*/
|
*/
|
||||||
default int countBlocks(Region region, Mask searchMask) {
|
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);
|
Operations.completeBlindly(visitor);
|
||||||
return visitor.getAffected();
|
return visitor.getAffected();
|
||||||
}
|
}
|
||||||
|
@ -79,17 +79,17 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
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
|
@Override
|
||||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
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
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
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
|
@Override
|
||||||
@ -102,7 +102,7 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
|||||||
public void applyBlock(FilterBlock block) {
|
public void applyBlock(FilterBlock block) {
|
||||||
//TODO: Find a way to make masking thread safe without having to synchonise the whole extent
|
//TODO: Find a way to make masking thread safe without having to synchonise the whole extent
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (!mask.test(getExtent(), block)) {
|
if (!mask.test(block)) {
|
||||||
block.setOrdinal(0);
|
block.setOrdinal(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public class ExtentBuffer extends AbstractBufferingExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
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());
|
buffer.put(location, block.toBaseBlock());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
max = max.getMaximum(location);
|
max = max.getMaximum(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask.test(getExtent(), location)) {
|
if (mask.test( location)) {
|
||||||
buffer.put(location, block.toBaseBlock());
|
buffer.put(location, block.toBaseBlock());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -131,7 +131,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
max2d = max2d.getMaximum(position);
|
max2d = max2d.getMaximum(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biomeMask.test(getExtent(), position)) {
|
if (biomeMask.test(position)) {
|
||||||
biomeBuffer.put(position, biome);
|
biomeBuffer.put(position, biome);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -155,7 +155,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
max2d = max2d.getMaximum(BlockVector2.at(x,z));
|
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);
|
biomeBuffer.put(BlockVector2.at(x,z), biome);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.function;
|
package com.sk89q.worldedit.function;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.NullExtent;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ public class RegionMaskTestFunction implements RegionFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
if (mask.test(NullExtent.INSTANCE, position)) {
|
if (mask.test(position)) {
|
||||||
return pass.apply(position);
|
return pass.apply(position);
|
||||||
} else {
|
} else {
|
||||||
return fail.apply(position);
|
return fail.apply(position);
|
||||||
|
@ -54,7 +54,7 @@ public class RegionMaskingFilter implements RegionFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
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
|
@Override
|
||||||
public boolean isGround(BlockVector3 position) {
|
public boolean isGround(BlockVector3 position) {
|
||||||
return mask.test(editSession, position);
|
return mask.test(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockState getTargetBlock(int depth) {
|
private BlockState getTargetBlock(int depth) {
|
||||||
@ -95,7 +95,7 @@ public class Naturalizer implements LayerFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||||
if (mask.test(editSession, position)) {
|
if (mask.test(position)) {
|
||||||
if (naturalize(position, depth)) {
|
if (naturalize(position, depth)) {
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class OreGen implements Resource {
|
|||||||
@Override
|
@Override
|
||||||
public boolean spawn(Random rand, int x, int z) throws WorldEditException {
|
public boolean spawn(Random rand, int x, int z) throws WorldEditException {
|
||||||
int y = rand.nextInt(maxY - minY) + minY;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
double f = rand.nextDouble() * Math.PI;
|
double f = rand.nextDouble() * Math.PI;
|
||||||
@ -102,7 +102,7 @@ public class OreGen implements Resource {
|
|||||||
double dz = (zz + 0.5D - d9) * id11o2;
|
double dz = (zz + 0.5D - d9) * id11o2;
|
||||||
double dxyz2 = dxy2 + dz * dz;
|
double dxyz2 = dxy2 + dz * dz;
|
||||||
if ((dxyz2 < 1)) {
|
if ((dxyz2 < 1)) {
|
||||||
if (mask.test(extent, mutable))
|
if (mask.test(mutable))
|
||||||
pattern.apply(extent, mutable, 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);
|
int y = extent.getNearestSurfaceTerrainBlock(x, z, mutable.getBlockY(), 0, 255);
|
||||||
if (y == -1) return false;
|
if (y == -1) return false;
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
if (!mask.test(extent, mutable)) {
|
if (!mask.test(mutable)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mutable.mutY(y + 1);
|
mutable.mutY(y + 1);
|
||||||
|
@ -15,8 +15,8 @@ public abstract class ABlockMask extends AbstractExtentMask {
|
|||||||
super(extent);
|
super(extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean test(Extent extent, BlockVector3 vector) {
|
@Override public boolean test(BlockVector3 vector) {
|
||||||
return test(vector.getBlock(extent));
|
return test(getExtent().getBlock(vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean test(BlockState state);
|
public abstract boolean test(BlockState state);
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
@ -40,10 +39,6 @@ public abstract class AbstractExtentMask extends AbstractMask {
|
|||||||
setExtent(extent);
|
setExtent(extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(BlockVector3 vector) {
|
|
||||||
return test(getExtent(), vector);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the extent.
|
* Get the extent.
|
||||||
@ -64,9 +59,4 @@ public abstract class AbstractExtentMask extends AbstractMask {
|
|||||||
this.extent = extent;
|
this.extent = extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mask withExtent(Extent extent) {
|
|
||||||
setExtent(extent);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base class of {@link Mask} that all masks should inherit from.
|
* 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
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector2 vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
BiomeType biome = extent.getBiome(vector);
|
BiomeType biome = extent.getBiome(vector);
|
||||||
return biomes.contains(biome);
|
return biomes.contains(biome);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
*/
|
*/
|
||||||
public class BlockCategoryMask extends AbstractExtentMask {
|
public class BlockCategoryMask extends AbstractExtentMask {
|
||||||
|
|
||||||
private BlockCategory category;
|
private final BlockCategory category;
|
||||||
|
|
||||||
public BlockCategoryMask(Extent extent, BlockCategory category) {
|
public BlockCategoryMask(Extent extent, BlockCategory category) {
|
||||||
super(extent);
|
super(extent);
|
||||||
@ -42,8 +42,8 @@ public class BlockCategoryMask extends AbstractExtentMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return category.contains(vector.getBlock(extent));
|
return category.contains(getExtent().getBlock(vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -188,8 +188,8 @@ public class BlockMask extends ABlockMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
int test = vector.getOrdinal(extent);
|
int test = getExtent().getBlock(vector).getOrdinal();
|
||||||
return ordinals[test] || replacesAir() && test == 0;
|
return ordinals[test] || replacesAir() && test == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class BlockStateMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
private final Map<String, String> states;
|
private final Map<String, String> states;
|
||||||
private final boolean strict;
|
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.
|
* 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
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return test(vector.getBlock(extent));
|
return test(getExtent().getBlock(vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean test(BlockState block) {
|
public boolean test(BlockState block) {
|
||||||
|
@ -110,8 +110,8 @@ public class BlockTypeMask extends AbstractExtentMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return test(vector.getBlock(extent).getBlockType());
|
return test(getExtent().getBlock(vector).getBlockType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -48,7 +47,7 @@ public class BoundedHeightMask extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return vector.getY() >= minY && vector.getY() <= maxY;
|
return vector.getY() >= minY && vector.getY() <= maxY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,11 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.boydti.fawe.object.function.mask.AbstractDelegateMask;
|
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 {
|
public class DelegateExtentMask extends AbstractDelegateMask {
|
||||||
private final Extent extent;
|
|
||||||
|
|
||||||
public DelegateExtentMask(Extent extent, Mask parent) {
|
public DelegateExtentMask(Mask parent) {
|
||||||
super(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
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return !vector.getBlock(extent).getMaterial().isAir();
|
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
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.EvaluationException;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
@ -68,7 +67,7 @@ public class ExpressionMask extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
try {
|
try {
|
||||||
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
|
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
|
||||||
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
|
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
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.EvaluationException;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
@ -61,7 +60,7 @@ public class ExpressionMask2D extends AbstractMask2D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector2 vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
try {
|
try {
|
||||||
if (timeout == null) {
|
if (timeout == null) {
|
||||||
return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0;
|
return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -13,8 +12,8 @@ public class InverseMask extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 pos) {
|
public boolean test(BlockVector3 pos) {
|
||||||
return !mask.test(extent, pos);
|
return !mask.test(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -19,8 +19,8 @@ public class InverseSingleBlockStateMask extends ABlockMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
int test = vector.getOrdinal(extent);
|
int test = getExtent().getBlock(vector).getOrdinal();
|
||||||
if (isAir && test == 0) {
|
if (isAir && test == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
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.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -15,11 +14,6 @@ public class InverseSingleBlockTypeMask extends ABlockMask {
|
|||||||
this.internalId = type.getInternalId();
|
this.internalId = type.getInternalId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
|
||||||
return test(vector.getBlock(extent));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean test(BlockState state) {
|
public final boolean test(BlockState state) {
|
||||||
return state.getBlockType().getInternalId() != internalId;
|
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.Filter;
|
||||||
import com.boydti.fawe.beta.implementation.filter.MaskFilter;
|
import com.boydti.fawe.beta.implementation.filter.MaskFilter;
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
|
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.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -41,26 +38,12 @@ public interface Mask {
|
|||||||
* @param vector the vector to test
|
* @param vector the vector to test
|
||||||
* @return true if the criteria is met
|
* @return true if the criteria is met
|
||||||
*/
|
*/
|
||||||
default boolean test(BlockVector3 vector) {
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
default <T extends Filter> MaskFilter<T> toFilter(T filter) {
|
default <T extends Filter> MaskFilter<T> toFilter(T filter) {
|
||||||
return new MaskFilter<>(filter, this);
|
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.
|
* Get the 2D version of this mask if one exists.
|
||||||
*
|
*
|
||||||
@ -94,16 +77,6 @@ public interface Mask {
|
|||||||
return value == null ? this : value;
|
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() {
|
default Mask inverse() {
|
||||||
if (this instanceof Masks.AlwaysTrue) {
|
if (this instanceof Masks.AlwaysTrue) {
|
||||||
return Masks.ALWAYS_FALSE;
|
return Masks.ALWAYS_FALSE;
|
||||||
@ -117,7 +90,7 @@ public interface Mask {
|
|||||||
return new Filter() {
|
return new Filter() {
|
||||||
@Override
|
@Override
|
||||||
public void applyBlock(FilterBlock block) {
|
public void applyBlock(FilterBlock block) {
|
||||||
if (test(block, block)) {
|
if (test(block)) {
|
||||||
run.accept(block);
|
run.accept(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
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.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether a given vector meets a criteria.
|
* Tests whether a given vector meets a criteria.
|
||||||
@ -35,16 +32,6 @@ public interface Mask2D {
|
|||||||
* @param vector the vector to test
|
* @param vector the vector to test
|
||||||
* @return true if the criteria is met
|
* @return true if the criteria is met
|
||||||
*/
|
*/
|
||||||
default boolean test(BlockVector2 vector) {
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
@ -226,9 +225,9 @@ public class MaskIntersection extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
for (Mask mask : masksArray) {
|
for (Mask mask : masksArray) {
|
||||||
if (!mask.test(extent, vector)) {
|
if (!mask.test( vector)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -84,13 +83,13 @@ public class MaskIntersection2D implements Mask2D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector2 vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
if (masks.isEmpty()) {
|
if (masks.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Mask2D mask : masks) {
|
for (Mask2D mask : masks) {
|
||||||
if (!mask.test(extent, vector)) {
|
if (!mask.test(vector)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -86,11 +85,11 @@ public class MaskUnion extends MaskIntersection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
Mask[] masks = getMasksArray();
|
Mask[] masks = getMasksArray();
|
||||||
|
|
||||||
for (Mask mask : masks) {
|
for (Mask mask : masks) {
|
||||||
if (mask.test(extent, vector)) {
|
if (mask.test(vector)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -48,11 +47,11 @@ public class MaskUnion2D extends MaskIntersection2D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector2 vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
Collection<Mask2D> masks = getMasks();
|
Collection<Mask2D> masks = getMasks();
|
||||||
|
|
||||||
for (Mask2D mask : masks) {
|
for (Mask2D mask : masks) {
|
||||||
if (mask.test(extent, vector)) {
|
if (mask.test(vector)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
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
|
* @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
|
* @return a mask
|
||||||
*/
|
*/
|
||||||
@ -90,8 +89,8 @@ public final class Masks {
|
|||||||
checkNotNull(mask);
|
checkNotNull(mask);
|
||||||
return new AbstractMask2D() {
|
return new AbstractMask2D() {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector2 vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
return !mask.test(extent, vector);
|
return !mask.test(vector);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -105,8 +104,8 @@ public final class Masks {
|
|||||||
public static Mask asMask(final Mask2D mask) {
|
public static Mask asMask(final Mask2D mask) {
|
||||||
return new AbstractMask() {
|
return new AbstractMask() {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return mask.test(extent, vector.toBlockVector2());
|
return mask.test(vector.toBlockVector2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -119,12 +118,12 @@ public final class Masks {
|
|||||||
|
|
||||||
protected static class AlwaysTrue implements Mask, Mask2D {
|
protected static class AlwaysTrue implements Mask, Mask2D {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector2 vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,20 +143,16 @@ public final class Masks {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mask withExtent(Extent extent) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class AlwaysFalse implements Mask, Mask2D {
|
protected static class AlwaysFalse implements Mask, Mask2D {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector2 vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,10 +172,6 @@ public final class Masks {
|
|||||||
return other;
|
return other;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mask withExtent(Extent extent) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableVector3;
|
import com.sk89q.worldedit.math.MutableVector3;
|
||||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||||
@ -87,7 +86,7 @@ public class NoiseFilter extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
return noiseGenerator.noise(MutableVector3.get(vector.getX(), vector.getY(), vector.getZ())) <= density;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||||
|
|
||||||
@ -84,7 +83,7 @@ public class NoiseFilter2D extends AbstractMask2D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector2 pos) {
|
public boolean test(BlockVector2 pos) {
|
||||||
return noiseGenerator.noise(pos.toVector2()) <= density;
|
return noiseGenerator.noise(pos.toVector2()) <= density;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -87,12 +86,12 @@ public class OffsetMask extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 pos) {
|
public boolean test(BlockVector3 vector) {
|
||||||
BlockVector3 testPos = pos.add(offset);
|
BlockVector3 testPos = vector.add(offset);
|
||||||
if (testPos.getBlockY() < 0 || testPos.getBlockY() > 255) {
|
if (testPos.getBlockY() < 0 || testPos.getBlockY() > 255) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return getMask().test(extent, pos.add(offset));
|
return getMask().test(vector.add(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||||
|
|
||||||
@ -88,9 +87,9 @@ public class OffsetMask2D extends AbstractMask2D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector2 vector) {
|
public boolean test(BlockVector2 vector) {
|
||||||
mutable.setComponents(vector.getX() + offset.getX(), vector.getZ() + offset.getZ());
|
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;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ public class RegionMask extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return region.contains(vector);
|
return region.contains(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ public class SingleBlockStateMask extends ABlockMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(Extent extent, BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
int test = vector.getOrdinal(extent);
|
int test = getExtent().getBlock(vector).getOrdinal();
|
||||||
return ordinal == test || isAir && test == 0;
|
return ordinal == test || isAir && test == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public class SnapshotRestore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndAddBlock(BlockVector3 pos) {
|
private void checkAndAddBlock(BlockVector3 pos) {
|
||||||
if (editSession.getMask() != null && !editSession.getMask().test(editSession, pos))
|
if (editSession.getMask() != null && !editSession.getMask().test(pos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockVector2 chunkPos = ChunkStore.toChunk(pos);
|
BlockVector2 chunkPos = ChunkStore.toChunk(pos);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren