From de199a0e59aa8e4fe827022a06c9c054702e51d3 Mon Sep 17 00:00:00 2001 From: Matt <4009945+MattBDev@users.noreply.github.com> Date: Fri, 11 Sep 2020 15:13:31 -0400 Subject: [PATCH] More work on masks (#607) * Add a #air mask, the opposite of #existing (#1511) (cherry picked from commit 84fa2bbbc63de7bece01f41c0d5cb7d85cf129e6) * Remove unused methods in Mask.java * Remove `test(Extent, BlockVector3)` from Masks. This was a poorly planned idea. This should save some memory too. Authored-by: Matthew Miller --- .../implementation/filter/MaskFilter.java | 2 +- .../boydti/fawe/function/mask/XAxisMask.java | 2 +- .../boydti/fawe/function/mask/YAxisMask.java | 2 +- .../boydti/fawe/function/mask/ZAxisMask.java | 5 ++- .../fawe/object/brush/CopyPastaBrush.java | 13 ++++---- .../boydti/fawe/object/brush/ImageBrush.java | 4 +-- .../boydti/fawe/object/brush/LayerBrush.java | 9 +++--- .../fawe/object/brush/RecurseBrush.java | 4 +-- .../fawe/object/brush/ScatterBrush.java | 13 ++++---- .../object/brush/ScatterOverlayBrush.java | 2 +- .../fawe/object/brush/ShatterBrush.java | 2 +- .../fawe/object/brush/SplatterBrush.java | 5 ++- .../boydti/fawe/object/brush/SplineBrush.java | 1 - .../fawe/object/brush/StencilBrush.java | 5 ++- .../fawe/object/brush/SurfaceSphereBrush.java | 2 +- .../cfi/HeightMapMCAGenerator.java | 30 +++++++++--------- .../fawe/object/extent/SourceMaskExtent.java | 13 ++------ .../function/mask/AbstractDelegateMask.java | 11 ------- .../fawe/object/mask/AdjacentAnyMask.java | 18 +++++------ .../boydti/fawe/object/mask/AdjacentMask.java | 15 +++++---- .../boydti/fawe/object/mask/AngleMask.java | 24 +++++++------- .../boydti/fawe/object/mask/CachedMask.java | 13 ++++---- .../com/boydti/fawe/object/mask/DataMask.java | 6 ++-- .../boydti/fawe/object/mask/IdDataMask.java | 6 ++-- .../com/boydti/fawe/object/mask/IdMask.java | 6 ++-- .../fawe/object/mask/MaskedTargetBlock.java | 2 +- .../boydti/fawe/object/mask/PlaneMask.java | 3 +- .../boydti/fawe/object/mask/RadiusMask.java | 3 +- .../boydti/fawe/object/mask/RandomMask.java | 3 +- .../boydti/fawe/object/mask/SimplexMask.java | 3 +- .../boydti/fawe/object/mask/SurfaceMask.java | 4 +-- .../com/boydti/fawe/object/mask/WallMask.java | 11 +++---- .../fawe/object/pattern/MaskedPattern.java | 2 +- .../fawe/object/regions/FuzzyRegion.java | 2 +- .../com/boydti/fawe/util/TextureUtil.java | 2 +- .../java/com/sk89q/worldedit/EditSession.java | 20 ++++++------ .../extension/factory/MaskFactory.java | 16 +++++++--- .../factory/parser/mask/AirMaskParser.java | 27 ++++++++++++++-- .../factory/parser/mask/ZAxisMaskParser.java | 2 +- .../com/sk89q/worldedit/extent/Extent.java | 14 ++++----- .../sk89q/worldedit/extent/MaskingExtent.java | 8 ++--- .../worldedit/extent/buffer/ExtentBuffer.java | 2 +- .../extent/buffer/ForgetfulExtentBuffer.java | 6 ++-- .../function/RegionMaskTestFunction.java | 3 +- .../function/RegionMaskingFilter.java | 2 +- .../worldedit/function/block/Naturalizer.java | 4 +-- .../worldedit/function/generator/OreGen.java | 4 +-- .../function/generator/SchemGen.java | 2 +- .../worldedit/function/mask/ABlockMask.java | 4 +-- .../function/mask/AbstractExtentMask.java | 10 ------ .../worldedit/function/mask/AbstractMask.java | 4 +-- .../worldedit/function/mask/BiomeMask2D.java | 2 +- .../function/mask/BlockCategoryMask.java | 6 ++-- .../worldedit/function/mask/BlockMask.java | 4 +-- .../function/mask/BlockStateMask.java | 6 ++-- .../function/mask/BlockTypeMask.java | 4 +-- .../function/mask/BoundedHeightMask.java | 3 +- .../function/mask/DelegateExtentMask.java | 15 +-------- .../function/mask/ExistingBlockMask.java | 4 +-- .../function/mask/ExpressionMask.java | 3 +- .../function/mask/ExpressionMask2D.java | 3 +- .../worldedit/function/mask/InverseMask.java | 5 ++- .../mask/InverseSingleBlockStateMask.java | 4 +-- .../mask/InverseSingleBlockTypeMask.java | 6 ---- .../sk89q/worldedit/function/mask/Mask.java | 31 ++----------------- .../sk89q/worldedit/function/mask/Mask2D.java | 15 +-------- .../function/mask/MaskIntersection.java | 5 ++- .../function/mask/MaskIntersection2D.java | 5 ++- .../worldedit/function/mask/MaskUnion.java | 5 ++- .../worldedit/function/mask/MaskUnion2D.java | 5 ++- .../sk89q/worldedit/function/mask/Masks.java | 29 ++++++----------- .../worldedit/function/mask/NoiseFilter.java | 3 +- .../function/mask/NoiseFilter2D.java | 3 +- .../worldedit/function/mask/OffsetMask.java | 7 ++--- .../worldedit/function/mask/OffsetMask2D.java | 5 ++- .../worldedit/function/mask/RegionMask.java | 3 +- .../function/mask/SingleBlockStateMask.java | 4 +-- .../world/snapshot/SnapshotRestore.java | 2 +- 78 files changed, 232 insertions(+), 331 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java index c911bb1eb..524ce1707 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java @@ -33,7 +33,7 @@ public class MaskFilter extends DelegateFilter { @Override public void applyBlock(FilterBlock block) { - if (mask.test(block, block)) { + if (mask.test(block)) { getParent().applyBlock(block); this.changes++; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/function/mask/XAxisMask.java b/worldedit-core/src/main/java/com/boydti/fawe/function/mask/XAxisMask.java index dbee08f69..92bf88390 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/function/mask/XAxisMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/function/mask/XAxisMask.java @@ -14,7 +14,7 @@ public class XAxisMask extends AbstractMask implements ResettableMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { if (layer == -1) { layer = vector.getBlockX(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/function/mask/YAxisMask.java b/worldedit-core/src/main/java/com/boydti/fawe/function/mask/YAxisMask.java index 3eff19eb2..2a55b8de0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/function/mask/YAxisMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/function/mask/YAxisMask.java @@ -13,7 +13,7 @@ public class YAxisMask extends AbstractMask implements ResettableMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { if (layer == -1) { layer = vector.getBlockY(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/function/mask/ZAxisMask.java b/worldedit-core/src/main/java/com/boydti/fawe/function/mask/ZAxisMask.java index 7f584c3ca..dd910546c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/function/mask/ZAxisMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/function/mask/ZAxisMask.java @@ -1,7 +1,6 @@ package com.boydti.fawe.function.mask; import com.boydti.fawe.object.mask.ResettableMask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.math.BlockVector3; @@ -9,11 +8,11 @@ public class ZAxisMask extends AbstractMask implements ResettableMask { private transient int layer = -1; - public ZAxisMask(Extent extent) { + public ZAxisMask() { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { if (layer == -1) { layer = vector.getBlockZ(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java index 97e59b4f6..8dce2d4a0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java @@ -4,14 +4,13 @@ import com.boydti.fawe.config.Caption; import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder; import com.boydti.fawe.object.function.NullRegionFunction; +import com.boydti.fawe.object.function.mask.AbstractDelegateMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.function.mask.DelegateExtentMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.operation.Operation; @@ -67,11 +66,11 @@ public class CopyPastaBrush implements Brush, ResettableTool { } final ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld()); final int minY = position.getBlockY(); - mask = new DelegateExtentMask(editSession, mask) { + mask = new AbstractDelegateMask(mask) { @Override - public boolean test(Extent extent, BlockVector3 vector) { - if (super.test(extent, vector) && vector.getBlockY() >= minY) { - BaseBlock block = vector.getFullBlock(editSession); + public boolean test(BlockVector3 vector) { + if (super.test(vector) && vector.getBlockY() >= minY) { + BaseBlock block = editSession.getFullBlock(vector); if (!block.getBlockType().getMaterial().isAir()) { builder.add(vector, BlockTypes.AIR.getDefaultState().toBaseBlock(), block); return true; @@ -81,7 +80,7 @@ public class CopyPastaBrush implements Brush, ResettableTool { } }; // Add origin - mask.test(editSession, position); + mask.test(position); RecursiveVisitor visitor = new RecursiveVisitor(mask, new NullRegionFunction(), (int) size); visitor.visit(position); Operations.completeBlindly(visitor); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java index 78100c955..57269d0a7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java @@ -88,8 +88,8 @@ public class ImageBrush implements Brush { RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { private final MutableVector3 mutable = new MutableVector3(); @Override - public boolean test(Extent extent, BlockVector3 vector) { - if (solid.test(extent, vector)) { + public boolean test(BlockVector3 vector) { + if (solid.test(vector)) { int dx = vector.getBlockX() - cx; int dy = vector.getBlockY() - cy; int dz = vector.getBlockZ() - cz; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java index 284be6fd6..5b3fa03e3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java @@ -6,7 +6,6 @@ import com.boydti.fawe.object.mask.RadiusMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.command.tool.brush.Brush; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.Mask; @@ -39,8 +38,8 @@ public class LayerBrush implements Brush { final RadiusMask radius = new RadiusMask(0, (int) size); visitor = new RecursiveVisitor(new Mask() { @Override - public boolean test(Extent extent, BlockVector3 vector) { - return solid.test(extent, vector) && radius.test(extent, vector) && adjacent.test(extent, vector); + public boolean test(BlockVector3 vector) { + return solid.test(vector) && radius.test(vector) && adjacent.test(vector); } }, function -> true); visitor.visit(position); @@ -49,7 +48,7 @@ public class LayerBrush implements Brush { BlockVectorSet visited = visitor.getVisited(); visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { @Override - public boolean test(Extent extent, BlockVector3 pos) { + public boolean test(BlockVector3 pos) { int depth = visitor.getDepth() + 1; if (depth > 1) { boolean found = false; @@ -71,7 +70,7 @@ public class LayerBrush implements Brush { return false; } } - return !adjacent.test(extent, pos); + return !adjacent.test(pos); } }, pos -> { int depth = visitor.getDepth(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RecurseBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RecurseBrush.java index 914eb602e..2f5f60e59 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RecurseBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RecurseBrush.java @@ -27,8 +27,6 @@ public class RecurseBrush implements Brush { Mask mask = editSession.getMask(); if (mask == null) { mask = Masks.alwaysTrue(); - } else { - mask = mask.withExtent(editSession); } final int radius = (int) size; BlockState block = editSession.getBlock(position); @@ -44,7 +42,7 @@ public class RecurseBrush implements Brush { @Override public boolean isVisitable(BlockVector3 from, BlockVector3 to) { int y = to.getBlockY(); - return y < maxY && radMask.test(editSession, to) && super.isVisitable(from, to); + return y < maxY && radMask.test(to) && super.isVisitable(from, to); } }; visitor.visit(position); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterBrush.java index f8d33e8a7..8fe6680fc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterBrush.java @@ -8,7 +8,6 @@ import com.boydti.fawe.object.mask.SurfaceMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.command.tool.brush.Brush; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.MaskIntersection; import com.sk89q.worldedit.function.mask.Masks; @@ -52,7 +51,7 @@ public class ScatterBrush implements Brush { final int distance = Math.min((int) size, this.distance); - RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(radius, surface).withExtent(editSession), function -> true); + RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(radius, surface), function -> true); visitor.visit(position); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); Operations.completeBlindly(visitor); @@ -67,7 +66,7 @@ public class ScatterBrush implements Brush { for (int i = 0; i < count; i++) { int index = ThreadLocalRandom.current().nextInt(length); BlockVector3 pos = visited.get(index); - if (pos != null && canApply(editSession, pos)) { + if (pos != null && canApply(pos)) { int x = pos.getBlockX(); int y = pos.getBlockY(); int z = pos.getBlockZ(); @@ -88,12 +87,12 @@ public class ScatterBrush implements Brush { public void finish(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pos, Pattern pattern, double size) { } - public boolean canApply(EditSession editSession, BlockVector3 pos) { - return mask.test(editSession, pos); + public boolean canApply(BlockVector3 pos) { + return mask.test(pos); } - public BlockVector3 getDirection(Extent extent, BlockVector3 pt) { - return surface.direction(extent, pt); + public BlockVector3 getDirection(BlockVector3 pt) { + return surface.direction(pt); } public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws MaxChangedBlocksException { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterOverlayBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterOverlayBrush.java index 96d003a2b..72ce8a9e8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterOverlayBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterOverlayBrush.java @@ -16,7 +16,7 @@ public class ScatterOverlayBrush extends ScatterBrush { int x = pt.getBlockX(); int y = pt.getBlockY(); int z = pt.getBlockZ(); - BlockVector3 dir = getDirection(editSession, pt); + BlockVector3 dir = getDirection(pt); editSession.setBlock(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ(), p); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java index 903d4f80e..aab7bd8be 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java @@ -76,7 +76,7 @@ public class ShatterBrush extends ScatterBrush { int dSqr = (dx * dx) + (dy * dy) + (dz * dz); if (dSqr <= radius2) { BlockVector3 bv = mutable.setComponents(x2, y2, z2); - if (surfaceTest.test(editSession, bv) && finalMask.test(editSession, bv)) { + if (surfaceTest.test(bv) && finalMask.test( bv)) { // (collision) If it's visited and part of another frontier, set the block if (!placed.add(x2, y2, z2)) { if (!frontierVisited.contains(x2, y2, z2)) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java index 16927212d..1143937a8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java @@ -4,7 +4,6 @@ import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.mask.SurfaceMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; @@ -38,10 +37,10 @@ public class SplatterBrush extends ScatterBrush { RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { double dist = vector.distanceSq(position); if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2 - && surface.test(extent, vector)) { + && surface.test(vector)) { placed.add(vector); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java index 9e750d140..8097f2104 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java @@ -53,7 +53,6 @@ public class SplineBrush implements Brush, ResettableTool { } else { mask = new MaskIntersection(mask, new IdMask(editSession)); } - mask = mask.withExtent(editSession); boolean visualization = editSession.getExtent() instanceof VisualExtent; if (visualization && positionSets.isEmpty()) { return; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java index 281cada71..08d5adefb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java @@ -4,7 +4,6 @@ import com.boydti.fawe.object.brush.heightmap.HeightMap; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.SolidBlockMask; @@ -48,7 +47,7 @@ public class StencilBrush extends HeightBrush { map.setSize(size); int cutoff = onlyWhite ? maxY : 0; final SolidBlockMask solid = new SolidBlockMask(editSession); - + Location loc = editSession.getPlayer().getLocation(); float yaw = loc.getYaw(); float pitch = loc.getPitch(); @@ -58,7 +57,7 @@ public class StencilBrush extends HeightBrush { RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { private final MutableVector3 mutable = new MutableVector3(); @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { if (solid.test(vector)) { int dx = vector.getBlockX() - cx; int dy = vector.getBlockY() - cy; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSphereBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSphereBrush.java index 6a32c5d92..5fd3b6cf3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSphereBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSphereBrush.java @@ -21,7 +21,7 @@ public class SurfaceSphereBrush implements Brush { SurfaceMask surface = new SurfaceMask(editSession); final SolidBlockMask solid = new SolidBlockMask(editSession); final RadiusMask radius = new RadiusMask(0, (int) size); - RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(surface, radius).withExtent(editSession), vector -> editSession.setBlock(vector, pattern)); + RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(surface, radius), vector -> editSession.setBlock(vector, pattern)); visitor.visit(position); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); Operations.completeBlindly(visitor); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java index c357922ce..40c11a8d6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java @@ -579,7 +579,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights[index] & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(this, mutable)) { + if (mask.test(mutable)) { int newHeight = table.average(x, z, index); setLayerHeightRaw(index, newHeight); } @@ -641,7 +641,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } mutable.mutX(x); mutable.mutY(y); - if (!mask.test(this, mutable)) { + if (!mask.test(mutable)) { continue; } if (placed.containsRadius(x, z, distance)) { @@ -691,7 +691,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } mutable.mutX(x); mutable.mutY(y); - if (!mask.test(this, mutable)) { + if (!mask.test(mutable)) { continue; } if (placed.containsRadius(x, z, distance)) { @@ -1151,7 +1151,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (mask != null) { mutable.mutX(z); mutable.mutY(heights.getByte(index) & 0xFF); - if (!mask.test(this, mutable)) { + if (!mask.test(mutable)) { continue; } } @@ -1281,7 +1281,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr for (int x = 0; x < getWidth(); x++, index++) { mutable.mutX(x); mutable.mutY(heights.getByte(index) & 0xFF); - if (mask.test(this, mutable)) { + if (mask.test(mutable)) { int color = img.getRGB(x, z); BlockType block = textureUtil.getNearestBlock(color); if (block != null) { @@ -1358,7 +1358,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(this, mutable)) { + if (mask.test(mutable)) { biomes.setByte(index, biomeByte); } } @@ -1501,7 +1501,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr for (int z = 0; z < getLength(); z++) { for (int x = 0; x < getWidth(); x++, index++) { filter.init(x, z, index); - if (mask.test(this, filter)) { + if (mask.test(filter)) { pattern.apply(this, filter, filter); } } @@ -1522,7 +1522,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr for (int z = 0; z < getLength(); z++) { for (int x = 0; x < getWidth(); x++, index++) { filter.init(x, z, index); - if (mask.test(this, filter)) { + if (mask.test(filter)) { pattern.apply(this, filter, filter); } } @@ -1542,7 +1542,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int index = 0; for (int z = 0; z < getLength(); z++) { for (int x = 0; x < getWidth(); x++, index++) { - if (mask.test(this, filter)) { + if (mask.test(filter)) { pattern.apply(this, filter, filter); } } @@ -1566,10 +1566,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr for (int x = 0; x < getWidth(); x++, index++) { floorFilter.init(x, z, index); mainFilter.init(x, z, index); - if (mask.test(this, mainFilter)) { + if (mask.test(mainFilter)) { pattern.apply(this, mainFilter, mainFilter); } - if (mask.test(this, floorFilter)) { + if (mask.test(floorFilter)) { pattern.apply(this, floorFilter, floorFilter); } } @@ -1887,7 +1887,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(this, mutable)) { + if (mask.test(mutable)) { overlay.setInt(index, combined); } } @@ -1902,7 +1902,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(this, mutable)) { + if (mask.test(mutable)) { floor.setInt(index, combined); } } @@ -1918,7 +1918,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(this, mutable)) { + if (mask.test(mutable)) { main.setInt(index, combined); } } @@ -1934,7 +1934,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(this, mutable)) { + if (mask.test(mutable)) { floor.setInt(index, combined); main.setInt(index, combined); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java index 0e2558247..e642cf8e2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java @@ -11,18 +11,11 @@ import static com.google.common.base.Preconditions.checkNotNull; public class SourceMaskExtent extends TemporalExtent { private Mask mask; - private Extent get; private MutableBlockVector3 mutable = new MutableBlockVector3(); public SourceMaskExtent(Extent extent, Mask mask) { - this(extent, extent, mask); - } - - public SourceMaskExtent(Extent get, Extent set, Mask mask) { - super(set); - checkNotNull(get); + super(extent); checkNotNull(mask); - this.get = get; this.mask = mask; } @@ -48,7 +41,7 @@ public class SourceMaskExtent extends TemporalExtent { @Override public > boolean setBlock(BlockVector3 location, T block) throws WorldEditException { set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block); - return mask.test(get, location) && super.setBlock(location, block); + return mask.test(location) && super.setBlock(location, block); } @Override @@ -57,6 +50,6 @@ public class SourceMaskExtent extends TemporalExtent { mutable.mutX(x); mutable.mutY(y); mutable.mutZ(z); - return mask.test(get, mutable) && super.setBlock(x, y, z, block); + return mask.test(mutable) && super.setBlock(x, y, z, block); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/function/mask/AbstractDelegateMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/function/mask/AbstractDelegateMask.java index d8856a751..d18db85ba 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/function/mask/AbstractDelegateMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/function/mask/AbstractDelegateMask.java @@ -1,6 +1,5 @@ package com.boydti.fawe.object.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask2D; @@ -25,20 +24,10 @@ public class AbstractDelegateMask extends AbstractMask { return mask.test(vector); } - @Override - public boolean test(Extent extent, BlockVector3 pos) { - return mask.test(extent, pos); - } - @Nullable @Override public Mask2D toMask2D() { return mask.toMask2D(); } - @Override - public Mask withExtent(Extent extent) { - mask.withExtent(extent); - return this; - } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java index e0536347d..5ee452445 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java @@ -29,25 +29,25 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask { } @Override - public boolean test(Extent extent, BlockVector3 v) { - return direction(extent, v) != null; + public boolean test(BlockVector3 v) { + return direction(v) != null; } - public BlockVector3 direction(Extent extent, BlockVector3 v) { + public BlockVector3 direction(BlockVector3 v) { int x = v.getBlockX(); int y = v.getBlockY(); int z = v.getBlockZ(); - if (mask.test(extent, x + 1, y, z)) { + if (mask.test(x + 1, y, z)) { return mutable.setComponents(1, 0, 0); - } else if (mask.test(extent, x - 1, y, z)) { + } else if (mask.test(x - 1, y, z)) { return mutable.setComponents(-1, 0, 0); - } else if (mask.test(extent, x, y, z + 1)) { + } else if (mask.test(x, y, z + 1)) { return mutable.setComponents(0, 0, 1); - } else if (mask.test(extent, x, y, z - 1)) { + } else if (mask.test(x, y, z - 1)) { return mutable.setComponents(0, 0, -1); - } else if (y < 256 && mask.test(extent, x, y + 1, z)) { + } else if (y < 256 && mask.test(x, y + 1, z)) { return mutable.setComponents(0, 1, 0); - } else if (y > 0 && mask.test(extent, x, y - 1, z)) { + } else if (y > 0 && mask.test(x, y - 1, z)) { return mutable.setComponents(0, -1, 0); } else { return null; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java index bc7c70c4d..499cb7893 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java @@ -1,6 +1,5 @@ package com.boydti.fawe.object.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; @@ -20,41 +19,41 @@ public class AdjacentMask extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 bv) { + public boolean test(BlockVector3 bv) { vector.setComponents(bv); double x = bv.getX(); double y = bv.getY(); double z = bv.getZ(); vector.mutX(x + 1); int count = 0; - if (mask.test(extent, vector) && ++count == min && max >= 8) { + if (mask.test(vector) && ++count == min && max >= 8) { vector.mutX(x); return true; } vector.mutX(x - 1); - if (mask.test(extent, vector) && ++count == min && max >= 8) { + if (mask.test(vector) && ++count == min && max >= 8) { vector.mutX(x); return true; } vector.mutX(x); vector.mutY(y + 1); - if (mask.test(extent, vector) && ++count == min && max >= 8) { + if (mask.test(vector) && ++count == min && max >= 8) { vector.mutY(y); return true; } vector.mutY(y - 1); - if (mask.test(extent, vector) && ++count == min && max >= 8) { + if (mask.test(vector) && ++count == min && max >= 8) { vector.mutY(y); return true; } vector.mutY(y); vector.mutZ(z + 1); - if (mask.test(extent, vector) && ++count == min && max >= 8) { + if (mask.test(vector) && ++count == min && max >= 8) { vector.mutZ(z); return true; } vector.mutZ(z - 1); - if (mask.test(extent, vector) && ++count == min && max >= 8) { + if (mask.test(vector) && ++count == min && max >= 8) { vector.mutZ(z); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java index 4d5fba6bb..123afcd2d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java @@ -124,53 +124,53 @@ public class AngleMask extends SolidBlockMask implements ResettableMask { } } - public boolean adjacentAir(Extent extent, BlockVector3 v) { + public boolean adjacentAir(BlockVector3 v) { int x = v.getBlockX(); int y = v.getBlockY(); int z = v.getBlockZ(); - if (!mask.test(extent, x + 1, y, z)) { + if (!mask.test(x + 1, y, z)) { return true; } - if (!mask.test(extent, x - 1, y, z)) { + if (!mask.test(x - 1, y, z)) { return true; } - if (!mask.test(extent, x, y, z + 1)) { + if (!mask.test(x, y, z + 1)) { return true; } - if (!mask.test(extent, x, y, z - 1)) { + if (!mask.test(x, y, z - 1)) { return true; } - if (y < 255 && !mask.test(extent, x, y + 1, z)) { + if (y < 255 && !mask.test(x, y + 1, z)) { return true; } - if (y > 0 && !mask.test(extent, x, y - 1, z)) { + if (y > 0 && !mask.test(x, y - 1, z)) { return true; } return false; } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { int x = vector.getBlockX(); int y = vector.getBlockY(); int z = vector.getBlockZ(); if ((lastX == (lastX = x) & lastZ == (lastZ = z))) { - int height = getHeight(extent, x, y, z); + int height = getHeight(getExtent(), x, y, z); if (y <= height) { return overlay ? (lastValue && y == height) : lastValue; } } - if (!mask.test(extent, x, y, z)) { + if (!mask.test(x, y, z)) { return false; } if (overlay) { - if (y < 255 && !adjacentAir(extent, vector)) { + if (y < 255 && !adjacentAir(vector)) { return lastValue = false; } } - return testSlope(extent, x, y, z); + return testSlope(getExtent(), x, y, z); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java index 4afe9ca07..ec0b0d4ef 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java @@ -2,7 +2,6 @@ package com.boydti.fawe.object.mask; import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.function.mask.AbstractDelegateMask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; @@ -42,21 +41,21 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { - return test(extent, vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); + public boolean test(BlockVector3 vector) { + return test(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); } - public boolean test(Extent extent, int x, int y, int z) { + public boolean test(int x, int y, int z) { try { boolean check = cache_checked.add(x, y, z); if (!check) { return cache_results.contains(x, y, z); } - boolean result = getMask().test(extent, mutable.setComponents(x, y, z)); + boolean result = getMask().test(mutable.setComponents(x, y, z)); if (result) cache_results.add(x, y, z); return result; - } catch (UnsupportedOperationException ignore) { - boolean result = getMask().test(extent, mutable.setComponents(x, y, z)); + } catch (UnsupportedOperationException ignored) { + boolean result = getMask().test(mutable.setComponents(x, y, z)); if (y < 0 || y > 255) return result; resetCache(); cache_checked.setOffset(x, z); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/DataMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/DataMask.java index 353c87fb0..d56ccd007 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/DataMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/DataMask.java @@ -13,11 +13,11 @@ public class DataMask extends AbstractExtentMask implements ResettableMask { private transient int data = -1; @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { if (data != -1) { - return extent.getBlock(vector).getInternalPropertiesId() == data; + return getExtent().getBlock(vector).getInternalPropertiesId() == data; } else { - data = extent.getBlock(vector).getInternalPropertiesId(); + data = getExtent().getBlock(vector).getInternalPropertiesId(); return true; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdDataMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdDataMask.java index d09750238..cd62830fb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdDataMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdDataMask.java @@ -12,11 +12,11 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { if (combined != -1) { - return extent.getBlock(vector).getInternalId() == combined; + return getExtent().getBlock(vector).getInternalId() == combined; } else { - combined = extent.getBlock(vector).getInternalId(); + combined = getExtent().getBlock(vector).getInternalId(); return true; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdMask.java index 5a55ad703..2a69c2a4a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdMask.java @@ -13,11 +13,11 @@ public class IdMask extends AbstractExtentMask implements ResettableMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { if (id != -1) { - return extent.getBlock(vector).getInternalBlockTypeId() == id; + return getExtent().getBlock(vector).getInternalBlockTypeId() == id; } else { - id = extent.getBlock(vector).getInternalBlockTypeId(); + id = getExtent().getBlock(vector).getInternalBlockTypeId(); return true; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/MaskedTargetBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/MaskedTargetBlock.java index f7b87aac7..88b94072e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/MaskedTargetBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/MaskedTargetBlock.java @@ -21,7 +21,7 @@ public class MaskedTargetBlock extends TargetBlock { Location lastBlock = null; while (getNextBlock() != null) { Location current = getCurrentBlock(); - if (!mask.test(world, current.toBlockPoint())) { + if (!mask.test(current.toBlockPoint())) { if (searchForLastBlock) { lastBlock = current; if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/PlaneMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/PlaneMask.java index 6b487d9ab..9628e20ce 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/PlaneMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/PlaneMask.java @@ -1,6 +1,5 @@ package com.boydti.fawe.object.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.math.BlockVector3; @@ -10,7 +9,7 @@ public class PlaneMask extends AbstractMask implements ResettableMask { private transient int originX = Integer.MAX_VALUE, originY = Integer.MAX_VALUE, originZ = Integer.MAX_VALUE; @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { switch (mode) { case -1: originX = vector.getBlockX(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RadiusMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RadiusMask.java index e5a6b2b42..fa3f94675 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RadiusMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RadiusMask.java @@ -1,6 +1,5 @@ package com.boydti.fawe.object.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.math.BlockVector3; @@ -20,7 +19,7 @@ public class RadiusMask extends AbstractMask implements ResettableMask { } @Override - public boolean test(Extent extent, BlockVector3 to) { + public boolean test(BlockVector3 to) { if (pos == null) { pos = to.toImmutable(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RandomMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RandomMask.java index 2b835700d..cff3dd6f7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RandomMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RandomMask.java @@ -1,6 +1,5 @@ package com.boydti.fawe.object.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.math.BlockVector3; @@ -16,7 +15,7 @@ public class RandomMask extends AbstractMask implements ResettableMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { return random.nextInt() <= threshold; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SimplexMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SimplexMask.java index 23658b595..9358552ca 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SimplexMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SimplexMask.java @@ -1,7 +1,6 @@ package com.boydti.fawe.object.mask; import com.boydti.fawe.object.random.SimplexNoise; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.math.BlockVector3; @@ -15,7 +14,7 @@ public class SimplexMask extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { double value = SimplexNoise.noise(vector.getBlockX() * scale, vector.getBlockY() * scale, vector.getBlockZ() * scale); return value >= min && value <= max; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SurfaceMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SurfaceMask.java index 9534be6dc..3cc468858 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SurfaceMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SurfaceMask.java @@ -19,7 +19,7 @@ public class SurfaceMask extends AdjacentAnyMask { } @Override - public boolean test(Extent extent, BlockVector3 v) { - return !getParentMask().test(extent, v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(extent, v); + public boolean test(BlockVector3 v) { + return !getParentMask().test(v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(v); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java index ca57027c9..83b2d110d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java @@ -1,6 +1,5 @@ package com.boydti.fawe.object.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; @@ -19,30 +18,30 @@ public class WallMask extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 bv) { + public boolean test(BlockVector3 bv) { v.setComponents(bv); int count = 0; double x = v.getX(); double y = v.getY(); double z = v.getZ(); v.mutX(x + 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x - 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x); v.mutZ(z + 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } v.mutZ(z - 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/MaskedPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/MaskedPattern.java index 0ff4e1761..de31735ce 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/MaskedPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/MaskedPattern.java @@ -30,7 +30,7 @@ public class MaskedPattern extends AbstractPattern { @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - if (mask.test(extent, get)) { + if (mask.test(get)) { return primary.apply(extent, get, set); } return secondary.apply(extent, get, set); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java index 1d0bd4d6b..ed672da39 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java @@ -42,7 +42,7 @@ public class FuzzyRegion extends AbstractRegion { } public void select(int x, int y, int z) { - RecursiveVisitor search = new RecursiveVisitor(mask.withExtent(extent), p -> { + RecursiveVisitor search = new RecursiveVisitor(mask, p -> { setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ()); return true; }, 256); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java index 877bc3a43..1cd7af233 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java @@ -376,7 +376,7 @@ public class TextureUtil implements TextureHolder { for (int typeId : tu.getValidBlockIds()) { BlockType block = BlockTypes.get(typeId); extent.init(0, 0, 0, block.getDefaultState().toBaseBlock()); - if (mask.test(extent, extent)) { + if (mask.test(extent)) { blocks.add(block); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 97f382248..b924b715b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -144,13 +144,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.sk89q.worldedit.regions.Regions.asFlatRegion; import static com.sk89q.worldedit.regions.Regions.maximumBlockY; import static com.sk89q.worldedit.regions.Regions.minimumBlockY; -import java.util.UUID; /** * An {@link Extent} that handles history, {@link BlockBag}s, change limits, @@ -804,7 +804,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { */ public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) { for (int y = maxY; y >= minY; --y) { - if (filter.test(getExtent(), mutablebv.setComponents(x, y, z))) { + if (filter.test(mutablebv.setComponents(x, y, z))) { return y; } } @@ -1135,7 +1135,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { if (direction.equals(BlockVector3.at(0, -1, 0))) { return fillXZ(origin, pattern, radius, depth, false); } - Mask mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this))).withExtent(getExtent()); + Mask mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this))); // Want to replace blocks final BlockReplace replace = new BlockReplace(EditSession.this, pattern); @@ -1187,7 +1187,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { new BoundedHeightMask( Math.max(origin.getBlockY() - depth + 1, getMinimumPoint().getBlockY()), Math.min(getMaxY(), origin.getBlockY())), - Masks.negate(new ExistingBlockMask(this))).withExtent(getExtent()); + Masks.negate(new ExistingBlockMask(this))); // Want to replace blocks BlockReplace replace = new BlockReplace(this, pattern); @@ -1399,7 +1399,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { } else { replaceBlocks(region, new Mask() { @Override - public boolean test(Extent extent, BlockVector3 position) { + public boolean test(BlockVector3 position) { int x = position.getBlockX(); int z = position.getBlockZ(); return !region.contains(x, z + 1) || !region.contains(x, z - 1) || !region @@ -1660,7 +1660,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { Mask mask = new MaskIntersection( new BoundedHeightMask(0, getWorld().getMaxY()), new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), - liquidMask).withExtent(getExtent()); + liquidMask); BlockReplace replace; if (waterlogged) { replace = new BlockReplace(this, new WaterloggedRemover(this)); @@ -1671,7 +1671,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { // Around the origin in a 3x3 block for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) { - if (mask.test(getExtent(), position)) { + if (mask.test(position)) { visitor.visit(position); } } @@ -1705,13 +1705,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())), new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), blockMask - ).withExtent(getExtent()); + ); BlockReplace replace = new BlockReplace(this, fluid.getDefaultState()); NonRisingVisitor visitor = new NonRisingVisitor(mask, replace); // Around the origin in a 3x3 block for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) { - if (liquidMask.test(getExtent(), position)) { + if (liquidMask.test(position)) { visitor.visit(position); } } @@ -2890,7 +2890,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { while (iter.hasNext()) { final BlockVector3 current = iter.next(); iter.remove(); - if (mask.test(getExtent(), current)) { + if (mask.test(current)) { continue; } if (!outside.add(current)) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java index 52ce3ba43..96192928a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java @@ -53,6 +53,8 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.MaskIntersection; import com.sk89q.worldedit.internal.registry.AbstractFactory; import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import java.util.ArrayList; import java.util.List; @@ -76,6 +78,7 @@ public final class MaskFactory extends AbstractFactory { super(worldEdit, new BlocksMaskParser(worldEdit)); register(new ExistingMaskParser(worldEdit)); + register(new AirMaskParser(worldEdit)); register(new SolidMaskParser(worldEdit)); register(new LazyRegionMaskParser(worldEdit)); register(new RegionMaskParser(worldEdit)); @@ -84,11 +87,11 @@ public final class MaskFactory extends AbstractFactory { register(new BlockStateMaskParser(worldEdit)); register(new NegateMaskParser(worldEdit)); register(new ExpressionMaskParser(worldEdit)); + register(new BlockCategoryMaskParser(worldEdit)); register(new BiomeMaskParser(worldEdit)); // Mask Parsers from FAWE register(new AdjacentMaskParser(worldEdit)); - register(new AirMaskParser(worldEdit)); register(new AngleMaskParser(worldEdit)); register(new ExtremaMaskParser(worldEdit)); register(new FalseMaskParser(worldEdit)); @@ -124,18 +127,23 @@ public final class MaskFactory extends AbstractFactory { continue; } + Mask match = null; for (InputParser parser : getParsers()) { - Mask match = parser.parseFromInput(component, context); + match = parser.parseFromInput(component, context); if (match != null) { - masks.add(match); + break; } } + if (match == null) { + throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(component))); + } + masks.add(match); } switch (masks.size()) { case 0: - throw new NoMatchException("No match for '" + input + "'"); + throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(input))); case 1: return masks.get(0).optimize(); default: diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AirMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AirMaskParser.java index ec2059129..43913f7db 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AirMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AirMaskParser.java @@ -1,10 +1,31 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package com.sk89q.worldedit.extension.factory.parser.mask; -import com.boydti.fawe.function.mask.AirMask; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.internal.registry.SimpleInputParser; import java.util.List; @@ -23,7 +44,7 @@ public class AirMaskParser extends SimpleInputParser { } @Override - public Mask parseFromSimpleInput(String input, ParserContext context) { - return new AirMask(context.getExtent()); + public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException { + return Masks.negate(new ExistingBlockMask(context.requireExtent())); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ZAxisMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ZAxisMaskParser.java index f6a739a51..8d37d0c47 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ZAxisMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ZAxisMaskParser.java @@ -43,6 +43,6 @@ public class ZAxisMaskParser extends SimpleInputParser { @Override public Mask parseFromSimpleInput(String input, ParserContext context) { - return new ZAxisMask(context.getExtent()); + return new ZAxisMask(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index c2ef68b73..d74c32475 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -206,7 +206,7 @@ public interface Extent extends InputExtent, OutputExtent { maxY = Math.min(maxY, Math.max(0, maxY)); minY = Math.max(0, minY); for (int y = maxY; y >= minY; --y) { - if (filter.test(this, MutableBlockVector3.get(x, y, z))) { + if (filter.test(MutableBlockVector3.get(x, y, z))) { return y; } } @@ -276,22 +276,22 @@ public interface Extent extends InputExtent, OutputExtent { int clearanceAbove = maxY - y; int clearanceBelow = y - minY; int clearance = Math.min(clearanceAbove, clearanceBelow); - boolean state = !mask.test(this, MutableBlockVector3.get(x, y, z)); + boolean state = !mask.test(MutableBlockVector3.get(x, y, z)); int offset = state ? 0 : 1; for (int d = 0; d <= clearance; d++) { int y1 = y + d; - if (mask.test(this, MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset; + if (mask.test(MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset; int y2 = y - d; - if (mask.test(this, MutableBlockVector3.get(x, y2, z)) != state) return y2 + offset; + if (mask.test(MutableBlockVector3.get(x, y2, z)) != state) return y2 + offset; } if (clearanceAbove != clearanceBelow) { if (clearanceAbove < clearanceBelow) { for (int layer = y - clearance - 1; layer >= minY; layer--) { - if (mask.test(this, MutableBlockVector3.get(x, layer, z)) != state) return layer + offset; + if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer + offset; } } else { for (int layer = y + clearance + 1; layer <= maxY; layer++) { - if (mask.test(this, MutableBlockVector3.get(x, layer, z)) != state) return layer - offset; + if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer - offset; } } } @@ -508,7 +508,7 @@ public interface Extent extends InputExtent, OutputExtent { * @return the number of blocks that matched the mask */ default int countBlocks(Region region, Mask searchMask) { - RegionVisitor visitor = new RegionVisitor(region, position -> searchMask.test(this, position)); + RegionVisitor visitor = new RegionVisitor(region, position -> searchMask.test(position)); Operations.completeBlindly(visitor); return visitor.getAffected(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java index 397367c0f..294bae88e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java @@ -79,17 +79,17 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce @Override public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { - return mask.test(getExtent(), location) && super.setBlock(location, block); + return mask.test(location) && super.setBlock(location, block); } @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { - return mask.test(getExtent(), position.toBlockVector3()) && super.setBiome(position, biome); + return mask.test(position.toBlockVector3()) && super.setBiome(position, biome); } @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { - return mask.test(getExtent(), BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome); + return mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome); } @Override @@ -102,7 +102,7 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce public void applyBlock(FilterBlock block) { //TODO: Find a way to make masking thread safe without having to synchonise the whole extent synchronized (this) { - if (!mask.test(getExtent(), block)) { + if (!mask.test(block)) { block.setOrdinal(0); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java index a83b47a32..8efd8615f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java @@ -75,7 +75,7 @@ public class ExtentBuffer extends AbstractBufferingExtent { @Override public > boolean setBlock(BlockVector3 location, T block) throws WorldEditException { - if (mask.test(getExtent(), location)) { + if (mask.test(location)) { buffer.put(location, block.toBaseBlock()); return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java index fd528f29f..412f549a4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java @@ -107,7 +107,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat max = max.getMaximum(location); } - if (mask.test(getExtent(), location)) { + if (mask.test( location)) { buffer.put(location, block.toBaseBlock()); return true; } else { @@ -131,7 +131,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat max2d = max2d.getMaximum(position); } - if (biomeMask.test(getExtent(), position)) { + if (biomeMask.test(position)) { biomeBuffer.put(position, biome); return true; } else { @@ -155,7 +155,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat max2d = max2d.getMaximum(BlockVector2.at(x,z)); } - if (biomeMask.test(getExtent(), BlockVector2.at(x,z))) { + if (biomeMask.test(BlockVector2.at(x,z))) { biomeBuffer.put(BlockVector2.at(x,z), biome); return true; } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java index 1f656d65e..462c1eb35 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.function; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; @@ -53,7 +52,7 @@ public class RegionMaskTestFunction implements RegionFunction { @Override public boolean apply(BlockVector3 position) throws WorldEditException { - if (mask.test(NullExtent.INSTANCE, position)) { + if (mask.test(position)) { return pass.apply(position); } else { return fail.apply(position); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java index 1ddfe8e95..8246115f6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java @@ -54,7 +54,7 @@ public class RegionMaskingFilter implements RegionFunction { @Override public boolean apply(BlockVector3 position) throws WorldEditException { - return mask.test(extent, position) && function.apply(position); + return mask.test(position) && function.apply(position); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java index 387480d15..1c2d73884 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java @@ -63,7 +63,7 @@ public class Naturalizer implements LayerFunction { @Override public boolean isGround(BlockVector3 position) { - return mask.test(editSession, position); + return mask.test(position); } private BlockState getTargetBlock(int depth) { @@ -95,7 +95,7 @@ public class Naturalizer implements LayerFunction { @Override public boolean apply(BlockVector3 position, int depth) throws WorldEditException { - if (mask.test(editSession, position)) { + if (mask.test(position)) { if (naturalize(position, depth)) { ++affected; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/OreGen.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/OreGen.java index d8d46f8a8..f544de178 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/OreGen.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/OreGen.java @@ -42,7 +42,7 @@ public class OreGen implements Resource { @Override public boolean spawn(Random rand, int x, int z) throws WorldEditException { int y = rand.nextInt(maxY - minY) + minY; - if (!mask.test(extent, mutable.setComponents(x, y, z))) { + if (!mask.test(mutable.setComponents(x, y, z))) { return false; } double f = rand.nextDouble() * Math.PI; @@ -102,7 +102,7 @@ public class OreGen implements Resource { double dz = (zz + 0.5D - d9) * id11o2; double dxyz2 = dxy2 + dz * dz; if ((dxyz2 < 1)) { - if (mask.test(extent, mutable)) + if (mask.test(mutable)) pattern.apply(extent, mutable, mutable); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java index 598a219fd..b0596201a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java @@ -36,7 +36,7 @@ public class SchemGen implements Resource { int y = extent.getNearestSurfaceTerrainBlock(x, z, mutable.getBlockY(), 0, 255); if (y == -1) return false; mutable.mutY(y); - if (!mask.test(extent, mutable)) { + if (!mask.test(mutable)) { return false; } mutable.mutY(y + 1); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java index b1bb9aaee..a37946a17 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java @@ -15,8 +15,8 @@ public abstract class ABlockMask extends AbstractExtentMask { super(extent); } - @Override public boolean test(Extent extent, BlockVector3 vector) { - return test(vector.getBlock(extent)); + @Override public boolean test(BlockVector3 vector) { + return test(getExtent().getBlock(vector)); } public abstract boolean test(BlockState state); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java index 0b690b309..7c9192c0c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.function.mask; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector3; import static com.google.common.base.Preconditions.checkNotNull; @@ -40,10 +39,6 @@ public abstract class AbstractExtentMask extends AbstractMask { setExtent(extent); } - @Override - public boolean test(BlockVector3 vector) { - return test(getExtent(), vector); - } /** * Get the extent. @@ -64,9 +59,4 @@ public abstract class AbstractExtentMask extends AbstractMask { this.extent = extent; } - @Override - public Mask withExtent(Extent extent) { - setExtent(extent); - return this; - } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractMask.java index 94376e5f7..c14ce3862 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractMask.java @@ -19,11 +19,9 @@ package com.sk89q.worldedit.function.mask; -import java.io.Serializable; - /** * A base class of {@link Mask} that all masks should inherit from. */ -public abstract class AbstractMask implements Mask, Serializable { +public abstract class AbstractMask implements Mask { } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java index 08ea454da..5df46facb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java @@ -93,7 +93,7 @@ public class BiomeMask2D extends AbstractMask2D { } @Override - public boolean test(Extent extent, BlockVector2 vector) { + public boolean test(BlockVector2 vector) { BiomeType biome = extent.getBiome(vector); return biomes.contains(biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java index 77ae4d34c..671f71acd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java @@ -32,7 +32,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class BlockCategoryMask extends AbstractExtentMask { - private BlockCategory category; + private final BlockCategory category; public BlockCategoryMask(Extent extent, BlockCategory category) { super(extent); @@ -42,8 +42,8 @@ public class BlockCategoryMask extends AbstractExtentMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { - return category.contains(vector.getBlock(extent)); + public boolean test(BlockVector3 vector) { + return category.contains(getExtent().getBlock(vector)); } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index dc9dbb664..b46ed64f7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -188,8 +188,8 @@ public class BlockMask extends ABlockMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { - int test = vector.getOrdinal(extent); + public boolean test(BlockVector3 vector) { + int test = getExtent().getBlock(vector).getOrdinal(); return ordinals[test] || replacesAir() && test == 0; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java index b999fdde4..485246917 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java @@ -36,7 +36,7 @@ public class BlockStateMask extends AbstractExtentMask { private final Map states; private final boolean strict; - private Map, Object>> cache = Maps.newHashMap(); + private final Map, Object>> cache = Maps.newHashMap(); /** * Creates a mask that checks if a given block has the desired properties set to the desired value. @@ -53,8 +53,8 @@ public class BlockStateMask extends AbstractExtentMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { - return test(vector.getBlock(extent)); + public boolean test(BlockVector3 vector) { + return test(getExtent().getBlock(vector)); } public boolean test(BlockState block) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java index e08364116..664739293 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java @@ -110,8 +110,8 @@ public class BlockTypeMask extends AbstractExtentMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { - return test(vector.getBlock(extent).getBlockType()); + public boolean test(BlockVector3 vector) { + return test(getExtent().getBlock(vector).getBlockType()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java index e67d6f8ad..10e969c79 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; @@ -48,7 +47,7 @@ public class BoundedHeightMask extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { return vector.getY() >= minY && vector.getY() <= maxY; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java index 78c765a4c..65fc2bb26 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java @@ -1,24 +1,11 @@ package com.sk89q.worldedit.function.mask; import com.boydti.fawe.object.function.mask.AbstractDelegateMask; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector3; public class DelegateExtentMask extends AbstractDelegateMask { - private final Extent extent; - public DelegateExtentMask(Extent extent, Mask parent) { + public DelegateExtentMask(Mask parent) { super(parent); - this.extent = extent; } - @Override - public boolean test(BlockVector3 vector) { - return super.test(extent, vector); - } - - @Override - public Mask withExtent(Extent extent) { - return new DelegateExtentMask(extent, getMask()); - } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java index f6b887b06..7619c15ff 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java @@ -40,8 +40,8 @@ public class ExistingBlockMask extends AbstractExtentMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { - return !vector.getBlock(extent).getMaterial().isAir(); + public boolean test(BlockVector3 vector) { + return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir(); } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java index 935ca89fa..cfffe2807 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; @@ -68,7 +67,7 @@ public class ExpressionMask extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { try { if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) { ((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java index d9dd19a4c..9c09a7430 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; @@ -61,7 +60,7 @@ public class ExpressionMask2D extends AbstractMask2D { } @Override - public boolean test(Extent extent, BlockVector2 vector) { + public boolean test(BlockVector2 vector) { try { if (timeout == null) { return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java index 99bc0f869..ec8c037d5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java @@ -1,6 +1,5 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; @@ -13,8 +12,8 @@ public class InverseMask extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 pos) { - return !mask.test(extent, pos); + public boolean test(BlockVector3 pos) { + return !mask.test(pos); } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java index 18812adac..f27f9816e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java @@ -19,8 +19,8 @@ public class InverseSingleBlockStateMask extends ABlockMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { - int test = vector.getOrdinal(extent); + public boolean test(BlockVector3 vector) { + int test = getExtent().getBlock(vector).getOrdinal(); if (isAir && test == 0) { return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockTypeMask.java index 1009ca3ad..2fc3c8d52 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockTypeMask.java @@ -1,7 +1,6 @@ package com.sk89q.worldedit.function.mask; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -15,11 +14,6 @@ public class InverseSingleBlockTypeMask extends ABlockMask { this.internalId = type.getInternalId(); } - @Override - public boolean test(Extent extent, BlockVector3 vector) { - return test(vector.getBlock(extent)); - } - @Override public final boolean test(BlockState state) { return state.getBlockType().getInternalId() != internalId; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java index dd70786fb..3de7466c8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java @@ -22,10 +22,7 @@ package com.sk89q.worldedit.function.mask; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.implementation.filter.MaskFilter; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.session.request.Request; import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; @@ -41,26 +38,12 @@ public interface Mask { * @param vector the vector to test * @return true if the criteria is met */ - default boolean test(BlockVector3 vector) { - Extent extent = Request.request().getExtent(); - if (extent == null) { - extent = NullExtent.INSTANCE; - } - return test(extent, vector); - } - - default boolean test(Extent extent, BlockVector3 vector) { - return test(vector); - } + boolean test(BlockVector3 vector); default MaskFilter toFilter(T filter) { return new MaskFilter<>(filter, this); } - default Mask withExtent(Extent extent) { - return new DelegateExtentMask(extent, this); - } - /** * Get the 2D version of this mask if one exists. * @@ -94,16 +77,6 @@ public interface Mask { return value == null ? this : value; } - default Mask and(Mask other) { - Mask value = and(other); - return value == null ? MaskIntersection.of(this, other) : value; - } - - default Mask or(Mask other) { - Mask value = or(other); - return value == null ? MaskUnion.of(this, other) : value; - } - default Mask inverse() { if (this instanceof Masks.AlwaysTrue) { return Masks.ALWAYS_FALSE; @@ -117,7 +90,7 @@ public interface Mask { return new Filter() { @Override public void applyBlock(FilterBlock block) { - if (test(block, block)) { + if (test(block)) { run.accept(block); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask2D.java index c5f93aa34..efc69018a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask2D.java @@ -19,10 +19,7 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.session.request.Request; /** * Tests whether a given vector meets a criteria. @@ -35,16 +32,6 @@ public interface Mask2D { * @param vector the vector to test * @return true if the criteria is met */ - default boolean test(BlockVector2 vector) { - Extent extent = Request.request().getExtent(); - if (extent == null) { - extent = NullExtent.INSTANCE; - } - return test(extent, vector); - } - - default boolean test(Extent extent, BlockVector2 vector) { - return test(vector); - } + boolean test(BlockVector2 vector); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java index d7cd2893a..2c87cdf25 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import java.util.AbstractMap; @@ -226,9 +225,9 @@ public class MaskIntersection extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { for (Mask mask : masksArray) { - if (!mask.test(extent, vector)) { + if (!mask.test( vector)) { return false; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java index 31c078e34..12ab2b0b8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import java.util.Arrays; @@ -84,13 +83,13 @@ public class MaskIntersection2D implements Mask2D { } @Override - public boolean test(Extent extent, BlockVector2 vector) { + public boolean test(BlockVector2 vector) { if (masks.isEmpty()) { return false; } for (Mask2D mask : masks) { - if (!mask.test(extent, vector)) { + if (!mask.test(vector)) { return false; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java index 001c03aba..a58ace750 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import java.util.ArrayList; @@ -86,11 +85,11 @@ public class MaskUnion extends MaskIntersection { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { Mask[] masks = getMasksArray(); for (Mask mask : masks) { - if (mask.test(extent, vector)) { + if (mask.test(vector)) { return true; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion2D.java index a6bbefda2..daf1a6e85 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion2D.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import java.util.Collection; @@ -48,11 +47,11 @@ public class MaskUnion2D extends MaskIntersection2D { } @Override - public boolean test(Extent extent, BlockVector2 vector) { + public boolean test(BlockVector2 vector) { Collection masks = getMasks(); for (Mask2D mask : masks) { - if (mask.test(extent, vector)) { + if (mask.test(vector)) { return true; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java index fd8cd5f74..b3333d268 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; @@ -43,7 +42,7 @@ public final class Masks { } /** - * Return a 3D mask that always returns true; + * Return a 3D mask that always returns true. * * @return a mask */ @@ -56,7 +55,7 @@ public final class Masks { } /** - * Return a 2D mask that always returns true; + * Return a 2D mask that always returns true. * * @return a mask */ @@ -90,8 +89,8 @@ public final class Masks { checkNotNull(mask); return new AbstractMask2D() { @Override - public boolean test(Extent extent, BlockVector2 vector) { - return !mask.test(extent, vector); + public boolean test(BlockVector2 vector) { + return !mask.test(vector); } }; } @@ -105,8 +104,8 @@ public final class Masks { public static Mask asMask(final Mask2D mask) { return new AbstractMask() { @Override - public boolean test(Extent extent, BlockVector3 vector) { - return mask.test(extent, vector.toBlockVector2()); + public boolean test(BlockVector3 vector) { + return mask.test(vector.toBlockVector2()); } @Nullable @@ -119,12 +118,12 @@ public final class Masks { protected static class AlwaysTrue implements Mask, Mask2D { @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { return true; } @Override - public boolean test(Extent extent, BlockVector2 vector) { + public boolean test(BlockVector2 vector) { return true; } @@ -144,20 +143,16 @@ public final class Masks { return this; } - @Override - public Mask withExtent(Extent extent) { - return this; - } } protected static class AlwaysFalse implements Mask, Mask2D { @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { return false; } @Override - public boolean test(Extent extent, BlockVector2 vector) { + public boolean test(BlockVector2 vector) { return false; } @@ -177,10 +172,6 @@ public final class Masks { return other; } - @Override - public Mask withExtent(Extent extent) { - return this; - } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java index 6af51968a..589b8bdf9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.noise.NoiseGenerator; @@ -87,7 +86,7 @@ public class NoiseFilter extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { return noiseGenerator.noise(MutableVector3.get(vector.getX(), vector.getY(), vector.getZ())) <= density; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java index 9becbcb8a..ac59d3ef1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.noise.NoiseGenerator; @@ -84,7 +83,7 @@ public class NoiseFilter2D extends AbstractMask2D { } @Override - public boolean test(Extent extent, BlockVector2 pos) { + public boolean test(BlockVector2 pos) { return noiseGenerator.noise(pos.toVector2()) <= density; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java index 2c16bb0cf..e1cc492f1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; @@ -87,12 +86,12 @@ public class OffsetMask extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 pos) { - BlockVector3 testPos = pos.add(offset); + public boolean test(BlockVector3 vector) { + BlockVector3 testPos = vector.add(offset); if (testPos.getBlockY() < 0 || testPos.getBlockY() > 255) { return false; } - return getMask().test(extent, pos.add(offset)); + return getMask().test(vector.add(offset)); } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java index 1c0db5e10..fa1bd7a08 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.MutableBlockVector2; @@ -88,9 +87,9 @@ public class OffsetMask2D extends AbstractMask2D { } @Override - public boolean test(Extent extent, BlockVector2 vector) { + public boolean test(BlockVector2 vector) { mutable.setComponents(vector.getX() + offset.getX(), vector.getZ() + offset.getZ()); - return getMask().test(extent, mutable); + return getMask().test(mutable); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java index 8ef800f4a..a3f0032c1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; @@ -63,7 +62,7 @@ public class RegionMask extends AbstractMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { + public boolean test(BlockVector3 vector) { return region.contains(vector); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java index f776335ac..6e3ab7785 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java @@ -19,8 +19,8 @@ public class SingleBlockStateMask extends ABlockMask { } @Override - public boolean test(Extent extent, BlockVector3 vector) { - int test = vector.getOrdinal(extent); + public boolean test(BlockVector3 vector) { + int test = getExtent().getBlock(vector).getOrdinal(); return ordinal == test || isAir && test == 0; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java index 61ef01a2a..5b579fa23 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java @@ -103,7 +103,7 @@ public class SnapshotRestore { } private void checkAndAddBlock(BlockVector3 pos) { - if (editSession.getMask() != null && !editSession.getMask().test(editSession, pos)) + if (editSession.getMask() != null && !editSession.getMask().test(pos)) return; BlockVector2 chunkPos = ChunkStore.toChunk(pos);