From 3b660756f675e658b91fc510f4c0b5d24a4c0500 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Mon, 21 Sep 2020 17:09:17 +0100 Subject: [PATCH] Fix #647 --- .../fawe/beta/implementation/filter/MaskFilter.java | 8 +++++++- .../implementation/queue/SingleThreadQueueExtent.java | 2 +- .../java/com/boydti/fawe/object/brush/ImageBrush.java | 6 ++++++ .../java/com/boydti/fawe/object/brush/LayerBrush.java | 6 ++++++ .../com/boydti/fawe/object/brush/SplatterBrush.java | 6 ++++++ .../com/boydti/fawe/object/brush/StencilBrush.java | 6 ++++++ .../java/com/boydti/fawe/object/mask/DataMask.java | 10 ++++++++++ .../java/com/boydti/fawe/object/mask/IdDataMask.java | 7 ++++++- .../main/java/com/boydti/fawe/object/mask/IdMask.java | 11 ++++++++--- .../com/sk89q/worldedit/function/mask/ABlockMask.java | 4 ++++ .../worldedit/function/mask/AbstractExtentMask.java | 3 +++ .../worldedit/function/mask/BlockCategoryMask.java | 5 +++++ .../sk89q/worldedit/function/mask/BlockStateMask.java | 5 +++++ .../sk89q/worldedit/function/mask/BlockTypeMask.java | 5 +++++ .../worldedit/function/mask/DelegateExtentMask.java | 11 ----------- .../worldedit/function/mask/ExistingBlockMask.java | 5 +++++ .../worldedit/function/mask/SingleBlockTypeMask.java | 1 + 17 files changed, 84 insertions(+), 17 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java 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 524ce1707..7d821c281 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 @@ -3,6 +3,7 @@ package com.boydti.fawe.beta.implementation.filter; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.implementation.filter.block.DelegateFilter; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; +import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.Mask; import java.util.function.Supplier; @@ -33,7 +34,12 @@ public class MaskFilter extends DelegateFilter { @Override public void applyBlock(FilterBlock block) { - if (mask.test(block)) { + if (mask instanceof AbstractExtentMask) { + if (((AbstractExtentMask) mask).test(block, block)) { + getParent().applyBlock(block); + this.changes++; + } + } else if (mask.test(block)) { getParent().applyBlock(block); this.changes++; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java index 72c449639..571191418 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java @@ -216,7 +216,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen } @Override - public synchronized final IQueueChunk getOrCreateChunk(int x, int z) { + public final IQueueChunk getOrCreateChunk(int x, int z) { final long pair = (long) x << 32 | z & 0xffffffffL; if (pair == lastPair) { return lastChunk; 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 57269d0a7..298ced9d5 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 @@ -87,6 +87,12 @@ 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) { + return test(vector); + } + @Override public boolean test(BlockVector3 vector) { if (solid.test(vector)) { 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 5b3fa03e3..9c2cc2faf 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,6 +6,7 @@ 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; @@ -47,6 +48,11 @@ public class LayerBrush implements Brush { Operations.completeBlindly(visitor); BlockVectorSet visited = visitor.getVisited(); visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(vector); + } + @Override public boolean test(BlockVector3 pos) { int depth = visitor.getDepth() + 1; 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 1143937a8..061235dda 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,6 +4,7 @@ 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; @@ -36,6 +37,11 @@ public class SplatterBrush extends ScatterBrush { SurfaceMask surface = new SurfaceMask(editSession); RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(vector); + } + @Override public boolean test(BlockVector3 vector) { double dist = vector.distanceSq(position); 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 08d5adefb..01e59173a 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,6 +4,7 @@ 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; @@ -55,6 +56,11 @@ public class StencilBrush extends HeightBrush { double scale = (yscale / sizeDouble) * (maxY + 1); RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(vector); + } + private final MutableVector3 mutable = new MutableVector3(); @Override public boolean test(BlockVector3 vector) { 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 d56ccd007..41d5d5aef 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 @@ -22,6 +22,16 @@ public class DataMask extends AbstractExtentMask implements ResettableMask { } } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + if (data != -1) { + return extent.getBlock(vector).getInternalPropertiesId() == data; + } else { + data = extent.getBlock(vector).getInternalPropertiesId(); + return true; + } + } + @Override public void reset() { this.data = -1; 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 cd62830fb..dcdd4987d 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,7 +12,7 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask { } @Override - public boolean test(BlockVector3 vector) { + public boolean test(Extent extent, BlockVector3 vector) { if (combined != -1) { return getExtent().getBlock(vector).getInternalId() == combined; } else { @@ -21,6 +21,11 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask { } } + @Override + public boolean test(BlockVector3 vector) { + return test(getExtent(), vector); + } + @Override public void reset() { this.combined = -1; 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 2a69c2a4a..b73fbedee 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,15 +13,20 @@ public class IdMask extends AbstractExtentMask implements ResettableMask { } @Override - public boolean test(BlockVector3 vector) { + public boolean test(Extent extent, BlockVector3 vector) { if (id != -1) { - return getExtent().getBlock(vector).getInternalBlockTypeId() == id; + return extent.getBlock(vector).getInternalBlockTypeId() == id; } else { - id = getExtent().getBlock(vector).getInternalBlockTypeId(); + id = extent.getBlock(vector).getInternalBlockTypeId(); return true; } } + @Override + public boolean test(BlockVector3 vector) { + return test(getExtent(), vector); + } + @Override public void reset() { this.id = -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 a37946a17..1489f0495 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,6 +15,10 @@ public abstract class ABlockMask extends AbstractExtentMask { super(extent); } + @Override public boolean test(Extent extent, BlockVector3 vector) { + return test(extent.getBlock(vector)); + } + @Override public boolean test(BlockVector3 vector) { return test(getExtent().getBlock(vector)); } 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 7c9192c0c..c5789eb1a 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,6 +20,7 @@ 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; @@ -59,4 +60,6 @@ public abstract class AbstractExtentMask extends AbstractMask { this.extent = extent; } + abstract public boolean test(Extent extent, BlockVector3 position); + } 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 671f71acd..7b64f19d6 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 @@ -46,6 +46,11 @@ public class BlockCategoryMask extends AbstractExtentMask { return category.contains(getExtent().getBlock(vector)); } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return category.contains(extent.getBlock(vector)); + } + @Nullable @Override public Mask2D toMask2D() { 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 485246917..1c52df34a 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 @@ -57,6 +57,11 @@ public class BlockStateMask extends AbstractExtentMask { return test(getExtent().getBlock(vector)); } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(extent.getBlock(vector)); + } + public boolean test(BlockState block) { final Map, Object> checkProps = cache .computeIfAbsent(block.getBlockType(), (b -> Blocks.resolveProperties(states, b))); 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 664739293..8776037df 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 @@ -114,6 +114,11 @@ public class BlockTypeMask extends AbstractExtentMask { return test(getExtent().getBlock(vector).getBlockType()); } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(extent.getBlock(vector).getBlockType()); + } + @Override public boolean replacesAir() { return hasAir; 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 deleted file mode 100644 index 65fc2bb26..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.sk89q.worldedit.function.mask; - -import com.boydti.fawe.object.function.mask.AbstractDelegateMask; - -public class DelegateExtentMask extends AbstractDelegateMask { - - public DelegateExtentMask(Mask parent) { - super(parent); - } - -} 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 7619c15ff..1504d46d5 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 @@ -44,6 +44,11 @@ public class ExistingBlockMask extends AbstractExtentMask { return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir(); } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return !extent.getBlock(vector).getBlockType().getMaterial().isAir(); + } + @Nullable @Override public Mask2D toMask2D() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java index d21eaf28d..6ceea320c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java @@ -1,6 +1,7 @@ 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;