Make masks more stateless

Dieser Commit ist enthalten in:
Jesse Boyd 2020-01-04 10:11:13 +00:00
Ursprung 9efdd886c5
Commit 88a95221a8
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
98 geänderte Dateien mit 617 neuen und 468 gelöschten Zeilen

Datei anzeigen

@ -319,7 +319,6 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial(); BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
return material.getCraftBlockData(); return material.getCraftBlockData();
} catch (ClassCastException ignore) { } catch (ClassCastException ignore) {
System.out.println(state.getAsString() + " cast");
throw ignore; throw ignore;
} }
} }

Datei anzeigen

@ -16,11 +16,8 @@ public abstract class AbstractFilterBlock extends FilterBlock {
public abstract BaseBlock getFullBlock(); public abstract BaseBlock getFullBlock();
public abstract void setFullBlock(BaseBlock block); public abstract void setFullBlock(BaseBlock block);
public abstract BlockVector3 getPosition(); public abstract BlockVector3 getPosition();
@Override @Override
public Extent getExtent() { public abstract Extent getExtent();
return this;
}
@Override @Override
public int getX() { public int getX() {

Datei anzeigen

@ -19,9 +19,7 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
private final int yOffset; private final int yOffset;
private final int width, length; private final int width, length;
private int x, z, index; private int x, z, index;
private char ordinal;
// TODO use in CFI
public ArrayFilterBlock(Extent extent, char[] blocks, byte[] heights, int width, int length, public ArrayFilterBlock(Extent extent, char[] blocks, byte[] heights, int width, int length,
int yOffset) { int yOffset) {
super(extent); super(extent);
@ -32,18 +30,16 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
this.yOffset = yOffset; this.yOffset = yOffset;
} }
public void filter2D(Filter filter) { public void init(int x, int z, int index) {
for (z = 0; z < length; z++) { this.x = x;
for (x = 0; x < width; x++, index++) { this.z = z;
ordinal = blocks[ordinal]; this.index = index;
filter.applyBlock(this);
}
}
} }
@Override @Override
public int getOrdinal() { public int getOrdinal() {
return ordinal; return blocks[index];
} }
@Override @Override
@ -53,7 +49,7 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock {
@Override @Override
public BlockState getBlock() { public BlockState getBlock() {
return BlockTypesCache.states[ordinal]; return BlockTypesCache.states[getOrdinal()];
} }
@Override @Override

Datei anzeigen

@ -32,4 +32,9 @@ public class ExtentFilterBlock extends AbstractFilterBlock {
public BlockVector3 getPosition() { public BlockVector3 getPosition() {
return pos; return pos;
} }
@Override
public Extent getExtent() {
return extent;
}
} }

Datei anzeigen

@ -0,0 +1,39 @@
package com.boydti.fawe.beta.implementation.filter.block;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import javax.annotation.Nullable;
public class MultiFilterBlock extends DelegateFilterBlock {
private final FilterBlock[] blocks;
private final int length;
public MultiFilterBlock(FilterBlock... blocks) {
super(blocks[0]);
this.blocks = blocks;
this.length = blocks.length;
}
@Override
public void setOrdinal(int ordinal) {
for (int i = 0; i < length; i++) blocks[i].setOrdinal(ordinal);
}
@Override
public void setBlock(BlockState state) {
for (int i = 0; i < length; i++) blocks[i].setBlock(state);
}
@Override
public void setFullBlock(BaseBlock block) {
for (int i = 0; i < length; i++) blocks[i].setFullBlock(block);
}
@Override
public void setNbtData(@Nullable CompoundTag nbtData) {
for (int i = 0; i < length; i++) blocks[i].setNbtData(nbtData);
}
}

Datei anzeigen

@ -1,32 +0,0 @@
package com.boydti.fawe.beta.implementation.filter.block;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
public class VectorSingleFilterBlock extends AbstractSingleFilterBlock {
private final BlockVector3 mutable;
public VectorSingleFilterBlock(BlockVector3 mutable) {
this.mutable = mutable;
}
public VectorSingleFilterBlock init(BaseBlock block) {
super.init(block);
return this;
}
@Override
public int getX() {
return mutable.getX();
}
@Override
public int getY() {
return mutable.getY();
}
@Override
public int getZ() {
return mutable.getZ();
}
}

Datei anzeigen

@ -456,7 +456,7 @@ public class CFICommands {
for (int typeId : tu.getValidBlockIds()) { for (int typeId : tu.getValidBlockIds()) {
BlockType type = BlockTypes.get(typeId); BlockType type = BlockTypes.get(typeId);
extent.init(0, 0, 0, type.getDefaultState().toBaseBlock()); extent.init(0, 0, 0, type.getDefaultState().toBaseBlock());
if (mask.test(extent)) { if (mask.test(extent, extent)) {
blocks.add(type); blocks.add(type);
} }
} }

Datei anzeigen

@ -1,6 +1,8 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.Caption; import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.DelegateExtentMask;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
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;
@ -64,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 AbstractDelegateMask(mask) { mask = new DelegateExtentMask(editSession, mask) {
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (super.test(vector) && vector.getBlockY() >= minY) { if (super.test(extent, vector) && vector.getBlockY() >= minY) {
BaseBlock block = editSession.getFullBlock(vector); BaseBlock block = vector.getFullBlock(editSession);
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;
@ -78,7 +80,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
} }
}; };
// Add origin // Add origin
mask.test(position); mask.test(editSession, 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);

Datei anzeigen

@ -8,6 +8,7 @@ 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.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
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;
@ -86,11 +87,11 @@ public class ImageBrush implements Brush {
float pitch = loc.getPitch(); float pitch = loc.getPitch();
AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX((pitch - 90) % 360).inverse(); AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX((pitch - 90) % 360).inverse();
RecursiveVisitor visitor = new RecursiveVisitor(new Mask() { RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
private final MutableVector3 mutable = new MutableVector3(); private final MutableVector3 mutable = new MutableVector3();
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (solid.test(vector)) { if (solid.test(extent, 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;

Datei anzeigen

@ -6,7 +6,10 @@ 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.BlockMask; import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.mask.SolidBlockMask;
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;
@ -34,34 +37,42 @@ public class LayerBrush implements Brush {
final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR)); final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR));
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);
visitor = new RecursiveVisitor(vector -> solid.test(vector) && radius.test(vector) && adjacent.test(vector), function -> true); visitor = new RecursiveVisitor(new Mask() {
@Override
public boolean test(Extent extent, BlockVector3 vector) {
return solid.test(extent, vector) && radius.test(extent, vector) && adjacent.test(extent, vector);
}
}, 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);
BlockVectorSet visited = visitor.getVisited(); BlockVectorSet visited = visitor.getVisited();
visitor = new RecursiveVisitor(pos -> { visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
int depth = visitor.getDepth() + 1; @Override
if (depth > 1) { public boolean test(Extent extent, BlockVector3 pos) {
boolean found = false; int depth = visitor.getDepth() + 1;
BlockState previous = layers[depth - 1]; if (depth > 1) {
BlockState previous2 = layers[depth - 2]; boolean found = false;
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) { BlockState previous = layers[depth - 1];
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ()); BlockState previous2 = layers[depth - 2];
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) { for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2); mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) { if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
found = true; mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2);
break; if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
} else { found = true;
return false; break;
} else {
return false;
}
} }
} }
if (!found) {
return false;
}
} }
if (!found) { return !adjacent.test(extent, pos);
return false;
}
} }
return !adjacent.test(pos);
}, pos -> { }, pos -> {
int depth = visitor.getDepth(); int depth = visitor.getDepth();
BlockStateHolder currentPattern = layers[depth]; BlockStateHolder currentPattern = layers[depth];

Datei anzeigen

@ -6,6 +6,7 @@ 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.function.block.BlockReplace; import com.sk89q.worldedit.function.block.BlockReplace;
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.Operations; import com.sk89q.worldedit.function.operation.Operations;
@ -27,6 +28,8 @@ 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;
BlockStateHolder block = editSession.getBlock(position); BlockStateHolder block = editSession.getBlock(position);
@ -42,7 +45,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(to) && super.isVisitable(from, to); return y < maxY && radMask.test(editSession, to) && super.isVisitable(from, to);
} }
}; };
visitor.visit(position); visitor.visit(position);

Datei anzeigen

@ -8,7 +8,11 @@ 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.AbstractExtentMask;
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.MaskUnion;
import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.mask.Masks;
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;
@ -50,7 +54,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(vector -> radius.test(vector) && surface.test(vector), function -> true); RecursiveVisitor visitor = new RecursiveVisitor(new MaskUnion(radius, surface).withExtent(editSession), 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);
@ -87,11 +91,11 @@ public class ScatterBrush implements Brush {
} }
public boolean canApply(EditSession editSession, BlockVector3 pos) { public boolean canApply(EditSession editSession, BlockVector3 pos) {
return mask.test(pos); return mask.test(editSession, pos);
} }
public BlockVector3 getDirection(BlockVector3 pt) { public BlockVector3 getDirection(Extent extent, BlockVector3 pt) {
return surface.direction(pt); return surface.direction(extent, 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 {

Datei anzeigen

@ -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(pt); BlockVector3 dir = getDirection(editSession, 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);
} }
} }

Datei anzeigen

@ -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(bv) && finalMask.test(bv)) { if (surfaceTest.test(editSession, bv) && finalMask.test(editSession, 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)) {

Datei anzeigen

@ -5,6 +5,9 @@ import com.boydti.fawe.object.mask.SurfaceMask;
import com.boydti.fawe.object.pattern.BiomePattern; import com.boydti.fawe.object.pattern.BiomePattern;
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.Mask;
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;
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch; import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
@ -40,14 +43,17 @@ public class SplatterBrush extends ScatterBrush {
final int size2 = (int) (size * size); final int size2 = (int) (size * size);
SurfaceMask surface = new SurfaceMask(editSession); SurfaceMask surface = new SurfaceMask(editSession);
RecursiveVisitor visitor = new RecursiveVisitor(vector -> { RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
double dist = vector.distanceSq(position); @Override
if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2 public boolean test(Extent extent, BlockVector3 vector) {
&& surface.test(vector)) { double dist = vector.distanceSq(position);
placed.add(vector); if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2
return true; && surface.test(extent, vector)) {
placed.add(vector);
return true;
}
return false;
} }
return false;
}, vector -> editSession.setBlock(vector, finalPattern), recursion); }, vector -> editSession.setBlock(vector, finalPattern), recursion);
visitor.setMaxBranch(2); visitor.setMaxBranch(2);
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));

Datei anzeigen

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.sk89q.worldedit.function.mask.DelegateExtentMask;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.object.mask.IdMask; import com.boydti.fawe.object.mask.IdMask;
@ -52,6 +53,7 @@ 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;

Datei anzeigen

@ -5,7 +5,9 @@ import com.boydti.fawe.object.mask.AdjacentAnyMask;
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.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.mask.SolidBlockMask; import com.sk89q.worldedit.function.mask.SolidBlockMask;
@ -61,10 +63,10 @@ public class StencilBrush extends HeightBrush {
AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX(pitch - 90).inverse(); AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX(pitch - 90).inverse();
RecursiveVisitor visitor = new RecursiveVisitor(new Mask() { RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) {
private final MutableVector3 mutable = new MutableVector3(); private final MutableVector3 mutable = new MutableVector3();
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, 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;

Datei anzeigen

@ -5,6 +5,8 @@ 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.function.mask.DelegateExtentMask;
import com.sk89q.worldedit.function.mask.MaskUnion;
import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.mask.SolidBlockMask;
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;
@ -20,7 +22,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(vector -> surface.test(vector) && radius.test(vector), vector -> editSession.setBlock(vector, pattern)); RecursiveVisitor visitor = new RecursiveVisitor(new MaskUnion(surface, radius).withExtent(editSession), 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);

Datei anzeigen

@ -7,6 +7,10 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.filter.block.AbstractFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.ArrayFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.MultiFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.beta.implementation.blocks.FallbackChunkGet; import com.boydti.fawe.beta.implementation.blocks.FallbackChunkGet;
import com.boydti.fawe.jnbt.anvil.MCAChunk; import com.boydti.fawe.jnbt.anvil.MCAChunk;
@ -34,6 +38,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
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.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
@ -54,6 +59,7 @@ import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -552,7 +558,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(mutable)) { if (mask.test(this, mutable)) {
int newHeight = table.average(x, z, index); int newHeight = table.average(x, z, index);
setLayerHeightRaw(index, newHeight); setLayerHeightRaw(index, newHeight);
} }
@ -607,7 +613,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
mutable.mutX(x); mutable.mutX(x);
mutable.mutY(y); mutable.mutY(y);
if (!mask.test(mutable)) { if (!mask.test(this, mutable)) {
continue; continue;
} }
if (placed.containsRadius(x, z, distance)) { if (placed.containsRadius(x, z, distance)) {
@ -654,7 +660,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
mutable.mutX(x); mutable.mutX(x);
mutable.mutY(y); mutable.mutY(y);
if (!mask.test(mutable)) { if (!mask.test(this, mutable)) {
continue; continue;
} }
if (placed.containsRadius(x, z, distance)) { if (placed.containsRadius(x, z, distance)) {
@ -1066,7 +1072,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(mutable)) continue; if (!mask.test(this, mutable)) continue;
} }
if (imgMask != null) { if (imgMask != null) {
int height = imgMask.getRGB(x, z) & 0xFF; int height = imgMask.getRGB(x, z) & 0xFF;
@ -1181,7 +1187,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(mutable)) { if (mask.test(this, 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) {
@ -1254,7 +1260,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(mutable)) { if (mask.test(this, mutable)) {
biomes.setByte(index, biomeByte); biomes.setByte(index, biomeByte);
} }
} }
@ -1274,17 +1280,15 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
overlay.record(() -> { overlay.record(() -> {
char[] overlayArr = overlay.get(); ArrayFilterBlock filter = new ArrayFilterBlock(this, overlay.get(), heights.get(), getWidth(), getLength(), 1);
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) { for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF; int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current() if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) { .nextInt(256) <= height) {
mutable.mutX(x); filter.init(x, z, index);
mutable.mutY(height); pattern.apply(this, filter, filter);
overlayArr[index] = pattern.apply(mutable).getOrdinalChar();
} }
} }
} }
@ -1302,17 +1306,15 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
primitives.modifiedMain = true; primitives.modifiedMain = true;
main.record(() -> { main.record(() -> {
char[] mainArr = main.get(); ArrayFilterBlock filter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) { for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF; int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current() if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) { .nextInt(256) <= height) {
mutable.mutX(x); filter.init(x, z, index);
mutable.mutY(height); pattern.apply(this, filter, filter);
mainArr[index] = pattern.apply(mutable).getOrdinalChar();
} }
} }
} }
@ -1328,17 +1330,15 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
floor.record(() -> { floor.record(() -> {
char[] floorArr = floor.get(); ArrayFilterBlock filter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 1);
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) { for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF; int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current() if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) { .nextInt(256) <= height) {
mutable.mutX(x); filter.init(x, z, index);
mutable.mutY(height); pattern.apply(this, filter, filter);
floorArr[index] = pattern.apply(mutable).getOrdinalChar();
} }
} }
} }
@ -1355,20 +1355,20 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
primitives.modifiedMain = true; primitives.modifiedMain = true;
main.record(() -> floor.record(() -> { main.record(() -> floor.record(() -> {
char[] floorArr = floor.get(); ArrayFilterBlock filterFloor = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
char[] mainArr = main.get(); ArrayFilterBlock filterMain = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) { for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF; int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current() if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) { .nextInt(256) <= height) {
mutable.mutX(x); filterFloor.init(x, z, index);
mutable.mutY(height); filterMain.init(x, z, index);
char combined = pattern.apply(mutable).getOrdinalChar();
mainArr[index] = combined; pattern.apply(this, filterFloor, filterFloor);
floorArr[index] = combined; pattern.apply(this, filterMain, filterMain);
} }
} }
} }
@ -1380,19 +1380,20 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) { if (pattern instanceof BlockStateHolder) {
setOverlay(mask, ((BlockStateHolder) pattern).getOrdinalChar()); setOverlay(mask, ((BlockStateHolder) pattern).getOrdinalChar());
} else { } else {
int index = 0;
if (overlay == null) overlay = new DifferentialArray<>(new char[getArea()]); if (overlay == null) overlay = new DifferentialArray<>(new char[getArea()]);
for (int z = 0; z < getLength(); z++) { overlay.record(() -> {
mutable.mutZ(z); ArrayFilterBlock filter = new ArrayFilterBlock(this, overlay.get(), heights.get(), getWidth(), getLength(), 1);
for (int x = 0; x < getWidth(); x++, index++) { int index = 0;
int y = heights.getByte(index) & 0xFF; for (int z = 0; z < getLength(); z++) {
mutable.mutX(x); for (int x = 0; x < getWidth(); x++, index++) {
mutable.mutY(y); filter.init(x, z, index);
if (mask.test(mutable)) { if (mask.test(this, filter)) {
overlay.setInt(index, pattern.apply(mutable).getOrdinalChar()); pattern.apply(this, filter, filter);
}
} }
} }
} });
} }
} }
@ -1400,18 +1401,18 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) { if (pattern instanceof BlockStateHolder) {
setFloor(mask, ((BlockStateHolder) pattern).getOrdinalChar()); setFloor(mask, ((BlockStateHolder) pattern).getOrdinalChar());
} else { } else {
int index = 0; floor.record(() -> {
for (int z = 0; z < getLength(); z++) { ArrayFilterBlock filter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
mutable.mutZ(z); int index = 0;
for (int x = 0; x < getWidth(); x++, index++) { for (int z = 0; z < getLength(); z++) {
int y = heights.getByte(index) & 0xFF; for (int x = 0; x < getWidth(); x++, index++) {
mutable.mutX(x); filter.init(x, z, index);
mutable.mutY(y); if (mask.test(this, filter)) {
if (mask.test(mutable)) { pattern.apply(this, filter, filter);
floor.setInt(index, pattern.apply(mutable).getOrdinalChar()); }
} }
} }
} });
} }
} }
@ -1419,19 +1420,18 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) { if (pattern instanceof BlockStateHolder) {
setMain(mask, ((BlockStateHolder) pattern).getOrdinalChar()); setMain(mask, ((BlockStateHolder) pattern).getOrdinalChar());
} else { } else {
primitives.modifiedMain = true; main.record(() -> {
int index = 0; ArrayFilterBlock filter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
for (int z = 0; z < getLength(); z++) { primitives.modifiedMain = true;
mutable.mutZ(z); int index = 0;
for (int x = 0; x < getWidth(); x++, index++) { for (int z = 0; z < getLength(); z++) {
int y = heights.getByte(index) & 0xFF; for (int x = 0; x < getWidth(); x++, index++) {
mutable.mutX(x); if (mask.test(this, filter)) {
mutable.mutY(y); pattern.apply(this, filter, filter);
if (mask.test(mutable)) { }
main.setInt(index, pattern.apply(mutable).getOrdinalChar());
} }
} }
} });
} }
} }
@ -1439,21 +1439,25 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) { if (pattern instanceof BlockStateHolder) {
setColumn(mask, ((BlockStateHolder) pattern).getOrdinalChar()); setColumn(mask, ((BlockStateHolder) pattern).getOrdinalChar());
} else { } else {
primitives.modifiedMain = true; floor.record(() -> main.record(() -> {
int index = 0; ArrayFilterBlock floorFilter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
for (int z = 0; z < getLength(); z++) { ArrayFilterBlock mainFilter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
mutable.mutZ(z); primitives.modifiedMain = true;
for (int x = 0; x < getWidth(); x++, index++) { int index = 0;
int y = heights.getByte(index) & 0xFF; for (int z = 0; z < getLength(); z++) {
mutable.mutX(x); for (int x = 0; x < getWidth(); x++, index++) {
mutable.mutY(y); floorFilter.init(x, z, index);
if (mask.test(mutable)) { mainFilter.init(x, z, index);
int combined = pattern.apply(mutable).getOrdinalChar(); if (mask.test(this, mainFilter)) {
floor.setInt(index, combined); pattern.apply(this, mainFilter, mainFilter);
main.setInt(index, combined); }
if (mask.test(this, floorFilter)) {
pattern.apply(this, floorFilter, floorFilter);
}
} }
} }
} }));
} }
} }
@ -1466,15 +1470,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setFloor(((BlockStateHolder) value).getOrdinalChar()); setFloor(((BlockStateHolder) value).getOrdinalChar());
} else { } else {
floor.record(() -> { floor.record(() -> {
char[] floorArr = floor.get(); ArrayFilterBlock filter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) { for (int x = 0; x < getWidth(); x++, index++) {
int y = heights.getByte(index) & 0xFF; filter.init(x, z, index);
mutable.mutX(x); value.apply(this, filter, filter);
mutable.mutY(y);
floorArr[index] = value.apply(mutable).getOrdinalChar();
} }
} }
}); });
@ -1486,18 +1487,15 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setColumn(((BlockStateHolder) value).getOrdinalChar()); setColumn(((BlockStateHolder) value).getOrdinalChar());
} else { } else {
main.record(() -> floor.record(() -> { main.record(() -> floor.record(() -> {
char[] floorArr = floor.get(); ArrayFilterBlock floorFilter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
char[] mainArr = main.get(); ArrayFilterBlock mainFilter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) { for (int x = 0; x < getWidth(); x++, index++) {
int y = heights.getByte(index) & 0xFF; floorFilter.init(x, z, index);
mutable.mutX(x); mainFilter.init(x, z, index);
mutable.mutY(y); value.apply(this, floorFilter, floorFilter);
char combined = value.apply(mutable).getOrdinalChar(); value.apply(this, mainFilter, mainFilter);
mainArr[index] = combined;
floorArr[index] = combined;
} }
} }
})); }));
@ -1509,15 +1507,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setMain(((BlockStateHolder) value).getOrdinalChar()); setMain(((BlockStateHolder) value).getOrdinalChar());
} else { } else {
main.record(() -> { main.record(() -> {
char[] mainArr = main.get(); ArrayFilterBlock filter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) { for (int x = 0; x < getWidth(); x++, index++) {
int y = heights.getByte(index) & 0xFF; filter.init(x, z, index);
mutable.mutX(x); value.apply(this, filter, filter);
mutable.mutY(y);
mainArr[index] = value.apply(mutable).getOrdinalChar();
} }
} }
}); });
@ -1530,15 +1525,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setOverlay(((BlockStateHolder) value).getOrdinalChar()); setOverlay(((BlockStateHolder) value).getOrdinalChar());
} else { } else {
overlay.record(() -> { overlay.record(() -> {
char[] overlayArr = overlay.get(); ArrayFilterBlock filter = new ArrayFilterBlock(this, overlay.get(), heights.get(), getWidth(), getLength(), 1);
int index = 0; int index = 0;
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) { for (int x = 0; x < getWidth(); x++, index++) {
int y = heights.getByte(index) & 0xFF; filter.init(x, z, index);
mutable.mutX(x); value.apply(this, filter, filter);
mutable.mutY(y);
overlayArr[index] = value.apply(mutable).getOrdinalChar();
} }
} }
}); });
@ -1758,7 +1750,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(mutable)) { if (mask.test(this, mutable)) {
overlay.setInt(index, combined); overlay.setInt(index, combined);
} }
} }
@ -1773,7 +1765,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(mutable)) { if (mask.test(this, mutable)) {
floor.setInt(index, combined); floor.setInt(index, combined);
} }
} }
@ -1789,7 +1781,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(mutable)) { if (mask.test(this, mutable)) {
main.setInt(index, combined); main.setInt(index, combined);
} }
} }
@ -1805,7 +1797,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(mutable)) { if (mask.test(this, mutable)) {
floor.setInt(index, combined); floor.setInt(index, combined);
main.setInt(index, combined); main.setInt(index, combined);
} }

Datei anzeigen

@ -4,6 +4,7 @@ import com.boydti.fawe.beta.implementation.filter.block.AbstractFilterBlock;
import com.boydti.fawe.jnbt.streamer.IntValueReader; import com.boydti.fawe.jnbt.streamer.IntValueReader;
import com.google.common.collect.ForwardingIterator; import com.google.common.collect.ForwardingIterator;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
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.visitor.Order; import com.sk89q.worldedit.function.visitor.Order;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -111,5 +112,10 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
public BlockVector3 getPosition() { public BlockVector3 getPosition() {
return position; return position;
} }
@Override
public Extent getExtent() {
return LinearClipboard.this;
}
} }
} }

Datei anzeigen

@ -294,14 +294,14 @@ public final class DifferentialArray<T> implements DifferentialCollection<T> {
dataInts[index] = value; dataInts[index] = value;
} }
// public void setChar(int index, char value) { public void setChar(int index, char value) {
// changed = true; changed = true;
// try { try {
// changesChars[index] += dataChars[index] - value; changesChars[index] += dataChars[index] - value;
// } catch (NullPointerException ignore) { } catch (NullPointerException ignore) {
// changes = (T) (changesChars = new char[dataChars.length]); changes = (T) (changesChars = new char[dataChars.length]);
// changesChars[index] += dataChars[index] - value; changesChars[index] += dataChars[index] - value;
// } }
// dataChars[index] = value; dataChars[index] = value;
// } }
} }

Datei anzeigen

@ -11,8 +11,20 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
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) {
this(extent, extent, mask);
}
public SourceMaskExtent(Extent get, Extent set, Mask mask) {
super(set);
checkNotNull(get);
checkNotNull(mask);
this.get = get;
this.mask = mask;
}
/** /**
* Get the mask. * Get the mask.
@ -33,16 +45,10 @@ public class SourceMaskExtent extends TemporalExtent {
this.mask = mask; this.mask = mask;
} }
public SourceMaskExtent(Extent extent, Mask mask) {
super(extent);
checkNotNull(mask);
this.mask = mask;
}
@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(location) && super.setBlock(location, block); return mask.test(get, location) && super.setBlock(location, block);
} }
@Override @Override
@ -51,6 +57,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(mutable) && super.setBlock(x, y, z, block); return mask.test(get, mutable) && super.setBlock(x, y, z, block);
} }
} }

Datei anzeigen

@ -1,5 +1,6 @@
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;
@ -24,9 +25,20 @@ 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;
}
} }

Datei anzeigen

@ -1,5 +1,6 @@
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;
@ -11,7 +12,7 @@ import com.sk89q.worldedit.math.MutableBlockVector3;
public class AdjacentAnyMask extends AbstractMask implements ResettableMask { public class AdjacentAnyMask extends AbstractMask implements ResettableMask {
private final CachedMask mask; private final CachedMask mask;
private transient MutableBlockVector3 mutable = new MutableBlockVector3(); private final MutableBlockVector3 mutable;
public AdjacentAnyMask(Mask mask) { public AdjacentAnyMask(Mask mask) {
this.mask = CachedMask.cache(mask); this.mask = CachedMask.cache(mask);
@ -20,7 +21,7 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask {
@Override @Override
public void reset() { public void reset() {
mutable = new MutableBlockVector3(); mutable.setComponents(0, 0, 0);
} }
public CachedMask getParentMask() { public CachedMask getParentMask() {
@ -28,53 +29,28 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask {
} }
@Override @Override
public boolean test(BlockVector3 v) { public boolean test(Extent extent, BlockVector3 v) {
int x = v.getBlockX(); return direction(extent, v) != null;
int y = v.getBlockY();
int z = v.getBlockZ();
if (mask.test(x + 1, y, z)) {
return true;
}
if (mask.test(x - 1, y, z)) {
return true;
}
if (mask.test(x, y, z + 1)) {
return true;
}
if (mask.test(x, y, z - 1)) {
return true;
}
if (y < 256 && mask.test(x, y + 1, z)) {
return true;
}
if (y > 0 && mask.test(x, y - 1, z)) {
return true;
}
return false;
} }
public BlockVector3 direction(BlockVector3 v) { public BlockVector3 direction(Extent extent, 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(x + 1, y, z)) { if (mask.test(extent, x + 1, y, z)) {
mutable.setComponents(1, 0, 0); return mutable.setComponents(1, 0, 0);
}else }else if (mask.test(extent, x - 1, y, z)) {
if (mask.test(x - 1, y, z)) { return mutable.setComponents(-1, 0, 0);
mutable.setComponents(-1, 0, 0); }else if (mask.test(extent, x, y, z + 1)) {
}else return mutable.setComponents(0, 0, 1);
if (mask.test(x, y, z + 1)) { }else if (mask.test(extent, x, y, z - 1)) {
mutable.setComponents(0, 0, 1); return mutable.setComponents(0, 0, -1);
}else }else if (y < 256 && mask.test(extent, x, y + 1, z)) {
if (mask.test(x, y, z - 1)) { return mutable.setComponents(0, 1, 0);
mutable.setComponents(0, 0, -1); }else if (y > 0 && mask.test(extent, x, y - 1, z)) {
}else return mutable.setComponents(0, -1, 0);
if (y < 256 && mask.test(x, y + 1, z)) { } else {
mutable.setComponents(0, 1, 0); return null;
}else
if (y > 0 && mask.test(x, y - 1, z)) {
mutable.setComponents(0, -1, 0);
} }
return (mutable.getX() == 0 && mutable.getY() == 0 && mutable.getZ() == 0) ? null : mutable;
} }
} }

Datei anzeigen

@ -1,5 +1,6 @@
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;
@ -18,41 +19,41 @@ public class AdjacentMask extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 bv) { public boolean test(Extent extent, BlockVector3 bv) {
v.setComponents(bv); v.setComponents(bv);
int count = 0; int count = 0;
double x = bv.getX(); double x = bv.getX();
double y = bv.getY(); double y = bv.getY();
double z = bv.getZ(); double z = bv.getZ();
v.mutX(x + 1); v.mutX(x + 1);
if (mask.test(v) && ++count == min && max >= 8) { if (mask.test(extent, 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(v) && ++count == min && max >= 8) { if (mask.test(extent, v) && ++count == min && max >= 8) {
v.mutX(x); v.mutX(x);
return true; return true;
} }
v.mutX(x); v.mutX(x);
v.mutY(y + 1); v.mutY(y + 1);
if (mask.test(v) && ++count == min && max >= 8) { if (mask.test(extent, v) && ++count == min && max >= 8) {
v.mutY(y); v.mutY(y);
return true; return true;
} }
v.mutY(y - 1); v.mutY(y - 1);
if (mask.test(v) && ++count == min && max >= 8) { if (mask.test(extent, v) && ++count == min && max >= 8) {
v.mutY(y); v.mutY(y);
return true; return true;
} }
v.mutY(y); v.mutY(y);
v.mutZ(z + 1); v.mutZ(z + 1);
if (mask.test(v) && ++count == min && max >= 8) { if (mask.test(extent, 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(v) && ++count == min && max >= 8) { if (mask.test(extent, v) && ++count == min && max >= 8) {
v.mutZ(z); v.mutZ(z);
return true; return true;
} }

Datei anzeigen

@ -58,8 +58,8 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
protected transient boolean foundY; protected transient boolean foundY;
protected transient boolean lastValue; protected transient boolean lastValue;
public int getHeight(int x, int y, int z) { public int getHeight(Extent extent, int x, int y, int z) {
// return getExtent().getNearestSurfaceTerrainBlock(x, z, y, 0, maxY); // return extent.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY);
try { try {
int rx = x - cacheBotX + 16; int rx = x - cacheBotX + 16;
int rz = z - cacheBotZ + 16; int rz = z - cacheBotZ + 16;
@ -80,7 +80,7 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
} }
int result = cacheHeights[index] & 0xFF; int result = cacheHeights[index] & 0xFF;
if (y > result) { if (y > result) {
cacheHeights[index] = (byte) (result = lastY = getExtent().getNearestSurfaceTerrainBlock(x, z, lastY, 0, maxY)); cacheHeights[index] = (byte) (result = lastY = extent.getNearestSurfaceTerrainBlock(x, z, lastY, 0, maxY));
} }
return result; return result;
} catch (Throwable e) { } catch (Throwable e) {
@ -89,72 +89,72 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
} }
} }
protected boolean testSlope(int x, int y, int z) { protected boolean testSlope(Extent extent, int x, int y, int z) {
double slope; double slope;
boolean aboveMin; boolean aboveMin;
lastY = y; lastY = y;
slope = Math.abs(getHeight(x + distance, y, z) - getHeight(x -distance, y, z)) * ADJACENT_MOD; slope = Math.abs(getHeight(extent, x + distance, y, z) - getHeight(extent, x -distance, y, z)) * ADJACENT_MOD;
if (checkFirst) { if (checkFirst) {
if (slope >= min) { if (slope >= min) {
return lastValue = true; return lastValue = true;
} }
slope = Math.max(slope, Math.abs(getHeight(x, y, z + distance) - getHeight(x, y, z - distance)) * ADJACENT_MOD); slope = Math.max(slope, Math.abs(getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance)) * ADJACENT_MOD);
slope = Math.max(slope, Math.abs(getHeight(x + distance, y, z + distance) - getHeight(x - distance, y, z - distance)) * DIAGONAL_MOD); slope = Math.max(slope, Math.abs(getHeight(extent, x + distance, y, z + distance) - getHeight(extent, x - distance, y, z - distance)) * DIAGONAL_MOD);
slope = Math.max(slope, Math.abs(getHeight(x - distance, y, z + distance) - getHeight(x + distance, y, z - distance)) * DIAGONAL_MOD); slope = Math.max(slope, Math.abs(getHeight(extent, x - distance, y, z + distance) - getHeight(extent, x + distance, y, z - distance)) * DIAGONAL_MOD);
return lastValue = (slope >= min); return lastValue = (slope >= min);
} else { } else {
slope = Math.max(slope, Math.abs(getHeight(x, y, z + distance) - getHeight(x, y, z - distance)) * ADJACENT_MOD); slope = Math.max(slope, Math.abs(getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance)) * ADJACENT_MOD);
slope = Math.max(slope, Math.abs(getHeight(x + distance, y, z + distance) - getHeight(x - distance, y, z - distance)) * DIAGONAL_MOD); slope = Math.max(slope, Math.abs(getHeight(extent, x + distance, y, z + distance) - getHeight(extent, x - distance, y, z - distance)) * DIAGONAL_MOD);
slope = Math.max(slope, Math.abs(getHeight(x - distance, y, z + distance) - getHeight(x + distance, y, z - distance)) * DIAGONAL_MOD); slope = Math.max(slope, Math.abs(getHeight(extent, x - distance, y, z + distance) - getHeight(extent, x + distance, y, z - distance)) * DIAGONAL_MOD);
return lastValue = (slope >= min && slope <= max); return lastValue = (slope >= min && slope <= max);
} }
} }
public boolean adjacentAir(BlockVector3 v) { public boolean adjacentAir(Extent extent, 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(x + 1, y, z)) { if (!mask.test(extent, x + 1, y, z)) {
return true; return true;
} }
if (!mask.test(x - 1, y, z)) { if (!mask.test(extent, x - 1, y, z)) {
return true; return true;
} }
if (!mask.test(x, y, z + 1)) { if (!mask.test(extent, x, y, z + 1)) {
return true; return true;
} }
if (!mask.test(x, y, z - 1)) { if (!mask.test(extent, x, y, z - 1)) {
return true; return true;
} }
if (y < 255 && !mask.test(x, y + 1, z)) { if (y < 255 && !mask.test(extent, x, y + 1, z)) {
return true; return true;
} }
if (y > 0 && !mask.test(x, y - 1, z)) { if (y > 0 && !mask.test(extent, x, y - 1, z)) {
return true; return true;
} }
return false; return false;
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, 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(x, y, z); int height = getHeight(extent, x, y, z);
if (y <= height) return overlay ? (lastValue && y == height) : lastValue; if (y <= height) return overlay ? (lastValue && y == height) : lastValue;
} }
if (!mask.test(x, y, z)) { if (!mask.test(extent, x, y, z)) {
return false; return false;
} }
if (overlay) { if (overlay) {
if (y < 255 && !mask.test(x, y + 1, z)) return lastValue = false; if (y < 255 && !mask.test(extent, x, y + 1, z)) return lastValue = false;
} else if (!adjacentAir(vector)) { } else if (!adjacentAir(extent, vector)) {
return false; return false;
} }
return testSlope(x, y, z); return testSlope(extent, x, y, z);
} }
} }

Datei anzeigen

@ -22,8 +22,8 @@ public class BiomeMask extends AbstractExtentMask implements ResettableMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
BlockVector2 pos = mutable.setComponents(vector.getBlockX(), vector.getBlockZ()); BlockVector2 pos = mutable.setComponents(vector.getBlockX(), vector.getBlockZ());
return getExtent().getBiome(pos).getId() == biome.getId(); return extent.getBiome(pos).getId() == biome.getId();
} }
} }

Datei anzeigen

@ -16,8 +16,7 @@ public class BlockLightMask extends AbstractExtentMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
Extent extent = getExtent();
if (extent instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getBlockLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); int light = ((LightingExtent) extent).getBlockLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;

Datei anzeigen

@ -16,8 +16,7 @@ public class BrightnessMask extends AbstractExtentMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
Extent extent = getExtent();
if (extent instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getBrightness(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); int light = ((LightingExtent) extent).getBrightness(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;

Datei anzeigen

@ -2,6 +2,7 @@ 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;
@ -41,21 +42,21 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return test(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); return test(extent, vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
} }
public boolean test(int x, int y, int z) { public boolean test(Extent extent, 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(mutable.setComponents(x, y, z)); boolean result = getMask().test(extent, 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 ignore) {
boolean result = getMask().test(mutable.setComponents(x, y, z)); boolean result = getMask().test(extent, 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);

Datei anzeigen

@ -13,8 +13,7 @@ public class DataMask extends AbstractExtentMask implements ResettableMask {
private transient int data = -1; private transient int data = -1;
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
Extent extent = getExtent();
if (data != -1) { if (data != -1) {
return extent.getBlock(vector).getInternalPropertiesId() == data; return extent.getBlock(vector).getInternalPropertiesId() == data;
} else { } else {

Datei anzeigen

@ -8,28 +8,28 @@ public class ExtremaMask extends AngleMask {
} }
@Override @Override
protected boolean testSlope(int x, int y, int z) { protected boolean testSlope(Extent extent, int x, int y, int z) {
double slope, tmp; double slope, tmp;
boolean aboveMin; boolean aboveMin;
lastY = y; lastY = y;
int base = getHeight(x, y, z); int base = getHeight(extent, x, y, z);
slope = get(base, x, y, z, 1, 0, distance) * ADJACENT_MOD; slope = getHeight(extent, base, x, y, z, 1, 0, distance) * ADJACENT_MOD;
tmp = get(base, x, y, z, 0, 1, distance) * ADJACENT_MOD; tmp = getHeight(extent, base, x, y, z, 0, 1, distance) * ADJACENT_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp; if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
tmp = get(base, x, y, z, 1, 1, distance) * DIAGONAL_MOD; tmp = getHeight(extent, base, x, y, z, 1, 1, distance) * DIAGONAL_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp; if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
tmp = get(base, x, y, z, 1, -1, distance) * DIAGONAL_MOD; tmp = getHeight(extent, base, x, y, z, 1, -1, distance) * DIAGONAL_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp; if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
return lastValue = (slope > min && slope < max); return lastValue = (slope > min && slope < max);
} }
private int get(int base, int x, int y, int z, int OX, int OZ, int iterations) { private int getHeight(Extent extent, int base, int x, int y, int z, int OX, int OZ, int iterations) {
int sign = 0; int sign = 0;
int lastHeight1 = base; int lastHeight1 = base;
int lastHeight2 = base; int lastHeight2 = base;
@ -40,8 +40,8 @@ public class ExtremaMask extends AngleMask {
int z1 = z + coz; int z1 = z + coz;
int x2 = x - cox; int x2 = x - cox;
int z2 = z - coz; int z2 = z - coz;
int height1 = getHeight(x1, y, z1); int height1 = getHeight(extent, x1, y, z1);
int height2 = getHeight(x2, y, z2); int height2 = getHeight(extent, x2, y, z2);
int diff1 = height1 - lastHeight1; int diff1 = height1 - lastHeight1;
int diff2 = height2 - lastHeight2; int diff2 = height2 - lastHeight2;
int sign1 = Integer.signum(diff1); int sign1 = Integer.signum(diff1);

Datei anzeigen

@ -12,8 +12,7 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
Extent extent = getExtent();
if (combined != -1) { if (combined != -1) {
return extent.getBlock(vector).getInternalId() == combined; return extent.getBlock(vector).getInternalId() == combined;
} else { } else {

Datei anzeigen

@ -13,8 +13,7 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
Extent extent = getExtent();
if (id != -1) { if (id != -1) {
return extent.getBlock(vector).getInternalBlockTypeId() == id; return extent.getBlock(vector).getInternalBlockTypeId() == id;
} else { } else {

Datei anzeigen

@ -16,9 +16,9 @@ public class LightMask extends AbstractExtentMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (getExtent() instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) getExtent()).getLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); int light = ((LightingExtent) extent).getLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;
} }
return false; return false;

Datei anzeigen

@ -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(current.toBlockPoint())) { if (!mask.test(world, 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()) {

Datei anzeigen

@ -16,9 +16,9 @@ public class OpacityMask extends AbstractExtentMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (getExtent() instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) getExtent()).getOpacity(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); int light = ((LightingExtent) extent).getOpacity(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;
} }
return false; return false;

Datei anzeigen

@ -1,5 +1,6 @@
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;
@ -12,7 +13,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(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
switch (mode) { switch (mode) {
case -1: case -1:
originX = vector.getBlockX(); originX = vector.getBlockX();

Datei anzeigen

@ -9,23 +9,23 @@ public class ROCAngleMask extends AngleMask {
} }
@Override @Override
protected boolean testSlope(int x, int y, int z) { protected boolean testSlope(Extent extent, int x, int y, int z) {
double tmp; double tmp;
lastY = y; lastY = y;
int base = getHeight(x, y, z); int base = getHeight(extent, x, y, z);
double slope = double slope =
(getHeight(x + distance, y, z) - base - (base - getHeight(x - distance, y, z))) (getHeight(extent, x + distance, y, z) - base - (base - getHeight(extent, x - distance, y, z)))
* ADJACENT_MOD; * ADJACENT_MOD;
tmp = (getHeight(x, y, z + distance) - base - (base - getHeight(x, y, z - distance))) * ADJACENT_MOD; tmp = (getHeight(extent, x, y, z + distance) - base - (base - getHeight(extent, x, y, z - distance))) * ADJACENT_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp; if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
tmp = (getHeight(x + distance, y, z + distance) - base - (base - getHeight(x - distance, y, tmp = (getHeight(extent, x + distance, y, z + distance) - base - (base - getHeight(extent, x - distance, y,
z - distance))) * DIAGONAL_MOD; z - distance))) * DIAGONAL_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp; if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
tmp = (getHeight(x - distance, y, z + distance) - base - (base - getHeight(x + distance, y, tmp = (getHeight(extent, x - distance, y, z + distance) - base - (base - getHeight(extent, x + distance, y,
z - distance))) * DIAGONAL_MOD; z - distance))) * DIAGONAL_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp; if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;

Datei anzeigen

@ -1,5 +1,6 @@
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;
@ -19,7 +20,7 @@ public class RadiusMask extends AbstractMask implements ResettableMask {
} }
@Override @Override
public boolean test(BlockVector3 to) { public boolean test(Extent extent, BlockVector3 to) {
if (pos == null) { if (pos == null) {
pos = to.toImmutable(); pos = to.toImmutable();
} }

Datei anzeigen

@ -1,5 +1,6 @@
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;
import java.util.SplittableRandom; import java.util.SplittableRandom;
@ -14,7 +15,7 @@ public class RandomMask extends AbstractMask implements ResettableMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return random.nextInt() <= threshold; return random.nextInt() <= threshold;
} }

Datei anzeigen

@ -1,6 +1,7 @@
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;
@ -14,7 +15,7 @@ public class SimplexMask extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, 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;
} }

Datei anzeigen

@ -17,9 +17,9 @@ public class SkyLightMask extends AbstractExtentMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (getExtent() instanceof LightingExtent) { if (extent instanceof LightingExtent) {
int light = ((LightingExtent) getExtent()) int light = ((LightingExtent) extent)
.getSkyLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); .getSkyLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; return light >= min && light <= max;
} }

Datei anzeigen

@ -20,7 +20,7 @@ public class SolidPlaneMask extends SolidBlockMask implements ResettableMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
switch (mode) { switch (mode) {
case -1: case -1:
if (!super.test(vector)) { if (!super.test(vector)) {
@ -30,7 +30,6 @@ public class SolidPlaneMask extends SolidBlockMask implements ResettableMask {
originY = vector.getBlockY(); originY = vector.getBlockY();
originZ = vector.getBlockZ(); originZ = vector.getBlockZ();
mode = 0; mode = 0;
Extent extent = getExtent();
if (!extent.getBlock(mutable.setComponents(originX - 1, originY, originZ)).getMaterial().isAir() && !extent.getBlock(mutable.setComponents(originX + 1, originY, originZ)).getMaterial().isAir()) { if (!extent.getBlock(mutable.setComponents(originX - 1, originY, originZ)).getMaterial().isAir() && !extent.getBlock(mutable.setComponents(originX + 1, originY, originZ)).getMaterial().isAir()) {
mode &= 1; mode &= 1;
} }

Datei anzeigen

@ -19,7 +19,7 @@ public class SurfaceMask extends AdjacentAnyMask {
} }
@Override @Override
public boolean test(BlockVector3 v) { public boolean test(Extent extent, BlockVector3 v) {
return !getParentMask().test(v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(v); return !getParentMask().test(extent, v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(extent, v);
} }
} }

Datei anzeigen

@ -1,5 +1,6 @@
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;
@ -18,30 +19,30 @@ public class WallMask extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 bv) { public boolean test(Extent extent, 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(v) && ++count == min && max >= 8) { if (mask.test(extent, 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(v) && ++count == min && max >= 8) { if (mask.test(extent, 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(v) && ++count == min && max >= 8) { if (mask.test(extent, 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(v) && ++count == min && max >= 8) { if (mask.test(extent, v) && ++count == min && max >= 8) {
v.mutZ(z); v.mutZ(z);
return true; return true;
} }

Datei anzeigen

@ -1,5 +1,6 @@
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;
@ -11,7 +12,7 @@ public class XAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1; private transient int layer = -1;
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (layer == -1) { if (layer == -1) {
layer = vector.getBlockX(); layer = vector.getBlockX();
} }

Datei anzeigen

@ -1,5 +1,6 @@
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;
@ -11,7 +12,7 @@ public class YAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1; private transient int layer = -1;
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (layer == -1) { if (layer == -1) {
layer = vector.getBlockY(); layer = vector.getBlockY();
} }

Datei anzeigen

@ -1,5 +1,6 @@
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;
@ -11,7 +12,7 @@ public class ZAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1; private transient int layer = -1;
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (layer == -1) { if (layer == -1) {
layer = vector.getBlockZ(); layer = vector.getBlockZ();
} }

Datei anzeigen

@ -20,7 +20,6 @@ public class MaskedPattern extends AbstractPattern {
this.secondary = secondary; this.secondary = secondary;
} }
@Override @Override
public BaseBlock apply(BlockVector3 position) { public BaseBlock apply(BlockVector3 position) {
if (mask.test(position)) { if (mask.test(position)) {
@ -31,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(get)) { if (mask.test(extent, 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);

Datei anzeigen

@ -5,6 +5,8 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
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.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
@ -42,7 +44,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, new RegionFunction() { RecursiveVisitor search = new RecursiveVisitor(mask.withExtent(extent), new RegionFunction() {
@Override @Override
public boolean apply(BlockVector3 p) throws WorldEditException { public boolean apply(BlockVector3 p) throws WorldEditException {
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ()); setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());

Datei anzeigen

@ -375,7 +375,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)) { if (mask.test(extent, extent)) {
blocks.add(block); blocks.add(block);
} }
} }

Datei anzeigen

@ -800,7 +800,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
@Override @Override
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(mutablebv.setComponents(x, y, z))) { if (filter.test(getExtent(), mutablebv.setComponents(x, y, z))) {
return y; return y;
} }
} }
@ -1079,8 +1079,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);
} }
final Mask mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this))); Mask mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this))).withExtent(getExtent());
// Want to replace blocks // Want to replace blocks
final BlockReplace replace = new BlockReplace(EditSession.this, pattern); final BlockReplace replace = new BlockReplace(EditSession.this, pattern);
@ -1127,13 +1126,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
checkArgument(radius >= 0, "radius >= 0"); checkArgument(radius >= 0, "radius >= 0");
checkArgument(depth >= 1, "depth >= 1"); checkArgument(depth >= 1, "depth >= 1");
MaskIntersection mask = new MaskIntersection( Mask mask = new MaskIntersection(
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
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))); Masks.negate(new ExistingBlockMask(this))).withExtent(getExtent());
// Want to replace blocks // Want to replace blocks
BlockReplace replace = new BlockReplace(this, pattern); BlockReplace replace = new BlockReplace(this, pattern);
@ -1341,15 +1339,18 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
if (region instanceof CuboidRegion) { if (region instanceof CuboidRegion) {
return makeCuboidWalls(region, pattern); return makeCuboidWalls(region, pattern);
} else { } else {
replaceBlocks(region, position -> { replaceBlocks(region, new Mask() {
int x = position.getBlockX(); @Override
int y = position.getBlockY(); public boolean test(Extent extent, BlockVector3 position) {
int z = position.getBlockZ(); int x = position.getBlockX();
if (!region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains(x - 1, z)) { int y = position.getBlockY();
return true; int z = position.getBlockZ();
} if (!region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains(x - 1, z)) {
return true;
}
return false; return false;
}
}, pattern); }, pattern);
} }
return changes; return changes;
@ -1571,10 +1572,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
// } else { // } else {
// } // }
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER); liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
MaskIntersection 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); liquidMask).withExtent(getExtent());
BlockReplace replace; BlockReplace replace;
if (waterlogged) { if (waterlogged) {
replace = new BlockReplace(this, new WaterloggedRemover(this)); replace = new BlockReplace(this, new WaterloggedRemover(this));
@ -1585,7 +1586,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(position)) { if (mask.test(getExtent(), position)) {
visitor.visit(position); visitor.visit(position);
} }
} }
@ -1619,14 +1620,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(position)) { if (liquidMask.test(getExtent(), position)) {
visitor.visit(position); visitor.visit(position);
} }
} }
@ -2712,7 +2712,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(current)) { if (mask.test(getExtent(), current)) {
continue; continue;
} }
if (!outside.add(current)) { if (!outside.add(current)) {

Datei anzeigen

@ -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(MutableBlockVector3.get(x, y, z))) { if (filter.test(this, 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(MutableBlockVector3.get(x, y, z)); boolean state = !mask.test(this, 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(MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset; if (mask.test(this, MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset;
int y2 = y - d; int y2 = y - d;
if (mask.test(MutableBlockVector3.get(x, y2, z)) != state) return y2 + offset; if (mask.test(this, 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(MutableBlockVector3.get(x, layer, z)) != state) return layer + offset; if (mask.test(this, 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(MutableBlockVector3.get(x, layer, z)) != state) return layer - offset; if (mask.test(this, 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, searchMask::test); RegionVisitor visitor = new RegionVisitor(region, position -> searchMask.test(this, position));
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
return visitor.getAffected(); return visitor.getAffected();
} }
@ -606,7 +606,7 @@ public interface Extent extends InputExtent, OutputExtent {
checkNotNull(pattern); checkNotNull(pattern);
BlockReplace replace = new BlockReplace(this, pattern); BlockReplace replace = new BlockReplace(this, pattern);
RegionMaskingFilter filter = new RegionMaskingFilter(mask, replace); RegionMaskingFilter filter = new RegionMaskingFilter(this, mask, replace);
RegionVisitor visitor = new RegionVisitor(region, filter); RegionVisitor visitor = new RegionVisitor(region, filter);
Operations.completeLegacy(visitor); Operations.completeLegacy(visitor);
return visitor.getAffected(); return visitor.getAffected();

Datei anzeigen

@ -86,17 +86,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(location) && super.setBlock(location, block); return mask.test(getExtent(), location) && super.setBlock(location, block);
} }
@Override @Override
public boolean setBiome(BlockVector2 position, BiomeType biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
return mask.test(position.toBlockVector3()) && super.setBiome(position, biome); return mask.test(getExtent(), 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(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome); return mask.test(getExtent(), BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome);
} }
@Override @Override
@ -108,7 +108,7 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
@Override @Override
public void applyBlock(FilterBlock block) { public void applyBlock(FilterBlock block) {
int ordinal = block.getOrdinal(); int ordinal = block.getOrdinal();
if (ordinal != 0 && !mask.test(block)) { if (ordinal != 0 && !mask.test(getExtent(), block)) {
block.setOrdinal(0); block.setOrdinal(0);
} }
} }

Datei anzeigen

@ -45,6 +45,7 @@ import javax.annotation.Nullable;
* pass on any changes. * pass on any changes.
*/ */
public class NullExtent implements Extent { public class NullExtent implements Extent {
public static final NullExtent INSTANCE = new NullExtent();
@Override @Override
public BlockVector3 getMinimumPoint() { public BlockVector3 getMinimumPoint() {

Datei anzeigen

@ -67,7 +67,7 @@ public class ExtentBuffer extends AbstractBufferingExtent {
@Override @Override
protected Optional<BaseBlock> getBufferedBlock(BlockVector3 position) { protected Optional<BaseBlock> getBufferedBlock(BlockVector3 position) {
if (mask.test(position)) { if (mask.test(getExtent(), position)) {
return Optional.of(buffer.computeIfAbsent(position, (pos -> getExtent().getFullBlock(pos)))); return Optional.of(buffer.computeIfAbsent(position, (pos -> getExtent().getFullBlock(pos))));
} }
return Optional.empty(); return Optional.empty();
@ -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(location)) { if (mask.test(getExtent(), location)) {
buffer.put(location, block.toBaseBlock()); buffer.put(location, block.toBaseBlock());
return true; return true;
} }

Datei anzeigen

@ -106,7 +106,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
max = max.getMaximum(location); max = max.getMaximum(location);
} }
if (mask.test(location)) { if (mask.test(getExtent(), location)) {
buffer.put(location, block.toBaseBlock()); buffer.put(location, block.toBaseBlock());
return true; return true;
} else { } else {
@ -130,7 +130,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
max2d = max2d.getMaximum(position); max2d = max2d.getMaximum(position);
} }
if (biomeMask.test(position)) { if (biomeMask.test(getExtent(), position)) {
biomeBuffer.put(position, biome); biomeBuffer.put(position, biome);
return true; return true;
} else { } else {
@ -154,7 +154,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(BlockVector2.at(x,z))) { if (biomeMask.test(getExtent(), BlockVector2.at(x,z))) {
biomeBuffer.put(BlockVector2.at(x,z), biome); biomeBuffer.put(BlockVector2.at(x,z), biome);
return true; return true;
} else { } else {

Datei anzeigen

@ -54,4 +54,4 @@ public class FlatRegionMaskingFilter implements FlatRegionFunction {
return mask.test(position) && function.apply(position); return mask.test(position) && function.apply(position);
} }
} }

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
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;
@ -51,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(position)) { if (mask.test(NullExtent.INSTANCE, position)) {
return pass.apply(position); return pass.apply(position);
} else { } else {
return fail.apply(position); return fail.apply(position);

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.function;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
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;
@ -33,7 +34,8 @@ import com.sk89q.worldedit.math.BlockVector3;
public class RegionMaskingFilter implements RegionFunction { public class RegionMaskingFilter implements RegionFunction {
private final RegionFunction function; private final RegionFunction function;
private Mask mask; private final Extent extent;
private final Mask mask;
/** /**
* Create a new masking filter. * Create a new masking filter.
@ -41,16 +43,18 @@ public class RegionMaskingFilter implements RegionFunction {
* @param mask the mask * @param mask the mask
* @param function the function * @param function the function
*/ */
public RegionMaskingFilter(Mask mask, RegionFunction function) { public RegionMaskingFilter(Extent extent, Mask mask, RegionFunction function) {
checkNotNull(function); checkNotNull(function);
checkNotNull(mask); checkNotNull(mask);
checkNotNull(extent);
this.extent = extent;
this.mask = mask; this.mask = mask;
this.function = function; this.function = function;
} }
@Override @Override
public boolean apply(BlockVector3 position) throws WorldEditException { public boolean apply(BlockVector3 position) throws WorldEditException {
return mask.test(position) && function.apply(position); return mask.test(extent, position) && function.apply(position);
} }
} }

Datei anzeigen

@ -63,7 +63,7 @@ public class Naturalizer implements LayerFunction {
@Override @Override
public boolean isGround(BlockVector3 position) { public boolean isGround(BlockVector3 position) {
return mask.test(position); return mask.test(editSession, 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(position)) { if (mask.test(editSession, position)) {
if (naturalize(position, depth)) { if (naturalize(position, depth)) {
++affected; ++affected;
} }

Datei anzeigen

@ -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(mutable.setComponents(x, y, z))) { if (!mask.test(extent, 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(mutable)) if (mask.test(extent, mutable))
pattern.apply(extent, mutable, mutable); pattern.apply(extent, mutable, mutable);
} }
} }

Datei anzeigen

@ -35,7 +35,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(mutable)) { if (!mask.test(extent, mutable)) {
return false; return false;
} }
mutable.mutY(y + 1); mutable.mutY(y + 1);

Datei anzeigen

@ -2,6 +2,7 @@ package com.sk89q.worldedit.function.mask;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
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,6 +16,11 @@ public abstract class ABlockMask extends AbstractExtentMask {
super(extent); super(extent);
} }
@Override
public boolean test(Extent extent, BlockVector3 vector) {
return test(vector.getBlock(extent));
}
public abstract boolean test(BlockState state); public abstract boolean test(BlockState state);
@Override @Override

Datei anzeigen

@ -22,6 +22,8 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.session.request.Request;
/** /**
* An abstract implementation of {@link Mask} that takes uses an {@link Extent}. * An abstract implementation of {@link Mask} that takes uses an {@link Extent}.
@ -39,6 +41,11 @@ 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.
* *
@ -58,4 +65,9 @@ public abstract class AbstractExtentMask extends AbstractMask {
this.extent = extent; this.extent = extent;
} }
@Override
public Mask withExtent(Extent extent) {
setExtent(extent);
return this;
}
} }

Datei anzeigen

@ -90,7 +90,7 @@ public class BiomeMask2D extends AbstractMask2D {
} }
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(Extent extent, BlockVector2 vector) {
BiomeType biome = extent.getBiome(vector); BiomeType biome = extent.getBiome(vector);
return biomes.contains(biome); return biomes.contains(biome);
} }

Datei anzeigen

@ -40,8 +40,8 @@ public class BlockCategoryMask extends AbstractExtentMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return category.contains(getExtent().getBlock(vector)); return category.contains(vector.getBlock(extent));
} }
@Nullable @Nullable

Datei anzeigen

@ -172,8 +172,8 @@ public class BlockMask extends ABlockMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return ordinals[vector.getOrdinal(getExtent())]; return ordinals[vector.getOrdinal(extent)];
} }
@Override @Override

Datei anzeigen

@ -51,8 +51,8 @@ public class BlockStateMask extends AbstractExtentMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return test(vector.getBlock(getExtent())); return test(vector.getBlock(extent));
} }
public boolean test(BlockState block) { public boolean test(BlockState block) {

Datei anzeigen

@ -106,8 +106,8 @@ public class BlockTypeMask extends AbstractExtentMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return test(vector.getBlock(getExtent()).getBlockType()); return test(vector.getBlock(extent).getBlockType());
} }
public boolean test(BlockType block) { public boolean test(BlockType block) {

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
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;
@ -46,7 +47,7 @@ public class BoundedHeightMask extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return vector.getY() >= minY && vector.getY() <= maxY; return vector.getY() >= minY && vector.getY() <= maxY;
} }

Datei anzeigen

@ -0,0 +1,28 @@
package com.sk89q.worldedit.function.mask;
import com.boydti.fawe.object.function.mask.AbstractDelegateMask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
public class DelegateExtentMask extends AbstractDelegateMask {
private final Extent extent;
public DelegateExtentMask(Extent extent, Mask parent) {
super(parent);
this.extent = extent;
}
@Override
public boolean test(BlockVector3 vector) {
return super.test(extent, vector);
}
public Extent getExtent() {
return extent;
}
@Override
public Mask withExtent(Extent extent) {
return new DelegateExtentMask(extent, getMask());
}
}

Datei anzeigen

@ -39,8 +39,8 @@ public class ExistingBlockMask extends AbstractExtentMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return !vector.getBlock(getExtent()).getMaterial().isAir(); return !vector.getBlock(extent).getMaterial().isAir();
} }
@Nullable @Nullable

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.Extent;
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;
import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.internal.expression.EvaluationException;
@ -67,7 +68,7 @@ public class ExpressionMask extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, 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());

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.internal.expression.EvaluationException;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
@ -59,7 +60,7 @@ public class ExpressionMask2D extends AbstractMask2D {
} }
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(Extent extent, 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;

Datei anzeigen

@ -2,6 +2,7 @@ package com.sk89q.worldedit.function.mask;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
public class InverseMask extends AbstractMask { public class InverseMask extends AbstractMask {
@ -12,8 +13,8 @@ public class InverseMask extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 pos) {
return !mask.test(vector); return !mask.test(extent, pos);
} }
@Nullable @Nullable

Datei anzeigen

@ -18,8 +18,8 @@ public class InverseSingleBlockStateMask extends ABlockMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return ordinal != vector.getOrdinal(getExtent()); return ordinal != vector.getOrdinal(extent);
} }
@Override @Override

Datei anzeigen

@ -16,8 +16,8 @@ public class InverseSingleBlockTypeMask extends ABlockMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return test(vector.getBlock(getExtent())); return test(vector.getBlock(extent));
} }
@Override @Override

Datei anzeigen

@ -21,7 +21,13 @@ 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.block.FilterBlock; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.session.request.Request;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -36,12 +42,26 @@ 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
*/ */
boolean test(BlockVector3 vector); default boolean test(BlockVector3 vector) {
Extent extent = Request.request().getExtent();
if (extent == null) {
extent = NullExtent.INSTANCE;
}
return test(extent, vector);
}
default boolean test(Extent extent, BlockVector3 vector) {
return test(vector);
}
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.
* *
@ -97,7 +117,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)) { if (test(block, block)) {
run.accept(block); run.accept(block);
} }
} }

Datei anzeigen

@ -19,7 +19,10 @@
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.
@ -32,6 +35,16 @@ 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
*/ */
boolean test(BlockVector2 vector); default boolean test(BlockVector2 vector) {
Extent extent = Request.request().getExtent();
if (extent == null) {
extent = NullExtent.INSTANCE;
}
return test(extent, vector);
}
default boolean test(Extent extent, BlockVector2 vector) {
return test(vector);
}
} }

Datei anzeigen

@ -26,7 +26,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)) { if (mask.test(block, block)) {
getParent().applyBlock(block); getParent().applyBlock(block);
} }
} }

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
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;
import java.util.ArrayList; import java.util.ArrayList;
@ -224,9 +225,9 @@ public class MaskIntersection extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
for (Mask mask : masksArray) { for (Mask mask : masksArray) {
if (!mask.test(vector)) { if (!mask.test(extent, vector)) {
return false; return false;
} }
} }

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
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;
@ -83,13 +84,13 @@ public class MaskIntersection2D implements Mask2D {
} }
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(Extent extent, BlockVector2 vector) {
if (masks.isEmpty()) { if (masks.isEmpty()) {
return false; return false;
} }
for (Mask2D mask : masks) { for (Mask2D mask : masks) {
if (!mask.test(vector)) { if (!mask.test(extent, vector)) {
return false; return false;
} }
} }

Datei anzeigen

@ -19,6 +19,7 @@
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;
import java.util.Collection; import java.util.Collection;
@ -84,11 +85,11 @@ public class MaskUnion extends MaskIntersection {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
Mask[] masks = getMasksArray(); Mask[] masks = getMasksArray();
for (Mask mask : masks) { for (Mask mask : masks) {
if (mask.test(vector)) { if (mask.test(extent, vector)) {
return true; return true;
} }
} }

Datei anzeigen

@ -19,6 +19,7 @@
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;
@ -47,11 +48,11 @@ public class MaskUnion2D extends MaskIntersection2D {
} }
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(Extent extent, BlockVector2 vector) {
Collection<Mask2D> masks = getMasks(); Collection<Mask2D> masks = getMasks();
for (Mask2D mask : masks) { for (Mask2D mask : masks) {
if (mask.test(vector)) { if (mask.test(extent, vector)) {
return true; return true;
} }
} }

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
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;
@ -89,8 +90,8 @@ public final class Masks {
checkNotNull(mask); checkNotNull(mask);
return new AbstractMask2D() { return new AbstractMask2D() {
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(Extent extent, BlockVector2 vector) {
return !mask.test(vector); return !mask.test(extent, vector);
} }
}; };
} }
@ -104,8 +105,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(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return mask.test(vector.toBlockVector2()); return mask.test(extent, vector.toBlockVector2());
} }
@Nullable @Nullable
@ -118,12 +119,12 @@ public final class Masks {
protected static class AlwaysTrue implements Mask, Mask2D { protected static class AlwaysTrue implements Mask, Mask2D {
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return true; return true;
} }
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(Extent extent, BlockVector2 vector) {
return true; return true;
} }
@ -142,16 +143,21 @@ public final class Masks {
public Mask tryOr(Mask other) { public Mask tryOr(Mask other) {
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(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return false; return false;
} }
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(Extent extent, BlockVector2 vector) {
return false; return false;
} }
@ -170,6 +176,11 @@ public final class Masks {
public Mask tryOr(Mask other) { public Mask tryOr(Mask other) {
return other; return other;
} }
@Override
public Mask withExtent(Extent extent) {
return this;
}
} }
} }

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.function.mask;
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 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;
@ -85,7 +86,7 @@ public class NoiseFilter extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, 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;
} }

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.function.mask;
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 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;
@ -83,7 +84,7 @@ public class NoiseFilter2D extends AbstractMask2D {
} }
@Override @Override
public boolean test(BlockVector2 pos) { public boolean test(Extent extent, BlockVector2 pos) {
return noiseGenerator.noise(pos.toVector2()) <= density; return noiseGenerator.noise(pos.toVector2()) <= density;
} }

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
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;
@ -86,8 +87,8 @@ public class OffsetMask extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 pos) {
return getMask().test(vector.add(offset)); return getMask().test(extent, pos);
} }
@Nullable @Nullable

Datei anzeigen

@ -21,7 +21,9 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.MutableBlockVector2;
/** /**
* Checks whether another mask tests true for a position that is offset * Checks whether another mask tests true for a position that is offset
@ -31,6 +33,7 @@ public class OffsetMask2D extends AbstractMask2D {
private Mask2D mask; private Mask2D mask;
private BlockVector2 offset; private BlockVector2 offset;
private MutableBlockVector2 mutable;
/** /**
* Create a new instance. * Create a new instance.
@ -43,6 +46,7 @@ public class OffsetMask2D extends AbstractMask2D {
checkNotNull(offset); checkNotNull(offset);
this.mask = mask; this.mask = mask;
this.offset = offset; this.offset = offset;
this.mutable = new MutableBlockVector2();
} }
/** /**
@ -84,8 +88,9 @@ public class OffsetMask2D extends AbstractMask2D {
} }
@Override @Override
public boolean test(BlockVector2 vector) { public boolean test(Extent extent, BlockVector2 vector) {
return getMask().test(vector.add(offset)); mutable.setComponents(vector.getX() + offset.getX(), vector.getZ() + offset.getZ());
return getMask().test(extent, mutable);
} }
} }

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
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;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -61,7 +62,7 @@ public class RegionMask extends AbstractMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return region.contains(vector); return region.contains(vector);
} }

Datei anzeigen

@ -18,8 +18,8 @@ public class SingleBlockStateMask extends ABlockMask {
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return ordinal == vector.getOrdinal(getExtent()); return ordinal == vector.getOrdinal(extent);
} }
@Override @Override

Datei anzeigen

@ -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 SingleBlockTypeMask extends ABlockMask {
this.internalId = type.getInternalId(); this.internalId = type.getInternalId();
} }
@Override
public boolean test(BlockVector3 vector) {
return test(vector.getBlock(getExtent()));
}
@Override @Override
public final boolean test(BlockState state) { public final boolean test(BlockState state) {
return state.getBlockType().getInternalId() == internalId; return state.getBlockType().getInternalId() == internalId;

Datei anzeigen

@ -317,7 +317,7 @@ public class ForwardExtentCopy implements Operation {
} }
if (sourceMask != Masks.alwaysTrue()) { if (sourceMask != Masks.alwaysTrue()) {
new MaskTraverser(sourceMask).reset(transExt); new MaskTraverser(sourceMask).reset(transExt);
copy = new RegionMaskingFilter(sourceMask, copy); copy = new RegionMaskingFilter(source, sourceMask, copy);
} }
if (copyingBiomes && source.isWorld() || (source instanceof Clipboard && ((Clipboard) source).hasBiomes())) { if (copyingBiomes && source.isWorld() || (source instanceof Clipboard && ((Clipboard) source).hasBiomes())) {
copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest)); copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest));
@ -371,7 +371,7 @@ public class ForwardExtentCopy implements Operation {
} }
if (sourceMask != Masks.alwaysTrue()) { if (sourceMask != Masks.alwaysTrue()) {
if (maskFunc != null) copy = new RegionMaskTestFunction(sourceMask, copy, maskFunc); if (maskFunc != null) copy = new RegionMaskTestFunction(sourceMask, copy, maskFunc);
else copy = new RegionMaskingFilter(sourceMask, copy); else copy = new RegionMaskingFilter(source, sourceMask, copy);
} }
if (copyingBiomes && source.isWorld() || (source instanceof Clipboard && ((Clipboard) source).hasBiomes())) { if (copyingBiomes && source.isWorld() || (source instanceof Clipboard && ((Clipboard) source).hasBiomes())) {
copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest)); copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest));

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.util; package com.sk89q.worldedit.util;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; 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.SolidBlockMask; import com.sk89q.worldedit.function.mask.SolidBlockMask;
@ -38,7 +39,7 @@ import javax.annotation.Nullable;
*/ */
public class TargetBlock { public class TargetBlock {
private final World world; private final Extent world;
private int maxDistance; private int maxDistance;
private double checkDistance, curDistance; private double checkDistance, curDistance;
@ -58,11 +59,7 @@ public class TargetBlock {
* @param player player to work with * @param player player to work with
*/ */
public TargetBlock(Player player) { public TargetBlock(Player player) {
this.world = player.getWorld(); this(player, 300, 0.2);
this.setValues(player.getLocation().toVector(), player.getLocation().getYaw(), player.getLocation().getPitch(),
300, 1.65, 0.2);
this.stopMask = new ExistingBlockMask(world);
this.solidMask = new SolidBlockMask(world);
} }
/** /**
@ -73,6 +70,10 @@ public class TargetBlock {
* @param checkDistance how often to check for blocks, the smaller the more precise * @param checkDistance how often to check for blocks, the smaller the more precise
*/ */
public TargetBlock(Player player, int maxDistance, double checkDistance) { public TargetBlock(Player player, int maxDistance, double checkDistance) {
this(player, player.getWorld(), maxDistance, checkDistance);
}
public TargetBlock(Player player, Extent extent, int maxDistance, double checkDistance) {
this.world = player.getWorld(); this.world = player.getWorld();
this.setValues(player.getLocation().toVector(), player.getLocation().getYaw(), player.getLocation().getPitch(), maxDistance, 1.65, checkDistance); this.setValues(player.getLocation().toVector(), player.getLocation().getYaw(), player.getLocation().getPitch(), maxDistance, 1.65, checkDistance);
this.stopMask = new ExistingBlockMask(world); this.stopMask = new ExistingBlockMask(world);
@ -145,7 +146,7 @@ public class TargetBlock {
boolean searchForLastBlock = true; boolean searchForLastBlock = true;
Location lastBlock = null; Location lastBlock = null;
while (getNextBlock() != null) { while (getNextBlock() != null) {
if (stopMask.test(targetPos)) { if (stopMask.test(world, targetPos)) {
break; break;
} else { } else {
if (searchForLastBlock) { if (searchForLastBlock) {
@ -168,7 +169,7 @@ public class TargetBlock {
*/ */
public Location getTargetBlock() { public Location getTargetBlock() {
//noinspection StatementWithEmptyBody //noinspection StatementWithEmptyBody
while (getNextBlock() != null && !stopMask.test(targetPos)) ; while (getNextBlock() != null && !stopMask.test(world, targetPos)) ;
return getCurrentBlock(); return getCurrentBlock();
} }
@ -180,7 +181,7 @@ public class TargetBlock {
*/ */
public Location getSolidTargetBlock() { public Location getSolidTargetBlock() {
//noinspection StatementWithEmptyBody //noinspection StatementWithEmptyBody
while (getNextBlock() != null && !solidMask.test(targetPos)) ; while (getNextBlock() != null && !solidMask.test(world, targetPos)) ;
return getCurrentBlock(); return getCurrentBlock();
} }

Datei anzeigen

@ -31,7 +31,10 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.extent.OutputExtent; import com.sk89q.worldedit.extent.OutputExtent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SingleBlockStateMask;
import com.sk89q.worldedit.function.pattern.FawePattern; import com.sk89q.worldedit.function.pattern.FawePattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.AbstractProperty;
@ -227,6 +230,10 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
return this.toBaseBlock(); return this.toBaseBlock();
} }
public Mask toMask() {
return new SingleBlockStateMask(new NullExtent(), this);
}
@Override @Override
public void applyTileEntity(OutputExtent output, int x, int y, int z) { public void applyTileEntity(OutputExtent output, int x, int y, int z) {

Datei anzeigen

@ -103,7 +103,7 @@ public class SnapshotRestore {
} }
private void checkAndAddBlock(BlockVector3 pos) { private void checkAndAddBlock(BlockVector3 pos) {
if (editSession.getMask() != null && !editSession.getMask().test(pos)) if (editSession.getMask() != null && !editSession.getMask().test(editSession, pos))
return; return;
BlockVector2 chunkPos = ChunkStore.toChunk(pos); BlockVector2 chunkPos = ChunkStore.toChunk(pos);