From 6bc5b4a823b8ea07358395b830290abf9345adf6 Mon Sep 17 00:00:00 2001
From: Jesse Boyd
Date: Wed, 29 May 2019 06:31:22 +1000
Subject: [PATCH] .
---
.../sk89q/worldedit/bukkit/BukkitWorld.java | 5 -
.../main/java/com/boydti/fawe/FaweCache.java | 24 +
.../boydti/fawe/beta/ArrayFilterBlock.java | 17 +-
.../com/boydti/fawe/beta/CharFilterBlock.java | 234 +++---
.../boydti/fawe/beta/ChunkFilterBlock.java | 2 +-
.../boydti/fawe/beta/DelegateFilterBlock.java | 697 ++++++++++++++++++
.../com/boydti/fawe/beta/FilterBlock.java | 117 ++-
.../java/com/boydti/fawe/beta/IChunk.java | 2 +-
.../java/com/boydti/fawe/beta/IChunkSet.java | 10 +-
.../com/boydti/fawe/beta/IDelegateChunk.java | 6 +-
.../com/boydti/fawe/beta/NorthVector.java | 93 +++
.../boydti/fawe/beta/SimpleFilterBlock.java | 56 +-
.../boydti/fawe/beta/SingleFilterBlock.java | 98 +++
.../boydti/fawe/beta/filters/SetFilter.java | 2 +-
.../beta/implementation/QueueHandler.java | 3 +-
.../implementation/SimpleCharQueueExtent.java | 3 +-
.../implementation/holder/ChunkHolder.java | 2 +-
.../implementation/holder/DelegateChunk.java | 6 +
.../com/boydti/fawe/command/CFICommands.java | 15 +-
.../com/boydti/fawe/jnbt/anvil/MCAWorld.java | 2 +-
.../fawe/jnbt/anvil/generator/CavesGen.java | 8 +-
.../boydti/fawe/object/DataAnglePattern.java | 16 +-
.../boydti/fawe/object/brush/LayerBrush.java | 46 +-
.../fawe/object/clipboard/EmptyClipboard.java | 2 +-
.../object/extent/BlockTranslateExtent.java | 11 +-
.../fawe/object/extent/EmptyExtent.java | 2 +-
.../object/extent/FastWorldEditExtent.java | 13 +-
.../boydti/fawe/object/extent/NullExtent.java | 20 +-
.../extent/PositionTransformExtent.java | 11 +-
.../fawe/object/extent/ProcessedWEExtent.java | 8 +-
.../fawe/object/extent/TemporalExtent.java | 12 +-
.../fawe/object/extent/TransformExtent.java | 65 +-
.../function/mask/AbstractDelegateMask.java | 1 +
.../fawe/object/mask/AdjacentAnyMask2.java | 11 +
.../com/boydti/fawe/object/mask/DataMask.java | 4 +-
.../boydti/fawe/object/mask/IdDataMask.java | 4 +-
.../com/boydti/fawe/object/mask/IdMask.java | 4 +-
.../boydti/fawe/object/mask/SurfaceMask.java | 3 -
.../object/pattern/AbstractExtentPattern.java | 2 +
.../object/pattern/AngleColorPattern.java | 44 +-
.../object/pattern/AverageColorPattern.java | 16 +-
.../fawe/object/pattern/BiomePattern.java | 11 +-
.../fawe/object/pattern/BufferedPattern.java | 39 +-
.../fawe/object/pattern/DataPattern.java | 30 +-
.../object/pattern/DesaturatePattern.java | 42 +-
.../fawe/object/pattern/ExistingPattern.java | 10 +-
.../object/pattern/ExpressionPattern.java | 15 +-
.../object/pattern/FullClipboardPattern.java | 5 +-
.../object/pattern/Linear2DBlockPattern.java | 5 +-
.../object/pattern/Linear3DBlockPattern.java | 5 +-
.../object/pattern/LinearBlockPattern.java | 4 +-
.../fawe/object/pattern/MaskedPattern.java | 24 +-
.../fawe/object/pattern/NoXPattern.java | 24 +-
.../fawe/object/pattern/NoYPattern.java | 24 +-
.../fawe/object/pattern/NoZPattern.java | 23 +-
.../fawe/object/pattern/OffsetPattern.java | 28 +-
.../fawe/object/pattern/PatternExtent.java | 134 ----
.../fawe/object/pattern/PropertyPattern.java | 12 +-
.../pattern/RandomFullClipboardPattern.java | 6 +-
.../object/pattern/RandomOffsetPattern.java | 20 +-
.../fawe/object/pattern/RelativePattern.java | 22 +-
.../fawe/object/pattern/SaturatePattern.java | 18 +-
.../fawe/object/pattern/ShadePattern.java | 20 +-
.../pattern/SolidRandomOffsetPattern.java | 40 +-
.../pattern/SurfaceRandomOffsetPattern.java | 20 +-
.../object/queue/FaweQueueDelegateExtent.java | 2 +-
.../fawe/object/queue/IDelegateFaweQueue.java | 9 +-
.../com/boydti/fawe/util/TextureUtil.java | 33 +-
.../com/sk89q/worldedit/CuboidClipboard.java | 4 +-
.../java/com/sk89q/worldedit/EditSession.java | 101 ++-
.../worldedit/blocks/TileEntityBlock.java | 16 +-
.../worldedit/command/PatternCommands.java | 37 +-
.../worldedit/command/SelectionCommands.java | 3 +-
.../worldedit/command/tool/BrushTool.java | 3 -
.../extent/AbstractDelegateExtent.java | 2 +-
.../sk89q/worldedit/extent/NullExtent.java | 5 -
.../extent/clipboard/BlockArrayClipboard.java | 9 +-
.../extent/inventory/BlockBagExtent.java | 2 +-
.../transform/BlockTransformExtent.java | 9 +-
.../worldedit/function/mask/ABlockMask.java | 84 +++
.../function/mask/AbstractExtentMask.java | 2 +-
.../function/mask/BlockCategoryMask.java | 3 +-
.../worldedit/function/mask/BlockMask.java | 350 ++++-----
.../function/mask/BlockMaskBuilder.java | 93 ++-
.../function/mask/BlockStateMask.java | 7 +-
.../function/mask/BlockTypeMask.java | 15 +-
.../function/mask/BoundedHeightMask.java | 1 +
.../function/mask/ExistingBlockMask.java | 3 +-
.../function/mask/ExpressionMask.java | 1 +
.../worldedit/function/mask/InverseMask.java | 1 +
.../mask/InverseSingleBlockStateMask.java | 38 +
.../mask/InverseSingleBlockTypeMask.java | 37 +
.../sk89q/worldedit/function/mask/Mask.java | 2 -
.../function/mask/MaskIntersection.java | 5 +-
.../worldedit/function/mask/MaskUnion.java | 1 +
.../sk89q/worldedit/function/mask/Masks.java | 4 +-
.../worldedit/function/mask/NoiseFilter.java | 6 +-
.../worldedit/function/mask/OffsetMask.java | 1 +
.../worldedit/function/mask/RegionMask.java | 1 +
.../mask/SingleBlockStateBitMask.java | 19 -
.../function/mask/SingleBlockStateMask.java | 35 +-
.../function/mask/SingleBlockTypeMask.java | 13 +-
.../function/mask/SolidBlockMask.java | 33 +-
.../function/pattern/BlockPattern.java | 2 +-
.../worldedit/function/pattern/Pattern.java | 8 +-
.../function/pattern/RandomPattern.java | 5 +-
.../pattern/RepeatingExtentPattern.java | 1 +
.../sk89q/worldedit/math/BlockVector3.java | 105 +++
.../sk89q/worldedit/math/BlockVector3Imp.java | 7 +-
.../worldedit/math/MutableBlockVector3.java | 11 +-
.../sk89q/worldedit/math/MutableVector3.java | 11 +
.../sk89q/worldedit/world/AbstractWorld.java | 3 +-
.../com/sk89q/worldedit/world/NullWorld.java | 17 +-
.../sk89q/worldedit/world/SimpleWorld.java | 4 +-
.../java/com/sk89q/worldedit/world/World.java | 4 +-
.../worldedit/world/block/BaseBlock.java | 22 +-
.../worldedit/world/block/BlockState.java | 27 +-
.../worldedit/world/block/BlockType.java | 11 +-
.../world/block/ImmutableBaseBlock.java | 7 +-
119 files changed, 2184 insertions(+), 1329 deletions(-)
create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java
create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java
create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java
create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask2.java
delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java
create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java
create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java
create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockTypeMask.java
delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateBitMask.java
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
index 7d5599ac3..0afe73a47 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
@@ -440,11 +440,6 @@ public class BukkitWorld extends AbstractWorld {
}
}
- @Override
- public com.sk89q.worldedit.world.block.BlockState getLazyBlock(BlockVector3 position) {
- return getBlock(position);
- }
-
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java
index 7dba8eb3e..7aac89cdc 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java
@@ -6,6 +6,8 @@ import com.boydti.fawe.jnbt.anvil.BitArray4096;
import com.boydti.fawe.object.collection.IterableThreadLocal;
import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.*;
+import com.sk89q.worldedit.math.MutableBlockVector3;
+import com.sk89q.worldedit.math.MutableVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
@@ -33,6 +35,10 @@ public class FaweCache implements Trimable {
BLOCK_STATES.clean();
SECTION_BLOCKS.clean();
PALETTE_CACHE.clean();
+ PALETTE_TO_BLOCK_CHAR.clean();
+
+ MUTABLE_VECTOR3.clean();
+ MUTABLE_BLOCKVECTOR3.clean();
return false;
}
@@ -189,6 +195,24 @@ public class FaweCache implements Trimable {
}
}
+ /*
+ * Vector cache
+ */
+
+ public static IterableThreadLocal MUTABLE_BLOCKVECTOR3 = new IterableThreadLocal() {
+ @Override
+ public MutableBlockVector3 init() {
+ return new MutableBlockVector3();
+ }
+ };
+
+ public static IterableThreadLocal MUTABLE_VECTOR3 = new IterableThreadLocal() {
+ @Override
+ public MutableVector3 init() {
+ return new MutableVector3();
+ }
+ };
+
/*
Conversion methods between JNBT tags and raw values
*/
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java
index c005b82f8..8e29eecd2 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java
@@ -2,13 +2,11 @@ package com.boydti.fawe.beta;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
-import java.awt.image.BufferedImage;
-import java.util.concurrent.ThreadLocalRandom;
+import javax.annotation.Nullable;
public class ArrayFilterBlock extends SimpleFilterBlock {
private final char[] blocks;
@@ -42,7 +40,7 @@ public class ArrayFilterBlock extends SimpleFilterBlock {
}
@Override
- public void setState(BlockState state) {
+ public void setBlock(BlockState state) {
blocks[index] = state.getOrdinalChar();
}
@@ -57,20 +55,23 @@ public class ArrayFilterBlock extends SimpleFilterBlock {
}
@Override
- public BlockState getState() {
+ public BlockState getBlock() {
return BlockTypes.states[ordinal];
}
@Override
- public BaseBlock getBaseBlock() {
- return getState().toBaseBlock();
+ public BaseBlock getFullBlock() {
+ return getBlock().toBaseBlock();
}
@Override
- public CompoundTag getTag() {
+ public CompoundTag getNbtData() {
return null;
}
+ @Override
+ public void setNbtData(@Nullable CompoundTag nbtData) {}
+
@Override
public int getX() {
return x;
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java
index 6fcfbea45..15d16d5ff 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java
@@ -2,6 +2,7 @@ package com.boydti.fawe.beta;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.sk89q.jnbt.CompoundTag;
+import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType;
@@ -166,13 +167,18 @@ public class CharFilterBlock extends ChunkFilterBlock {
}
}
+ @Override
+ public void setBiome(BiomeType biome) {
+ set.setBiome(x, y, z, biome);
+ }
+
@Override
public void setOrdinal(final int ordinal) {
delegate.set(this, (char) ordinal);
}
@Override
- public void setState(final BlockState state) {
+ public void setBlock(final BlockState state) {
delegate.set(this, state.getOrdinalChar());
}
@@ -235,28 +241,81 @@ public class CharFilterBlock extends ChunkFilterBlock {
}
@Override
- public final BlockState getState() {
+ public final BlockState getBlock() {
final int ordinal = getArr[index];
return BlockTypes.states[ordinal];
}
@Override
- public final BaseBlock getBaseBlock() {
- final BlockState state = getState();
+ public final BaseBlock getFullBlock() {
+ final BlockState state = getBlock();
final BlockMaterial material = state.getMaterial();
if (material.hasContainer()) {
- final CompoundTag tag = get.getTag(x, y + (layer << 4), z);
+ final CompoundTag tag = get.getTag(x, y + yy, z);
return state.toBaseBlock(tag);
}
return state.toBaseBlock();
}
@Override
- public final CompoundTag getTag() {
+ public final CompoundTag getNbtData() {
return get.getTag(x, y + (layer << 4), z);
}
- public final BlockState getOrdinalBelow() {
+ @Override
+ public void setNbtData(CompoundTag tag) {
+ if (tag != null) {
+ set.setTile(x, y + yy, z, tag);
+ }
+ }
+
+ @Override
+ public boolean hasNbtData() {
+ final BlockState state = getBlock();
+ final BlockMaterial material = state.getMaterial();
+ return material.hasContainer();
+ }
+ /*
+ NORTH(Vector3.at(0, 0, -1), Flag.CARDINAL, 3, 1),
+ EAST(Vector3.at(1, 0, 0), Flag.CARDINAL, 0, 2),
+ SOUTH(Vector3.at(0, 0, 1), Flag.CARDINAL, 1, 3),
+ WEST(Vector3.at(-1, 0, 0), Flag.CARDINAL, 2, 0),
+ */
+
+ @Override
+ public final BlockState getBlockNorth() {
+ if (z > 0) {
+ return states[getArr[index - 16]];
+ }
+ return getExtent().getBlock(getX(), getY(), getZ() - 1);
+ }
+
+ @Override
+ public final BlockState getBlockEast() {
+ if (x < 15) {
+ return states[getArr[index + 1]];
+ }
+ return getExtent().getBlock(getX() + 1, getY(), getZ());
+ }
+
+ @Override
+ public final BlockState getBlockSouth() {
+ if (z < 15) {
+ return states[getArr[index + 16]];
+ }
+ return getExtent().getBlock(getX(), getY(), getZ() + 1);
+ }
+
+ @Override
+ public final BlockState getBlockWest() {
+ if (x > 0) {
+ return states[getArr[index - 1]];
+ }
+ return getExtent().getBlock(getX() - 1, getY(), getZ());
+ }
+
+ @Override
+ public final BlockState getBlockBelow() {
if (y > 0) {
return states[getArr[index - 256]];
}
@@ -268,7 +327,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
return BlockTypes.__RESERVED__.getDefaultState();
}
- public final BlockState getStateAbove() {
+ @Override
+ public final BlockState getBlockAbove() {
if (y < 16) {
return states[getArr[index + 256]];
}
@@ -280,7 +340,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
return BlockTypes.__RESERVED__.getDefaultState();
}
- public final BlockState getStateRelativeY(final int y) {
+ @Override
+ public final BlockState getBlockRelativeY(final int y) {
final int newY = this.y + y;
final int layerAdd = newY >> 4;
switch (layerAdd) {
@@ -334,135 +395,34 @@ public class CharFilterBlock extends ChunkFilterBlock {
return BlockTypes.__RESERVED__.getDefaultState();
}
- public final BlockState getStateRelative(final int x, final int y, final int z) {
- final int newX = this.x + x;
- final int newZ = this.z + z;
- if (newX >> 4 == 0 && newZ >> 4 == 0) {
- final int newY = this.y + y;
- final int layerAdd = newY >> 4;
- switch (layerAdd) {
- case 0:
- return states[getArr[this.index + ((y << 8) + (z << 4) + x)]];
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15: {
- final int newLayer = layer + layerAdd;
- if (newLayer < 16) {
- final int index = ((newY & 15) << 8) + (newZ << 4) + newX;
- return states[get.sections[newLayer].get(get, newLayer, index)];
- }
- break;
- }
- case -1:
- case -2:
- case -3:
- case -4:
- case -5:
- case -6:
- case -7:
- case -8:
- case -9:
- case -10:
- case -11:
- case -12:
- case -13:
- case -14:
- case -15: {
- final int newLayer = layer + layerAdd;
- if (newLayer >= 0) {
- final int index = ((newY & 15) << 8) + (newZ << 4) + newX;
- return states[get.sections[newLayer].get(get, newLayer, index)];
- }
- break;
- }
- }
- return BlockTypes.__RESERVED__.getDefaultState();
- }
- final int newY = this.y + y + yy;
- if (newY >= 0 && newY <= 256) {
- return getExtent().getBlock(xx + newX, newY, this.zz + newZ);
- }
- return BlockTypes.__RESERVED__.getDefaultState();
+
+
+ @Override
+ public BlockVector3 north() {
+ return this.north;
}
- public final BaseBlock getFullBlockRelative(final int x, final int y, final int z) {
- final int newX = this.x + x;
- final int newZ = this.z + z;
- if (newX >> 4 == 0 && newZ >> 4 == 0) {
- final int newY = this.y + y;
- final int layerAdd = newY >> 4;
- BlockState state = BlockTypes.__RESERVED__.getDefaultState();
- switch (layerAdd) {
- case 0:
- state = states[getArr[this.index + ((y << 8) + (z << 4) + x)]];
- break;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15: {
- final int newLayer = layer + layerAdd;
- if (newLayer < 16) {
- final int index = ((newY & 15) << 8) + (newZ << 4) + newX;
- state = states[get.sections[newLayer].get(get, newLayer, index)];
- }
- break;
- }
- case -1:
- case -2:
- case -3:
- case -4:
- case -5:
- case -6:
- case -7:
- case -8:
- case -9:
- case -10:
- case -11:
- case -12:
- case -13:
- case -14:
- case -15: {
- final int newLayer = layer + layerAdd;
- if (newLayer >= 0) {
- final int index = ((newY & 15) << 8) + (newZ << 4) + newX;
- state = states[get.sections[newLayer].get(get, newLayer, index)];
- }
- break;
- }
- }
- if (state.getMaterial().hasContainer()) {
- final CompoundTag tag = get.getTag(x, y + (layer << 4), z);
- return state.toBaseBlock(tag);
- }
- }
- final int newY = this.y + y + yy;
- if (newY >= 0 && newY <= 256) {
- return getExtent().getFullBlock(xx + newX, newY, this.zz + newZ);
- }
- return BlockTypes.__RESERVED__.getDefaultState().toBaseBlock();
+ @Override
+ public BlockVector3 east() {
+ return super.east();
+ }
+
+ @Override
+ public BlockVector3 south() {
+ return super.south();
+ }
+
+ @Override
+ public BlockVector3 west() {
+ return super.west();
+ }
+
+ /*
+ Extent
+ */
+ @Override
+ public char getOrdinalChar(Extent orDefault) {
+ return getOrdinalChar();
}
/*
@@ -484,7 +444,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
if ((x >> 4) == X && (z >> 4) == Z) {
- return set.setBiome(x & 15, z & 15, biome);
+ return set.setBiome(x & 15, y, z & 15, biome);
}
return getExtent().setBiome(x, y, z, biome);
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java
index 59560279b..8dd9f95f8 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java
@@ -6,7 +6,7 @@ import com.sk89q.worldedit.regions.Region;
import javax.annotation.Nullable;
-public abstract class ChunkFilterBlock extends FilterBlock {
+public abstract class ChunkFilterBlock extends SimpleFilterBlock {
public ChunkFilterBlock(Extent extent) {
super(extent);
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java
new file mode 100644
index 000000000..88e1f9340
--- /dev/null
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java
@@ -0,0 +1,697 @@
+package com.boydti.fawe.beta;
+
+import com.boydti.fawe.jnbt.anvil.generator.GenBase;
+import com.boydti.fawe.jnbt.anvil.generator.Resource;
+import com.sk89q.jnbt.CompoundTag;
+import com.sk89q.worldedit.WorldEditException;
+import com.sk89q.worldedit.entity.BaseEntity;
+import com.sk89q.worldedit.entity.Entity;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
+import com.sk89q.worldedit.function.mask.Mask;
+import com.sk89q.worldedit.function.operation.Operation;
+import com.sk89q.worldedit.function.pattern.Pattern;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.MutableBlockVector3;
+import com.sk89q.worldedit.math.Vector3;
+import com.sk89q.worldedit.regions.Region;
+import com.sk89q.worldedit.session.ClipboardHolder;
+import com.sk89q.worldedit.util.Countable;
+import com.sk89q.worldedit.util.Location;
+import com.sk89q.worldedit.world.biome.BiomeType;
+import com.sk89q.worldedit.world.block.BaseBlock;
+import com.sk89q.worldedit.world.block.BlockState;
+import com.sk89q.worldedit.world.block.BlockStateHolder;
+import com.sk89q.worldedit.world.block.BlockType;
+
+import javax.annotation.Nullable;
+import java.util.Comparator;
+import java.util.List;
+
+public class DelegateFilterBlock extends FilterBlock {
+ private final FilterBlock parent;
+
+ public DelegateFilterBlock(FilterBlock parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public Extent getExtent() {
+ return parent.getExtent();
+ }
+
+ @Override
+ public void setOrdinal(int ordinal) {
+ parent.setOrdinal(ordinal);
+ }
+
+ @Override
+ public void setBlock(BlockState state) {
+ parent.setBlock(state);
+ }
+
+ @Override
+ public void setFullBlock(BaseBlock block) {
+ parent.setFullBlock(block);
+ }
+
+ @Override
+ public void setNbtData(@Nullable CompoundTag nbtData) {
+ parent.setNbtData(nbtData);
+ }
+
+ @Override
+ public boolean hasNbtData() {
+ return parent.hasNbtData();
+ }
+
+ @Override
+ public void setBiome(BiomeType biome) {
+ parent.setBiome(biome);
+ }
+
+ @Override
+ public int getOrdinal() {
+ return parent.getOrdinal();
+ }
+
+ @Override
+ public BlockState getBlock() {
+ return parent.getBlock();
+ }
+
+ @Override
+ public BaseBlock getFullBlock() {
+ return parent.getFullBlock();
+ }
+
+ @Override
+ public CompoundTag getNbtData() {
+ return parent.getNbtData();
+ }
+
+ @Override
+ public BlockVector3 getMinimumPoint() {
+ return parent.getMinimumPoint();
+ }
+
+ @Override
+ public BlockVector3 getMaximumPoint() {
+ return parent.getMaximumPoint();
+ }
+
+ @Override
+ public BlockState getBlock(int x, int y, int z) {
+ return parent.getBlock(x, y, z);
+ }
+
+ @Override
+ public BaseBlock getFullBlock(int x, int y, int z) {
+ return parent.getFullBlock(x, y, z);
+ }
+
+ @Override
+ public BlockState getBlockBelow() {
+ return parent.getBlockBelow();
+ }
+
+ @Override
+ public BlockState getBlockAbove() {
+ return parent.getBlockAbove();
+ }
+
+ @Override
+ public BlockState getBlockNorth() {
+ return parent.getBlockNorth();
+ }
+
+ @Override
+ public BlockState getBlockEast() {
+ return parent.getBlockEast();
+ }
+
+ @Override
+ public BlockState getBlockSouth() {
+ return parent.getBlockSouth();
+ }
+
+ @Override
+ public BlockState getBlockWest() {
+ return parent.getBlockWest();
+ }
+
+ @Override
+ public BlockState getBlockRelativeY(int y) {
+ return parent.getBlockRelativeY(y);
+ }
+
+ @Override
+ public int getX() {
+ return parent.getX();
+ }
+
+ @Override
+ public int getY() {
+ return parent.getY();
+ }
+
+ @Override
+ public int getZ() {
+ return parent.getZ();
+ }
+
+ @Override
+ public int getLocalX() {
+ return parent.getLocalX();
+ }
+
+ @Override
+ public int getLocalY() {
+ return parent.getLocalY();
+ }
+
+ @Override
+ public int getLocalZ() {
+ return parent.getLocalZ();
+ }
+
+ @Override
+ public int getChunkX() {
+ return parent.getChunkX();
+ }
+
+ @Override
+ public int getChunkZ() {
+ return parent.getChunkZ();
+ }
+
+ @Override
+ public boolean setOrdinal(Extent orDefault, int ordinal) {
+ return parent.setOrdinal(orDefault, ordinal);
+ }
+
+ @Override
+ public boolean setBlock(Extent orDefault, BlockState state) {
+ return parent.setBlock(orDefault, state);
+ }
+
+ @Override
+ public boolean setFullBlock(Extent orDefault, BaseBlock block) {
+ return parent.setFullBlock(orDefault, block);
+ }
+
+ @Override
+ public boolean setBiome(Extent orDefault, BiomeType biome) {
+ return parent.setBiome(orDefault, biome);
+ }
+
+ @Override
+ public int getOrdinal(Extent orDefault) {
+ return parent.getOrdinal(orDefault);
+ }
+
+ @Override
+ public BlockState getBlock(Extent orDefault) {
+ return parent.getBlock(orDefault);
+ }
+
+ @Override
+ public BaseBlock getFullBlock(Extent orDefault) {
+ return parent.getFullBlock(orDefault);
+ }
+
+ @Override
+ public CompoundTag getNbtData(Extent orDefault) {
+ return parent.getNbtData(orDefault);
+ }
+
+ @Override
+ public BlockState getOrdinalBelow(Extent orDefault) {
+ return parent.getOrdinalBelow(orDefault);
+ }
+
+ @Override
+ public BlockState getStateAbove(Extent orDefault) {
+ return parent.getStateAbove(orDefault);
+ }
+
+ @Override
+ public BlockState getStateRelativeY(Extent orDefault, int y) {
+ return parent.getStateRelativeY(orDefault, y);
+ }
+
+ public static BlockVector3 at(double x, double y, double z) {
+ return BlockVector3.at(x, y, z);
+ }
+
+ public static BlockVector3 at(int x, int y, int z) {
+ return BlockVector3.at(x, y, z);
+ }
+
+ public static Comparator sortByCoordsYzx() {
+ return BlockVector3.sortByCoordsYzx();
+ }
+
+ @Override
+ public MutableBlockVector3 setComponents(double x, double y, double z) {
+ return parent.setComponents(x, y, z);
+ }
+
+ @Override
+ public MutableBlockVector3 setComponents(int x, int y, int z) {
+ return parent.setComponents(x, y, z);
+ }
+
+ @Override
+ public MutableBlockVector3 mutX(double x) {
+ return parent.mutX(x);
+ }
+
+ @Override
+ public MutableBlockVector3 mutY(double y) {
+ return parent.mutY(y);
+ }
+
+ @Override
+ public MutableBlockVector3 mutZ(double z) {
+ return parent.mutZ(z);
+ }
+
+ @Override
+ public MutableBlockVector3 mutX(int x) {
+ return parent.mutX(x);
+ }
+
+ @Override
+ public MutableBlockVector3 mutY(int y) {
+ return parent.mutY(y);
+ }
+
+ @Override
+ public MutableBlockVector3 mutZ(int z) {
+ return parent.mutZ(z);
+ }
+
+ @Override
+ public BlockVector3 toImmutable() {
+ return parent.toImmutable();
+ }
+
+ @Override
+ public BlockVector3 north() {
+ return parent.north();
+ }
+
+ @Override
+ public BlockVector3 east() {
+ return parent.east();
+ }
+
+ @Override
+ public BlockVector3 south() {
+ return parent.south();
+ }
+
+ @Override
+ public BlockVector3 west() {
+ return parent.west();
+ }
+
+ @Override
+ public int getBlockX() {
+ return parent.getBlockX();
+ }
+
+ @Override
+ public BlockVector3 withX(int x) {
+ return parent.withX(x);
+ }
+
+ @Override
+ public int getBlockY() {
+ return parent.getBlockY();
+ }
+
+ @Override
+ public BlockVector3 withY(int y) {
+ return parent.withY(y);
+ }
+
+ @Override
+ public int getBlockZ() {
+ return parent.getBlockZ();
+ }
+
+ @Override
+ public BlockVector3 withZ(int z) {
+ return parent.withZ(z);
+ }
+
+ @Override
+ public BlockVector3 add(BlockVector3 other) {
+ return parent.add(other);
+ }
+
+ @Override
+ public BlockVector3 add(int x, int y, int z) {
+ return parent.add(x, y, z);
+ }
+
+ @Override
+ public BlockVector3 add(BlockVector3... others) {
+ return parent.add(others);
+ }
+
+ @Override
+ public BlockVector3 subtract(BlockVector3 other) {
+ return parent.subtract(other);
+ }
+
+ @Override
+ public BlockVector3 subtract(int x, int y, int z) {
+ return parent.subtract(x, y, z);
+ }
+
+ @Override
+ public BlockVector3 subtract(BlockVector3... others) {
+ return parent.subtract(others);
+ }
+
+ @Override
+ public BlockVector3 multiply(BlockVector3 other) {
+ return parent.multiply(other);
+ }
+
+ @Override
+ public BlockVector3 multiply(int x, int y, int z) {
+ return parent.multiply(x, y, z);
+ }
+
+ @Override
+ public BlockVector3 multiply(BlockVector3... others) {
+ return parent.multiply(others);
+ }
+
+ @Override
+ public BlockVector3 multiply(int n) {
+ return parent.multiply(n);
+ }
+
+ @Override
+ public BlockVector3 divide(BlockVector3 other) {
+ return parent.divide(other);
+ }
+
+ @Override
+ public BlockVector3 divide(int x, int y, int z) {
+ return parent.divide(x, y, z);
+ }
+
+ @Override
+ public BlockVector3 divide(int n) {
+ return parent.divide(n);
+ }
+
+ @Override
+ public double length() {
+ return parent.length();
+ }
+
+ @Override
+ public int lengthSq() {
+ return parent.lengthSq();
+ }
+
+ @Override
+ public double distance(BlockVector3 other) {
+ return parent.distance(other);
+ }
+
+ @Override
+ public int distanceSq(BlockVector3 other) {
+ return parent.distanceSq(other);
+ }
+
+ @Override
+ public BlockVector3 normalize() {
+ return parent.normalize();
+ }
+
+ @Override
+ public double dot(BlockVector3 other) {
+ return parent.dot(other);
+ }
+
+ @Override
+ public BlockVector3 cross(BlockVector3 other) {
+ return parent.cross(other);
+ }
+
+ @Override
+ public boolean containedWithin(BlockVector3 min, BlockVector3 max) {
+ return parent.containedWithin(min, max);
+ }
+
+ @Override
+ public BlockVector3 clampY(int min, int max) {
+ return parent.clampY(min, max);
+ }
+
+ @Override
+ public BlockVector3 floor() {
+ return parent.floor();
+ }
+
+ @Override
+ public BlockVector3 ceil() {
+ return parent.ceil();
+ }
+
+ @Override
+ public BlockVector3 round() {
+ return parent.round();
+ }
+
+ @Override
+ public BlockVector3 abs() {
+ return parent.abs();
+ }
+
+ @Override
+ public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
+ return parent.transform2D(angle, aboutX, aboutZ, translateX, translateZ);
+ }
+
+ @Override
+ public double toPitch() {
+ return parent.toPitch();
+ }
+
+ @Override
+ public double toYaw() {
+ return parent.toYaw();
+ }
+
+ @Override
+ public BlockVector3 getMinimum(BlockVector3 v2) {
+ return parent.getMinimum(v2);
+ }
+
+ @Override
+ public BlockVector3 getMaximum(BlockVector3 v2) {
+ return parent.getMaximum(v2);
+ }
+
+ @Override
+ public char getOrdinalChar(Extent orDefault) {
+ return parent.getOrdinalChar(orDefault);
+ }
+
+ @Override
+ public BlockVector2 toBlockVector2() {
+ return parent.toBlockVector2();
+ }
+
+ @Override
+ public Vector3 toVector3() {
+ return parent.toVector3();
+ }
+
+ @Override
+ public int hashCode() {
+ return parent.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return parent.toString();
+ }
+
+ @Override
+ public List extends Entity> getEntities(Region region) {
+ return parent.getEntities(region);
+ }
+
+ @Override
+ public List extends Entity> getEntities() {
+ return parent.getEntities();
+ }
+
+ @Override
+ @Nullable
+ public Entity createEntity(Location location, BaseEntity entity) {
+ return parent.createEntity(location, entity);
+ }
+
+ @Override
+ public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
+ return parent.getHighestTerrainBlock(x, z, minY, maxY);
+ }
+
+ @Override
+ public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
+ return parent.getHighestTerrainBlock(x, z, minY, maxY, filter);
+ }
+
+ @Override
+ public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
+ return parent.getNearestSurfaceLayer(x, z, y, minY, maxY);
+ }
+
+ @Override
+ public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
+ return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
+ }
+
+ @Override
+ public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
+ return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
+ }
+
+ @Override
+ public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
+ return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
+ }
+
+ @Override
+ public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
+ return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
+ }
+
+ @Override
+ public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
+ return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
+ }
+
+ @Override
+ public void addCaves(Region region) throws WorldEditException {
+ parent.addCaves(region);
+ }
+
+ @Override
+ public void generate(Region region, GenBase gen) throws WorldEditException {
+ parent.generate(region, gen);
+ }
+
+ @Override
+ public void addSchems(Region region, Mask mask, List clipboards, int rarity, boolean rotate) throws WorldEditException {
+ parent.addSchems(region, mask, clipboards, rarity, rotate);
+ }
+
+ @Override
+ public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
+ parent.spawnResource(region, gen, rarity, frequency);
+ }
+
+ @Override
+ public boolean contains(BlockVector3 pt) {
+ return parent.contains(pt);
+ }
+
+ @Override
+ public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
+ parent.addOre(region, mask, material, size, frequency, rarity, minY, maxY);
+ }
+
+ @Override
+ public void addOres(Region region, Mask mask) throws WorldEditException {
+ parent.addOres(region, mask);
+ }
+
+ @Override
+ public List> getBlockDistribution(Region region) {
+ return parent.getBlockDistribution(region);
+ }
+
+ @Override
+ public List> getBlockDistributionWithData(Region region) {
+ return parent.getBlockDistributionWithData(region);
+ }
+
+ @Override
+ public BlockArrayClipboard lazyCopy(Region region) {
+ return parent.lazyCopy(region);
+ }
+
+ @Override
+ @Nullable
+ public Operation commit() {
+ return parent.commit();
+ }
+
+ @Override
+ public int getMaxY() {
+ return parent.getMaxY();
+ }
+
+ @Override
+ public BlockState getBlock(BlockVector3 position) {
+ return parent.getBlock(position);
+ }
+
+ @Override
+ public BlockType getBlockType(BlockVector3 position) {
+ return parent.getBlockType(position);
+ }
+
+ @Override
+ public BaseBlock getFullBlock(BlockVector3 position) {
+ return parent.getFullBlock(position);
+ }
+
+ @Override
+ public BiomeType getBiome(BlockVector2 position) {
+ return parent.getBiome(position);
+ }
+
+ @Override
+ public BiomeType getBiome(int x, int z) {
+ return parent.getBiome(x, z);
+ }
+
+ @Override
+ public > boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
+ return parent.setBlock(position, block);
+ }
+
+ @Override
+ public > boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
+ return parent.setBlock(x, y, z, block);
+ }
+
+ @Override
+ public boolean setBiome(BlockVector2 position, BiomeType biome) {
+ return parent.setBiome(position, biome);
+ }
+
+ @Override
+ public boolean setBiome(int x, int y, int z, BiomeType biome) {
+ return parent.setBiome(x, y, z, biome);
+ }
+
+ @Override
+ public String getNbtId() {
+ return parent.getNbtId();
+ }
+}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java
index 007b25a6d..34fc86323 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java
@@ -1,38 +1,43 @@
package com.boydti.fawe.beta;
import com.sk89q.jnbt.CompoundTag;
+import com.sk89q.worldedit.blocks.TileEntityBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.regions.Region;
+import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import javax.annotation.Nullable;
-public abstract class FilterBlock extends BlockVector3 implements Extent {
- private final Extent extent;
+import static com.sk89q.worldedit.world.block.BlockTypes.states;
- public FilterBlock(Extent extent) {
- this.extent = extent;
- }
-
- public final Extent getExtent() {
- return extent;
- }
+public abstract class FilterBlock extends BlockVector3 implements Extent, TileEntityBlock {
+ public abstract Extent getExtent();
public abstract void setOrdinal(int ordinal);
- public abstract void setState(BlockState state);
+ public abstract void setBlock(BlockState state);
public abstract void setFullBlock(BaseBlock block);
+ public void setBiome(BiomeType biome) {
+ setBiome(getX(), getY(), getZ(), biome);
+ }
+
public abstract int getOrdinal();
- public abstract BlockState getState();
+ public abstract BlockState getBlock();
- public abstract BaseBlock getBaseBlock();
+ public abstract BaseBlock getFullBlock();
- public abstract CompoundTag getTag();
+ public abstract CompoundTag getNbtData();
+
+ public abstract void setNbtData(@Nullable CompoundTag nbtData);
+
+ public boolean hasNbtData() {
+ return getNbtData() != null;
+ }
@Override
public BlockVector3 getMinimumPoint() {
@@ -46,32 +51,40 @@ public abstract class FilterBlock extends BlockVector3 implements Extent {
@Override
public BlockState getBlock(int x, int y, int z) {
- return getStateRelative(x - getX(), y - getY(), z - getZ());
+ return getExtent().getBlock(x, y, z);
}
@Override
public BaseBlock getFullBlock(int x, int y, int z) {
- return getFullBlockRelative(x - getX(), y - getY(), z - getZ());
+ return getExtent().getFullBlock(x, y, z);
}
- public BlockState getOrdinalBelow() {
- return getStateRelative(0, -1, 0);
+ public BlockState getBlockBelow() {
+ return getBlock(getX(), getY() - 1, getZ());
}
- public BlockState getStateAbove() {
- return getStateRelative(0, 1, 0);
+ public BlockState getBlockAbove() {
+ return getBlock(getX(), getY() + 1, getZ());
}
- public BlockState getStateRelativeY(final int y) {
- return getStateRelative(0, y, 0);
+ public BlockState getBlockNorth() {
+ return getBlock(getX(), getY(), getZ() - 1);
}
- public BlockState getStateRelative(final int x, final int y, final int z) {
- return getFullBlockRelative(x, y, z).toBlockState();
+ public BlockState getBlockEast() {
+ return getBlock(getX() + 1, getY(), getZ());
}
- public BaseBlock getFullBlockRelative(int x, int y, int z) {
- return getExtent().getFullBlock(x + getX(), y + getY(), z + getZ());
+ public BlockState getBlockSouth() {
+ return getBlock(getX(), getY(), getZ() + 1);
+ }
+
+ public BlockState getBlockWest() {
+ return getBlock(getX() - 1, getY(), getZ());
+ }
+
+ public BlockState getBlockRelativeY(final int y) {
+ return getBlock(getX(), getY() + y , getZ());
}
@Override
@@ -102,4 +115,56 @@ public abstract class FilterBlock extends BlockVector3 implements Extent {
public int getChunkZ() {
return getZ() >> 4;
}
+
+ /*
+ Extent
+ */
+
+ public boolean setOrdinal(Extent orDefault, int ordinal) {
+ setOrdinal(ordinal);
+ return true;
+ }
+
+ public boolean setBlock(Extent orDefault, BlockState state) {
+ setBlock(state);
+ return true;
+ }
+
+ public boolean setFullBlock(Extent orDefault, BaseBlock block) {
+ setFullBlock(block);
+ return true;
+ }
+
+ public boolean setBiome(Extent orDefault, BiomeType biome) {
+ setBiome(biome);
+ return true;
+ }
+
+ public int getOrdinal(Extent orDefault) {
+ return getOrdinal();
+ }
+
+ public BlockState getBlock(Extent orDefault) {
+ return getBlock();
+ }
+
+ public BaseBlock getFullBlock(Extent orDefault) {
+ return getFullBlock();
+ }
+
+ public CompoundTag getNbtData(Extent orDefault) {
+ return getNbtData();
+ }
+
+ public BlockState getOrdinalBelow(Extent orDefault) {
+ return getBlockBelow();
+ }
+
+ public BlockState getStateAbove(Extent orDefault) {
+ return getBlockAbove();
+ }
+
+ public BlockState getStateRelativeY(Extent orDefault, final int y) {
+ return getBlockRelativeY(y);
+ }
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java
index bdc17bb47..ed8c080b0 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java
@@ -71,7 +71,7 @@ public interface IChunk> extends Trimable, Callable {
* @param unitialized a mutable block vector (buffer)
* @param unitialized2 a mutable block vector (buffer)
*/
- void filter(Filter filter, ChunkFilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2);
+ void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2);
void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block);
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java
index 138efc6be..bef4af0bf 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java
@@ -2,10 +2,12 @@ package com.boydti.fawe.beta;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.OutputExtent;
+import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
+import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -16,7 +18,7 @@ import java.util.UUID;
* Interface for setting blocks
*/
public interface IChunkSet extends IBlocks, OutputExtent {
- boolean setBiome(int x, int z, BiomeType biome);
+ boolean setBiome(int x, int y, int z, BiomeType biome);
boolean setBlock(int x, int y, int z, BlockStateHolder holder);
@@ -42,4 +44,10 @@ public interface IChunkSet extends IBlocks, OutputExtent {
@Override
void reset();
+
+ @Nullable
+ @Override
+ default Operation commit() {
+ return null;
+ }
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java
index 9a5f4add1..3862c23c5 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java
@@ -27,7 +27,7 @@ public interface IDelegateChunk extends IChunk {
}
@Override
- default void flood(Flood flood, FilterBlockMask mask, FilterBlock block) {
+ default void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
getParent().flood(flood, mask, block);
}
@@ -88,8 +88,8 @@ public interface IDelegateChunk extends IChunk {
}
@Override
- default void filter(Filter filter, FilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2) {
- getParent().filter(filter, block, region, unitialized, unitialized2);
+ default void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2) {
+ getParent().filterBlocks(filter, block, region, unitialized, unitialized2);
}
@Override
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java
new file mode 100644
index 000000000..c0b4c8e5e
--- /dev/null
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java
@@ -0,0 +1,93 @@
+package com.boydti.fawe.beta;
+
+import com.sk89q.jnbt.CompoundTag;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.MutableBlockVector3;
+import com.sk89q.worldedit.world.biome.BiomeType;
+import com.sk89q.worldedit.world.block.BaseBlock;
+import com.sk89q.worldedit.world.block.BlockState;
+
+public class NorthVector extends BlockVector3 {
+ private final BlockVector3 parent;
+
+ public NorthVector(BlockVector3 parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public BlockVector3 south(BlockVector3 orDefault) {
+ return parent;
+ }
+
+ @Override
+ public int getX() {
+ return parent.getX();
+ }
+
+ @Override
+ public int getY() {
+ return parent.getY();
+ }
+
+ @Override
+ public int getZ() {
+ return parent.getZ();
+ }
+
+ public boolean setOrdinal(Extent orDefault, int ordinal) {
+ return orDefault.setBlock(this, BlockState.getFromOrdinal(ordinal));
+ }
+
+ public boolean setBlock(Extent orDefault, BlockState state) {
+ return orDefault.setBlock(this, state);
+ }
+
+ public boolean setFullBlock(Extent orDefault, BaseBlock block) {
+ return orDefault.setBlock(this, block);
+ }
+
+ public boolean setBiome(Extent orDefault, BiomeType biome) {
+ return orDefault.setBiome(getX(), getY(), getZ(), biome);
+ }
+
+ public int getOrdinal(Extent orDefault) {
+ return getBlock(orDefault).getOrdinal();
+ }
+
+ public char getOrdinalChar(Extent orDefault) {
+ return (char) getOrdinal(orDefault);
+ }
+
+ public BlockState getBlock(Extent orDefault) {
+ return orDefault.getBlock(this);
+ }
+
+ public BaseBlock getFullBlock(Extent orDefault) {
+ return orDefault.getFullBlock(this);
+ }
+
+ public CompoundTag getNbtData(Extent orDefault) {
+ return orDefault.getFullBlock(getX(), getY(), getZ()).getNbtData();
+ }
+
+ public BlockState getOrdinalBelow(Extent orDefault) {
+ return getStateRelative(orDefault, 0, -1, 0);
+ }
+
+ public BlockState getStateAbove(Extent orDefault) {
+ return getStateRelative(orDefault, 0, 1, 0);
+ }
+
+ public BlockState getStateRelativeY(Extent orDefault, final int y) {
+ return getStateRelative(orDefault, 0, y, 0);
+ }
+
+ public BlockState getStateRelative(Extent orDefault, final int x, final int y, final int z) {
+ return getFullBlockRelative(orDefault, x, y, z).toBlockState();
+ }
+
+ public BaseBlock getFullBlockRelative(Extent orDefault, int x, int y, int z) {
+ return orDefault.getFullBlock(x + getX(), y + getY(), z + getZ());
+ }
+}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java
index 34da51861..99ec8e2e6 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java
@@ -11,60 +11,14 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
public abstract class SimpleFilterBlock extends FilterBlock {
+ private final Extent extent;
+
public SimpleFilterBlock(Extent extent) {
- super(extent);
- }
-
- private int x, y, z, ordinal;
- private CompoundTag nbt;
-
- public void init(int x, int y, int z, int ordinal) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.ordinal = ordinal;
- }
-
- public void init(int x, int y, int z, int ordinal, CompoundTag nbt) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.ordinal = ordinal;
- this.nbt = nbt;
+ this.extent = extent;
}
@Override
- public int getOrdinal() {
- return ordinal;
- }
-
- @Override
- public BlockState getState() {
- return BlockTypes.states[ordinal];
- }
-
- @Override
- public BaseBlock getBaseBlock() {
- return getState().toBaseBlock(nbt);
- }
-
- @Override
- public CompoundTag getTag() {
- return nbt;
- }
-
- @Override
- public int getX() {
- return x;
- }
-
- @Override
- public int getY() {
- return y;
- }
-
- @Override
- public int getZ() {
- return z;
+ public final Extent getExtent() {
+ return extent;
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java
new file mode 100644
index 000000000..8a7add4b6
--- /dev/null
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java
@@ -0,0 +1,98 @@
+package com.boydti.fawe.beta;
+
+import com.sk89q.jnbt.CompoundTag;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.world.block.BaseBlock;
+import com.sk89q.worldedit.world.block.BlockState;
+
+import javax.annotation.Nullable;
+
+public class SingleFilterBlock extends FilterBlock {
+
+ private BaseBlock block;
+ private int x, y, z;
+
+ public SingleFilterBlock init(int x, int y, int z, BaseBlock block) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.block = block;
+ return this;
+ }
+
+ @Override
+ public Extent getExtent() {
+ return this;
+ }
+
+ @Override
+ public void setOrdinal(int ordinal) {
+ setBlock(BlockState.getFromOrdinal(ordinal));
+ }
+
+ @Override
+ public void setBlock(BlockState state) {
+ setFullBlock(state.toBaseBlock(block.getNbtData()));
+ }
+
+ @Override
+ public void setFullBlock(BaseBlock block) {
+ this.block = block;
+ }
+
+ @Override
+ public void setNbtData(@Nullable CompoundTag nbtData) {
+ block = block.toBaseBlock(nbtData);
+ }
+
+ @Override
+ public int getOrdinal() {
+ return block.getOrdinal();
+ }
+
+ @Override
+ public BaseBlock getFullBlockRelative(int x, int y, int z) {
+ return block;
+ }
+
+ @Override
+ public BlockState getBlock() {
+ return block.toBlockState();
+ }
+
+ @Override
+ public BaseBlock getFullBlock() {
+ return block;
+ }
+
+ @Override
+ public CompoundTag getNbtData() {
+ return block.getNbtData();
+ }
+
+ @Override
+ public int getX() {
+ return x;
+ }
+
+ @Override
+ public int getY() {
+ return y;
+ }
+
+ @Override
+ public int getZ() {
+ return z;
+ }
+
+ @Override
+ public BlockVector3 getMinimumPoint() {
+ return BlockVector3.at(x, y, z);
+ }
+
+ @Override
+ public BlockVector3 getMaximumPoint() {
+ return BlockVector3.at(x, y, z);
+ }
+}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java
index 04048d04d..841defd43 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java
@@ -13,6 +13,6 @@ public class SetFilter implements Filter {
@Override
public void applyBlock(final FilterBlock block) {
- block.setState(state);
+ block.setBlock(state);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java
index 666ededbf..e7a90b531 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java
@@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.ChunkFilterBlock;
import com.boydti.fawe.beta.Filter;
-import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.Trimable;
@@ -186,7 +185,7 @@ public abstract class QueueHandler implements Trimable, Runnable {
if (newChunk != null) {
chunk = newChunk;
if (block == null) block = queue.initFilterBlock();
- chunk.filter(newFilter, block, region, mbv1, mbv2);
+ chunk.filterBlocks(newFilter, block, region, mbv1, mbv2);
}
queue.submit(chunk);
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java
index 80ce0d560..b341c7021 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SimpleCharQueueExtent.java
@@ -1,11 +1,12 @@
package com.boydti.fawe.beta.implementation;
import com.boydti.fawe.beta.CharFilterBlock;
+import com.boydti.fawe.beta.ChunkFilterBlock;
import com.boydti.fawe.beta.FilterBlock;
public abstract class SimpleCharQueueExtent extends SingleThreadQueueExtent {
@Override
- public FilterBlock initFilterBlock() {
+ public ChunkFilterBlock initFilterBlock() {
return new CharFilterBlock(this);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java
index dbf456a72..b1336a480 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java
@@ -47,7 +47,7 @@ public abstract class ChunkHolder implements IChunk, Supplier {
}
@Override
- public void filter(final Filter filter, ChunkFilterBlock block, @Nullable Region region, @Nullable final MutableBlockVector3 min, @Nullable final MutableBlockVector3 max) {
+ public void filterBlocks(final Filter filter, ChunkFilterBlock block, @Nullable Region region, @Nullable final MutableBlockVector3 min, @Nullable final MutableBlockVector3 max) {
final IChunkGet get = getOrCreateGet();
final IChunkSet set = getOrCreateSet();
try {
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java
index 91e28814f..88c6269db 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java
@@ -1,10 +1,16 @@
package com.boydti.fawe.beta.implementation.holder;
+import com.boydti.fawe.beta.ChunkFilterBlock;
+import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.beta.FilterBlockMask;
import com.boydti.fawe.beta.Flood;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IDelegateChunk;
+import com.sk89q.worldedit.math.MutableBlockVector3;
+import com.sk89q.worldedit.regions.Region;
+
+import javax.annotation.Nullable;
/**
* Implementation of IDelegateChunk
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java
index 404fef5da..20140ba8d 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java
@@ -2,6 +2,7 @@ package com.boydti.fawe.command;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
+import com.boydti.fawe.beta.SingleFilterBlock;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
@@ -9,7 +10,6 @@ import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
-import com.boydti.fawe.object.pattern.PatternExtent;
import com.boydti.fawe.util.CleanTextureUtil;
import com.boydti.fawe.util.FilteredTextureUtil;
import com.boydti.fawe.util.ImgurUtility;
@@ -37,7 +37,6 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.mask.Mask;
-import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
@@ -70,7 +69,6 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.function.Consumer;
import java.util.function.Function;
import static com.boydti.fawe.util.image.ImageUtil.load;
@@ -419,9 +417,7 @@ public class CFICommands extends MethodCommands {
}
default: {
blocks = new HashSet<>();
- BlockPattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
- PatternExtent extent = new PatternExtent(pattern);
-
+ SingleFilterBlock extent = new SingleFilterBlock();
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
@@ -432,9 +428,10 @@ public class CFICommands extends MethodCommands {
TextureUtil tu = Fawe.get().getTextureUtil();
for (int typeId : tu.getValidBlockIds()) {
BlockType type = BlockTypes.get(typeId);
- BlockStateHolder block = type.getDefaultState();
- pattern.setBlock(block);
- if (mask.test(BlockVector3.ZERO)) blocks.add(type);
+ extent.init(0, 0, 0, type.getDefaultState().toBaseBlock());
+ if (mask.test(extent)) {
+ blocks.add(type);
+ }
}
break;
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java
index ab6701b0d..4c8926103 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java
@@ -104,7 +104,7 @@ public class MCAWorld implements SimpleWorld {
@Override
public BlockState getBlock(BlockVector3 position) {
- return extent.getLazyBlock(position);
+ return extent.getBlock(position);
}
@Override
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/CavesGen.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/CavesGen.java
index 76cbdb05f..08257fb7f 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/CavesGen.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/CavesGen.java
@@ -150,7 +150,7 @@ public class CavesGen extends GenBase {
for (int local_z = i3; (!waterFound) && (local_z < i4); local_z++) {
for (int local_y = i2 + 1; (!waterFound) && (local_y >= i1 - 1); local_y--) {
if (local_y < 255) {
- BlockStateHolder material = chunk.getLazyBlock(bx + local_x, local_y, bz + local_z);
+ BlockStateHolder material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
if (material.getBlockType() == BlockTypes.WATER) {
waterFound = true;
}
@@ -174,8 +174,8 @@ public class CavesGen extends GenBase {
for (int local_y = i2; local_y > i1; local_y--) {
double d11 = ((local_y - 1) + 0.5D - y) / d4;
if ((d11 > -0.7D) && (d9 * d9 + d11 * d11 + d10 * d10 < 1.0D)) {
- BlockStateHolder material = chunk.getLazyBlock(bx + local_x, local_y, bz + local_z);
- BlockStateHolder materialAbove = chunk.getLazyBlock(bx + local_x, local_y + 1, bz + local_z);
+ BlockStateHolder material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
+ BlockStateHolder materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z);
BlockType blockType = material.getBlockType();
switch (blockType.getInternalId()) {
case BlockID.MYCELIUM:
@@ -192,7 +192,7 @@ public class CavesGen extends GenBase {
// If grass was just deleted, try to
// move it down
if (grassFound) {
- BlockStateHolder block = chunk.getLazyBlock(bx + local_x, local_y - 1, bz + local_z);
+ BlockStateHolder block = chunk.getBlock(bx + local_x, local_y - 1, bz + local_z);
if (block.getBlockType() == BlockTypes.DIRT) {
chunk.setBlock(bx + local_x, local_y - 1, bz + local_z, BlockTypes.STONE.getDefaultState());
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java
index 323e918e3..48696a6d0 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java
@@ -1,15 +1,14 @@
package com.boydti.fawe.object;
-import com.boydti.fawe.FaweCache;
+import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.extent.ExtentHeightCacher;
import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.world.block.BaseBlock;
+import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
-import com.sk89q.worldedit.world.block.BlockTypes;
public class DataAnglePattern extends AbstractPattern {
public final double FACTOR;
@@ -24,7 +23,7 @@ public class DataAnglePattern extends AbstractPattern {
this.FACTOR = (1D / distance) * (1D / 255);
}
- public int getSlope(BlockStateHolder block, BlockVector3 vector) {
+ public int getSlope(BlockStateHolder block, BlockVector3 vector, Extent extent) {
int x = vector.getBlockX();
int y = vector.getBlockY();
int z = vector.getBlockZ();
@@ -32,7 +31,6 @@ public class DataAnglePattern extends AbstractPattern {
return -1;
}
int slope;
- boolean aboveMin;
slope = Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z, y, 0, maxY)) * 7;
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x, z - distance, y, 0, maxY)) * 7;
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z - distance, y, 0, maxY)) * 5;
@@ -42,8 +40,8 @@ public class DataAnglePattern extends AbstractPattern {
@Override
public BaseBlock apply(BlockVector3 position) {
- BlockStateHolder block = extent.getBlock(position);
- int slope = getSlope(block, position);
+ BlockState block = extent.getBlock(position);
+ int slope = getSlope(block, position, extent);
if (slope == -1) return block.toBaseBlock();
int data = (Math.min(slope, 255)) >> 4;
return block.withPropertyId(data).toBaseBlock();
@@ -52,7 +50,7 @@ public class DataAnglePattern extends AbstractPattern {
@Override
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
BlockStateHolder block = extent.getBlock(getPosition);
- int slope = getSlope(block, getPosition);
+ int slope = getSlope(block, getPosition, extent);
if (slope == -1) return false;
int data = (Math.min(slope, 255)) >> 4;
return extent.setBlock(setPosition, block.withPropertyId(data));
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 fccf2502c..41039fb55 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
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.brush;
+import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.collection.BlockVectorSet;
import com.boydti.fawe.object.mask.AdjacentAnyMask;
@@ -7,6 +8,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.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
@@ -34,7 +36,7 @@ public class LayerBrush implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws MaxChangedBlocksException {
final FaweQueue queue = editSession.getQueue();
- final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockTypeMask(editSession, BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR));
+ final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR));
final SolidBlockMask solid = new SolidBlockMask(editSession);
final RadiusMask radius = new RadiusMask(0, (int) size);
visitor = new RecursiveVisitor(vector -> solid.test(vector) && radius.test(vector) && adjacent.test(vector), function -> true);
@@ -42,30 +44,32 @@ public class LayerBrush implements Brush {
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
Operations.completeBlindly(visitor);
BlockVectorSet visited = visitor.getVisited();
- BlockStateHolder firstPattern = layers[0];
- visitor = new RecursiveVisitor((Mask) pos -> {
- int depth = visitor.getDepth() + 1;
- if (depth > 1) {
- boolean found = false;
- int previous = layers[depth - 1].getInternalId();
- int previous2 = layers[depth - 2].getInternalId();
- for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
- mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
- if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
- mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2);
- if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
- found = true;
- break;
- } else {
- return false;
+ visitor = new RecursiveVisitor(new Mask() {
+ @Override
+ public boolean test(BlockVector3 pos) {
+ int depth = visitor.getDepth() + 1;
+ if (depth > 1) {
+ boolean found = false;
+ int previous = layers[depth - 1].getInternalId();
+ int previous2 = layers[depth - 2].getInternalId();
+ for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
+ mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
+ if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
+ mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2);
+ if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
+ found = true;
+ break;
+ } else {
+ return false;
+ }
}
}
+ if (!found) {
+ return false;
+ }
}
- if (!found) {
- return false;
- }
+ return !adjacent.test(pos);
}
- return !adjacent.test(pos);
}, pos -> {
int depth = visitor.getDepth();
BlockStateHolder currentPattern = layers[depth];
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java
index 41062cffd..8e953f8eb 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java
@@ -79,7 +79,7 @@ public class EmptyClipboard implements Clipboard {
}
@Override
- public BlockState getLazyBlock(BlockVector3 position) {
+ public BlockState getBlock(BlockVector3 position) {
return EditSession.nullBlock;
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java
index 625d2687c..1b35bf82f 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java
@@ -52,17 +52,12 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
@Override
public BlockState getBlock(BlockVector3 location) {
- return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
+ return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
@Override
- public BlockState getLazyBlock(BlockVector3 location) {
- return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
- }
-
- @Override
- public BlockState getLazyBlock(int x, int y, int z) {
- return super.getLazyBlock(x + dx, y + dy, z + dz);
+ public BlockState getBlock(int x, int y, int z) {
+ return super.getBlock(x + dx, y + dy, z + dz);
}
@Override
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/EmptyExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/EmptyExtent.java
index 886c02150..04ff96b56 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/EmptyExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/EmptyExtent.java
@@ -50,7 +50,7 @@ public class EmptyExtent implements Extent {
}
@Override
- public BlockState getLazyBlock(BlockVector3 position) {
+ public BlockState getBlock(int x, int y, int z) {
return EditSession.nullBlock;
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java
index e8853dda8..fd761b76c 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java
@@ -112,8 +112,6 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
public > boolean setBlock(final BlockVector3 location, final B block) throws WorldEditException {
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
}
-
-
@Override
public > boolean setBlock(int x, int y, int z, final B block) throws WorldEditException {
@@ -121,12 +119,12 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
}
@Override
- public BlockState getLazyBlock(BlockVector3 location) {
- return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
+ public BlockState getBlock(BlockVector3 location) {
+ return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
@Override
- public BlockState getLazyBlock(int x, int y, int z) {
+ public BlockState getBlock(int x, int y, int z) {
int combinedId4Data = queue.getCombinedId4Data(x, y, z, 0);
BlockType type = BlockTypes.getFromStateId(combinedId4Data);
BlockState state = type.withStateId(combinedId4Data);
@@ -157,11 +155,6 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
return world.getEntities(region);
}
- @Override
- public BlockState getBlock(final BlockVector3 position) {
- return this.getLazyBlock(position);
- }
-
@Override
public boolean setBiome(final BlockVector2 position, final BiomeType biome) {
queue.setBiome(position.getBlockX(), position.getBlockZ(), biome);
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java
index ae1d1c7be..75a8955e4 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java
@@ -66,7 +66,7 @@ public class NullExtent extends FaweRegionExtent {
}
@Override
- public BlockState getLazyBlock(final BlockVector3 arg0) {
+ public BlockState getBlock(int x, int y, int z) {
if(reason != null) {
throw new FaweException(reason);
}else {
@@ -74,6 +74,15 @@ public class NullExtent extends FaweRegionExtent {
}
}
+ @Override
+ public BaseBlock getFullBlock(int x, int y, int z) {
+ if(reason != null) {
+ throw new FaweException(reason);
+ }else {
+ return null;
+ }
+ }
+
@Override
public boolean setBiome(final BlockVector2 arg0, final BiomeType arg1) {
if(reason != null) {
@@ -101,15 +110,6 @@ public class NullExtent extends FaweRegionExtent {
}
}
- @Override
- public BlockState getLazyBlock(int x, int y, int z) {
- if(reason != null) {
- throw new FaweException(reason);
- }else {
- return null;
- }
- }
-
@Override
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
if(reason != null) {
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java
index 469a689a1..3e8132a5e 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java
@@ -47,20 +47,15 @@ public class PositionTransformExtent extends ResettableExtent {
}
@Override
- public BlockState getLazyBlock(int x, int y, int z) {
- return super.getLazyBlock(getPos(BlockVector3.at(x, y, z)));
- }
-
- @Override
- public BlockState getLazyBlock(BlockVector3 position) {
- return super.getLazyBlock(getPos(position));
+ public BlockState getBlock(int x, int y, int z) {
+ return super.getBlock(getPos(BlockVector3.at(x, y, z)));
}
@Override
public BlockState getBlock(BlockVector3 position) {
return super.getBlock(getPos(position));
}
-
+
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
return super.getFullBlock(getPos(position));
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java
index 270792162..a8b7bb6c6 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java
@@ -63,12 +63,12 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
}
@Override
- public BlockState getLazyBlock(int x, int y, int z) {
+ public BlockState getBlock(int x, int y, int z) {
if (!limit.MAX_CHECKS()) {
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
return EditSession.nullBlock;
} else {
- return extent.getLazyBlock(x, y, z);
+ return extent.getBlock(x, y, z);
}
}
@@ -88,8 +88,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
}
@Override
- public BlockState getLazyBlock(BlockVector3 location) {
- return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
+ public BlockState getBlock(BlockVector3 location) {
+ return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
@Override
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TemporalExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TemporalExtent.java
index d678f7b7f..503286fd6 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TemporalExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TemporalExtent.java
@@ -58,19 +58,11 @@ public class TemporalExtent extends AbstractDelegateExtent {
}
@Override
- public BlockState getLazyBlock(BlockVector3 position) {
- if (position.getX() == x && position.getY() == y && position.getZ() == z) {
- return block.toImmutableState();
- }
- return super.getLazyBlock(position);
- }
-
- @Override
- public BlockState getLazyBlock(int x, int y, int z) {
+ public BlockState getBlock(int x, int y, int z) {
if (this.x == x && this.y == y && this.z == z) {
return block.toImmutableState();
}
- return super.getLazyBlock(x, y, z);
+ return super.getBlock(x, y, z);
}
@Override
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java
index 0fae70cb3..a4d33cf8f 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java
@@ -1,6 +1,7 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.WorldEditException;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent;
@@ -14,7 +15,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
public class TransformExtent extends BlockTransformExtent {
- private final MutableBlockVector3 mutable = new MutableBlockVector3();
+ private final MutableVector3 mutable1 = new MutableVector3();
+ private final MutableBlockVector3 mutable2 = new MutableBlockVector3();
private BlockVector3 min;
private int maxy;
@@ -53,56 +55,45 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) {
min = pos;
}
- mutable.mutX(((pos.getX() - min.getX())));
- mutable.mutY(((pos.getY() - min.getY())));
- mutable.mutZ(((pos.getZ() - min.getZ())));
- MutableVector3 tmp = new MutableVector3(getTransform().apply(mutable.toVector3()));
- tmp.mutX((tmp.getX() + min.getX()));
- tmp.mutY((tmp.getY() + min.getY()));
- tmp.mutZ((tmp.getZ() + min.getZ()));
- return tmp.toBlockPoint();
+ mutable1.mutX(((pos.getX() - min.getX())));
+ mutable1.mutY(((pos.getY() - min.getY())));
+ mutable1.mutZ(((pos.getZ() - min.getZ())));
+ Vector3 tmp = getTransform().apply(mutable1);
+ mutable2.mutX((tmp.getX() + min.getX()));
+ mutable2.mutY((tmp.getY() + min.getY()));
+ mutable2.mutZ((tmp.getZ() + min.getZ()));
+ return mutable2;
}
public BlockVector3 getPos(int x, int y, int z) {
if (min == null) {
min = BlockVector3.at(x, y, z);
}
- mutable.mutX(((x - min.getX())));
- mutable.mutY(((y - min.getY())));
- mutable.mutZ(((z - min.getZ())));
- MutableVector3 tmp = new MutableVector3(getTransform().apply(mutable.toVector3()));
- tmp.mutX((tmp.getX() + min.getX()));
- tmp.mutY((tmp.getY() + min.getY()));
- tmp.mutZ((tmp.getZ() + min.getZ()));
+ mutable1.mutX(((x - min.getX())));
+ mutable1.mutY(((y - min.getY())));
+ mutable1.mutZ(((z - min.getZ())));
+ Vector3 tmp = getTransform().apply(mutable1);
+ mutable2.mutX((tmp.getX() + min.getX()));
+ mutable2.mutY((tmp.getY() + min.getY()));
+ mutable2.mutZ((tmp.getZ() + min.getZ()));
return tmp.toBlockPoint();
}
@Override
- public BlockState getLazyBlock(int x, int y, int z) {
- return transform(super.getLazyBlock(getPos(x, y, z)));
+ public BlockState getBlock(int x, int y, int z) {
+ BlockVector3 p = getPos(x, y, z);
+ return transform(super.getBlock(p.getX(), p.getY(), p.getZ()));
}
- @Override
- public BlockState getLazyBlock(BlockVector3 position) {
- return transform(super.getLazyBlock(getPos(position)));
- }
-
- @Override
- public BlockState getBlock(BlockVector3 position) {
- return transform(super.getBlock(getPos(position)));
- }
-
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
return transform(super.getFullBlock(getPos(position)));
}
@Override
- public BiomeType getBiome(BlockVector2 position) {
- mutable.mutX(position.getBlockX());
- mutable.mutZ(position.getBlockZ());
- mutable.mutY(0);
- return super.getBiome(getPos(mutable).toBlockVector2());
+ public BiomeType getBiome(int x, int z) {
+ BlockVector3 p = getPos(x, 0, z);
+ return super.getBiome(p.getX(), p.getZ());
}
@Override
@@ -117,10 +108,8 @@ public class TransformExtent extends BlockTransformExtent {
}
@Override
- public boolean setBiome(BlockVector2 position, BiomeType biome) {
- mutable.mutX(position.getBlockX());
- mutable.mutZ(position.getBlockZ());
- mutable.mutY(0);
- return super.setBiome(getPos(mutable).toBlockVector2(), biome);
+ public boolean setBiome(int x, int y, int z, BiomeType biome) {
+ BlockVector3 p = getPos(x, y, z);
+ return super.setBiome(p.getX(), p.getY(), p.getZ(), biome);
}
}
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 fd6e472fe..ece6b91db 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,5 +1,6 @@
package com.boydti.fawe.object.function.mask;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Mask2D;
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask2.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask2.java
new file mode 100644
index 000000000..8cb5f6ffc
--- /dev/null
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask2.java
@@ -0,0 +1,11 @@
+package com.boydti.fawe.object.mask;
+
+import com.sk89q.worldedit.function.mask.AbstractMask;
+import com.sk89q.worldedit.math.BlockVector3;
+
+public class AdjacentAnyMask2 extends AbstractMask {
+ @Override
+ public boolean test(BlockVector3 vector) {
+ return false;
+ }
+}
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 01afbac85..f98776e89 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
@@ -19,9 +19,9 @@ public class DataMask extends AbstractExtentMask implements ResettableMask {
public boolean test(BlockVector3 vector) {
Extent extent = getExtent();
if (data != -1) {
- return extent.getLazyBlock(vector).getInternalPropertiesId() == data;
+ return extent.getBlock(vector).getInternalPropertiesId() == data;
} else {
- data = extent.getLazyBlock(vector).getInternalPropertiesId();
+ data = extent.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 7b7705172..69274c22f 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
@@ -19,9 +19,9 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask {
public boolean test(BlockVector3 vector) {
Extent extent = getExtent();
if (combined != -1) {
- return extent.getLazyBlock(vector).getInternalId() == combined;
+ return extent.getBlock(vector).getInternalId() == combined;
} else {
- combined = extent.getLazyBlock(vector).getInternalId();
+ combined = extent.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 e9b36b365..7070f3cbe 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
@@ -19,9 +19,9 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
public boolean test(BlockVector3 vector) {
Extent extent = getExtent();
if (id != -1) {
- return extent.getLazyBlock(vector).getInternalBlockTypeId() == id;
+ return extent.getBlock(vector).getInternalBlockTypeId() == id;
} else {
- id = extent.getLazyBlock(vector).getInternalBlockTypeId();
+ id = extent.getBlock(vector).getInternalBlockTypeId();
return true;
}
}
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 cd740f93f..dafc52a9b 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
@@ -7,11 +7,8 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockTypes;
public class SurfaceMask extends AdjacentAnyMask {
- private final transient Extent extent;
-
public SurfaceMask(Extent extent) {
super(getMask(extent));
- this.extent = extent;
}
public static Mask getMask(Extent extent) {
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AbstractExtentPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AbstractExtentPattern.java
index 1e6a8204f..a6566eb57 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AbstractExtentPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AbstractExtentPattern.java
@@ -2,6 +2,8 @@ package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.world.block.BaseBlock;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java
index 64e3ee009..d94340204 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java
@@ -1,11 +1,8 @@
package com.boydti.fawe.object.pattern;
-import com.boydti.fawe.Fawe;
-import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.DataAnglePattern;
import com.boydti.fawe.util.TextureHolder;
-import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -14,14 +11,12 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
-import java.io.IOException;
-
public class AngleColorPattern extends DataAnglePattern {
- protected transient TextureUtil util;
+ protected transient TextureHolder holder;
public AngleColorPattern(Extent extent, TextureHolder holder, int distance) {
super(extent, distance);
- this.util = holder.getTextureUtil();
+ this.holder = holder.getTextureUtil();
}
public int getColor(int color, int slope) {
@@ -33,33 +28,20 @@ public class AngleColorPattern extends DataAnglePattern {
return (((color >> 24) & 0xFF) << 24) + (newRed << 16) + (newGreen << 8) + (newBlue << 0);
}
- @Override
- public void apply(FilterBlock block) {
- BlockState state = block.getState();
- int slope = getSlope(state, block);
- if (slope == -1) return;
- int color = util.getColor(state.getBlockType());
- if (color == 0) return;
- int newColor = getColor(color, slope);
- BlockType newBlock = util.getNearestBlock(newColor);
- if (newBlock == null) return;
- newBlock.apply(block);
- }
-
@Override
public BaseBlock apply(BlockVector3 position) {
BaseBlock block = extent.getFullBlock(position);
- int slope = getSlope(block, position);
+ int slope = getSlope(block, position, extent);
if (slope == -1) return block;
- int color = util.getColor(block.getBlockType());
+ int color = holder.getTextureUtil().getColor(block.getBlockType());
if (color == 0) return block;
int newColor = getColor(color, slope);
- return util.getNearestBlock(newColor).getDefaultState().toBaseBlock();
+ return holder.getTextureUtil().getNearestBlock(newColor).getDefaultState().toBaseBlock();
}
@Override
- public int getSlope(BlockStateHolder block, BlockVector3 vector) {
- int slope = super.getSlope(block, vector);
+ public int getSlope(BlockStateHolder block, BlockVector3 vector, Extent extent) {
+ int slope = super.getSlope(block, vector, extent);
if (slope != -1) {
int x = vector.getBlockX();
int y = vector.getBlockY();
@@ -76,15 +58,15 @@ public class AngleColorPattern extends DataAnglePattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
- BlockStateHolder block = extent.getBlock(getPosition);
- int slope = getSlope(block, getPosition);
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BlockStateHolder block = get.getBlock(extent);
+ int slope = getSlope(block, get, extent);
if (slope == -1) return false;
- int color = util.getColor(block.getBlockType());
+ int color = holder.getTextureUtil().getColor(block.getBlockType());
if (color == 0) return false;
int newColor = getColor(color, slope);
- BlockType newBlock = util.getNearestBlock(newColor);
+ BlockType newBlock = holder.getTextureUtil().getNearestBlock(newColor);
if (newBlock == null) return false;
- return extent.setBlock(setPosition, newBlock.getDefaultState());
+ return set.setBlock(extent, newBlock.getDefaultState());
}
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java
index bb8395a8c..c8637cf70 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java
@@ -1,19 +1,14 @@
package com.boydti.fawe.object.pattern;
-import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.TextureHolder;
import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
-import com.sk89q.worldedit.world.block.BlockTypes;
import java.awt.Color;
-import java.io.IOException;
public class AverageColorPattern extends AbstractExtentPattern {
private transient TextureHolder holder;
@@ -35,19 +30,14 @@ public class AverageColorPattern extends AbstractExtentPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
- BlockType blockType = extent.getBlockType(getPosition);
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BlockType blockType = get.getBlock(extent).getBlockType();
TextureUtil util = holder.getTextureUtil();
int currentColor = util.getColor(blockType);
if (currentColor == 0) return false;
int newColor = util.averageColor(currentColor, color);
BlockType newBlock = util.getNearestBlock(newColor);
if (newBlock == blockType) return false;
- return extent.setBlock(setPosition, newBlock.getDefaultState());
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
+ return set.setBlock(extent, newBlock.getDefaultState());
}
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BiomePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BiomePattern.java
index ff031dde7..1446feb74 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BiomePattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BiomePattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -10,7 +11,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import java.io.IOException;
public class BiomePattern extends ExistingPattern {
- private transient MutableBlockVector2 mutable = new MutableBlockVector2();
private final BiomeType biome;
public BiomePattern(Extent extent, BiomeType biome) {
@@ -24,8 +24,8 @@ public class BiomePattern extends ExistingPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 getPosition) throws WorldEditException {
- return extent.setBiome(set.getBlockX(), set.getBlockY(), set.getBlockZ(), biome);
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ return set.setBiome(extent, biome);
}
public class BiomePatternException extends RuntimeException {
@@ -45,9 +45,4 @@ public class BiomePattern extends ExistingPattern {
return this;
}
}
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- mutable = new MutableBlockVector2();
- }
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java
index a9b9a5148..9bfafc9c5 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java
@@ -1,6 +1,7 @@
package com.boydti.fawe.object.pattern;
import com.boydti.fawe.Fawe;
+import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.boydti.fawe.util.FaweTimer;
@@ -17,17 +18,18 @@ import java.io.IOException;
import java.util.UUID;
public class BufferedPattern extends AbstractPattern implements ResettablePattern {
- protected transient LocalBlockVectorSet set = new LocalBlockVectorSet();
- protected transient FaweTimer timer;
- protected transient long[] actionTime;
+ protected final LocalBlockVectorSet set = new LocalBlockVectorSet();
+ protected final FaweTimer timer;
+ protected final long[] actionTime;
protected final Pattern pattern;
protected final UUID uuid;
public BufferedPattern(FawePlayer fp, Pattern parent) {
this.uuid = fp.getUUID();
- this.actionTime = fp.getMeta("lastActionTime");
- if (actionTime == null) fp.setMeta("lastActionTime", actionTime = new long[2]);
+ long[] tmp = fp.getMeta("lastActionTime");
+ if (tmp == null) fp.setMeta("lastActionTime", tmp = new long[2]);
+ actionTime = tmp;
this.pattern = parent;
this.timer = Fawe.get().getTimer();
}
@@ -38,16 +40,12 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
- long now = timer.getTick();
- try {
- if (!set(setPosition)) {
- return false;
- }
- return pattern.apply(extent, setPosition, getPosition);
- } catch (UnsupportedOperationException ignore) {
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ actionTime[1] = timer.getTick();
+ if (!set(get)) {
+ return false;
}
- return false;
+ return pattern.apply(extent, get, set);
}
public boolean set(BlockVector3 pos) {
@@ -63,17 +61,4 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter
actionTime[1] = actionTime[0];
actionTime[0] = now;
}
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- set = new LocalBlockVectorSet();
- timer = Fawe.get().getTimer();
- FawePlayer fp = Fawe.get().getCachedPlayer(uuid);
- if (fp != null) {
- this.actionTime = fp.getMeta("lastActionTime");
- if (actionTime == null) fp.setMeta("lastActionTime", actionTime = new long[2]);
- } else {
- actionTime = new long[2];
- }
- }
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java
index 30c7d85f4..7b3b580d2 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java
@@ -1,14 +1,14 @@
package com.boydti.fawe.object.pattern;
-import com.boydti.fawe.FaweCache;
-import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
+import com.boydti.fawe.beta.DelegateFilterBlock;
+import com.boydti.fawe.beta.FilterBlock;
+import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.world.block.BaseBlock;
+import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
-import com.sk89q.worldedit.world.block.BlockTypes;
-
import static com.google.common.base.Preconditions.checkNotNull;
@@ -25,6 +25,24 @@ public class DataPattern extends AbstractExtentPattern {
public BaseBlock apply(BlockVector3 position) {
BaseBlock oldBlock = getExtent().getFullBlock(position);
BaseBlock newBlock = pattern.apply(position);
- return oldBlock.withPropertyId(newBlock.getInternalPropertiesId()).toBaseBlock();
+ return oldBlock.toBlockState().withProperties(newBlock.toBlockState()).toBaseBlock(newBlock.getNbtData());
+ }
+
+ @Override
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BaseBlock oldBlock = get.getFullBlock(extent);
+ BaseBlock newBlock = pattern.apply(get);
+
+ BlockState oldState = oldBlock.toBlockState();
+ BlockState newState = oldState.withProperties(newBlock.toBlockState());
+ if (newState != oldState) {
+ if (oldBlock.hasNbtData()) {
+ set.setFullBlock(extent, newState.toBaseBlock(oldBlock.getNbtData()));
+ } else {
+ set.setBlock(extent, newState);
+ }
+ return true;
+ }
+ return false;
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java
index 1647b3662..2fa5ba2a3 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java
@@ -1,21 +1,16 @@
package com.boydti.fawe.object.pattern;
-import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.TextureHolder;
import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
-import java.io.IOException;
-
public class DesaturatePattern extends AbstractPattern {
- private transient TextureHolder holder;
+ private final TextureHolder holder;
private final Extent extent;
private final double value;
@@ -29,7 +24,11 @@ public class DesaturatePattern extends AbstractPattern {
public BaseBlock apply(BlockVector3 position) {
BlockType block = extent.getBlockType(position);
TextureUtil util = holder.getTextureUtil();
- int color = util.getColor(block);
+ int color = getColor(util.getColor(block));
+ return util.getNearestBlock(color).getDefaultState().toBaseBlock();
+ }
+
+ public int getColor(int color) {
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 0) & 0xFF;
@@ -39,35 +38,22 @@ public class DesaturatePattern extends AbstractPattern {
int green = (int) (g + value * (l - g));
int blue = (int) (b + value * (l - b));
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
- return util.getNearestBlock(newColor).getDefaultState().toBaseBlock();
+ return newColor;
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
- BlockType block = extent.getBlockType(getPosition);
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BlockType type = get.getBlock(extent).getBlockType();
TextureUtil util = holder.getTextureUtil();
- int color = util.getColor(block);
- int r = (color >> 16) & 0xFF;
- int g = (color >> 8) & 0xFF;
- int b = (color >> 0) & 0xFF;
- int alpha = (color >> 24) & 0xFF;
- double l = 0.3f * r + 0.6f * g + 0.1f * b;
- int red = (int) (r + value * (l - r));
- int green = (int) (g + value * (l - g));
- int blue = (int) (b + value * (l - b));
- int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
+ int color = util.getColor(type);
+ int newColor = getColor(color);
if (newColor == color) {
return false;
}
- BlockType newBlock = util.getNextNearestBlock(newColor);
- if (block.equals(newBlock)) {
+ BlockType newType = util.getNextNearestBlock(newColor);
+ if (type.equals(newType)) {
return false;
}
- return extent.setBlock(setPosition, newBlock.getDefaultState());
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
+ return set.setBlock(extent, newType.getDefaultState());
}
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExistingPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExistingPattern.java
index e345a1705..35f5299c9 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExistingPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExistingPattern.java
@@ -1,12 +1,10 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
-import com.sk89q.worldedit.world.block.BlockTypes;
public class ExistingPattern extends AbstractExtentPattern {
public ExistingPattern(Extent extent) {
@@ -19,10 +17,10 @@ public class ExistingPattern extends AbstractExtentPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
- if (set.equals(get)) {
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ if (set == get || set.equals(get)) {
return false;
}
- return extent.setBlock(set, extent.getBlock(get));
+ return set.setFullBlock(extent, get.getFullBlock(extent));
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java
index c023f4ff3..50f27aaf2 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -23,9 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
* greater than {@code 0}.
*/
public class ExpressionPattern extends AbstractPattern {
-
- public String input;
- private transient Expression expression;
+ private final Expression expression;
/**
* Create a new instance.
@@ -35,7 +34,6 @@ public class ExpressionPattern extends AbstractPattern {
*/
public ExpressionPattern(String input) throws ExpressionException {
checkNotNull(input);
- this.input = input;
this.expression = Expression.compile(input, "x", "y", "z");
}
@@ -65,13 +63,4 @@ public class ExpressionPattern extends AbstractPattern {
throw e;
}
}
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- try {
- this.expression = Expression.compile(input, "x", "y", "z");
- } catch (ExpressionException e) {
- e.printStackTrace();
- }
- }
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java
index 015eb990d..8e234a9b4 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java
@@ -36,9 +36,8 @@ public class FullClipboardPattern extends AbstractExtentPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
- Region region = clipboard.getRegion();
- ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), clipboard.getOrigin(), extent, setPosition);
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), clipboard.getOrigin(), extent, set);
copy.setSourceMask(new ExistingBlockMask(clipboard));
Operations.completeBlindly(copy);
return true;
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear2DBlockPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear2DBlockPattern.java
index 2e2826525..681b96892 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear2DBlockPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear2DBlockPattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -27,11 +28,11 @@ public class Linear2DBlockPattern extends AbstractPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
int index = (get.getBlockX() + get.getBlockZ()) % patternsArray.length;
if (index < 0) {
index += patternsArray.length;
}
- return patternsArray[index].apply(extent, set, get);
+ return patternsArray[index].apply(extent, get, set);
}
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear3DBlockPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear3DBlockPattern.java
index c52c349e9..843d07c8e 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear3DBlockPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear3DBlockPattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -27,11 +28,11 @@ public class Linear3DBlockPattern extends AbstractPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
int index = (get.getBlockX() + get.getBlockY() + get.getBlockZ()) % patternsArray.length;
if (index < 0) {
index += patternsArray.length;
}
- return patternsArray[index].apply(extent, set, get);
+ return patternsArray[index].apply(extent, get, set);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/LinearBlockPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/LinearBlockPattern.java
index 2614dde7a..7cfd81991 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/LinearBlockPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/LinearBlockPattern.java
@@ -27,11 +27,11 @@ public class LinearBlockPattern extends AbstractPattern implements ResettablePat
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
if (index == patternsArray.length) {
index = 0;
}
- return patternsArray[index++].apply(extent, set, get);
+ return patternsArray[index++].apply(extent, get, set);
}
@Override
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 8f9f72550..4858a92b5 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
@@ -1,5 +1,7 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
+import com.boydti.fawe.beta.SingleFilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -12,32 +14,30 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
public class MaskedPattern extends AbstractPattern {
- private final PatternExtent patternExtent;
- private final Pattern secondaryPattern;
+ private final Pattern primary;
+ private final Pattern secondary;
private Mask mask;
- public MaskedPattern(Mask mask, PatternExtent primary, Pattern secondary) {
+ public MaskedPattern(Mask mask, Pattern primary, Pattern secondary) {
this.mask = mask;
- this.patternExtent = primary;
- this.secondaryPattern = secondary;
+ this.primary = primary;
+ this.secondary = secondary;
}
@Override
public BaseBlock apply(BlockVector3 position) {
- patternExtent.setTarget(position);
if (mask.test(position)) {
- return patternExtent.getAndResetTarget().toBaseBlock();
+ return primary.apply(position);
}
- return secondaryPattern.apply(position);
+ return secondary.apply(position);
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
- patternExtent.setTarget(get);
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
if (mask.test(get)) {
- return patternExtent.getAndResetTarget(extent, set, get);
+ return primary.apply(extent, get, set);
}
- return secondaryPattern.apply(extent, set, get);
+ return secondary.apply(extent, get, set);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java
index 3accfc1e9..93cf0f550 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java
@@ -1,5 +1,7 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.DelegateFilterBlock;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -15,7 +17,7 @@ import java.io.IOException;
public class NoXPattern extends AbstractPattern {
private final Pattern pattern;
-// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
+ private final MutableBlockVector3 mutable = new MutableBlockVector3();
public NoXPattern(Pattern pattern) {
this.pattern = pattern;
@@ -23,21 +25,15 @@ public class NoXPattern extends AbstractPattern {
@Override
public BaseBlock apply(BlockVector3 pos) {
-// mutable.mutY((pos.getY()));
-// mutable.mutZ((pos.getZ()));
-// return pattern.apply(mutable);
- return pattern.apply(pos);
+ mutable.mutY((pos.getY()));
+ mutable.mutZ((pos.getZ()));
+ return pattern.apply(mutable);
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
-// mutable.mutY((get.getY()));
-// mutable.mutZ((get.getZ()));
- return pattern.apply(extent, set, get);
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
-// mutable = new MutableBlockVector3();
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ mutable.mutY((get.getY()));
+ mutable.mutZ((get.getZ()));
+ return pattern.apply(extent, mutable, set);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java
index 6c8303cff..62e4de18a 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java
@@ -1,5 +1,7 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.DelegateFilterBlock;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -15,29 +17,23 @@ import java.io.IOException;
public class NoYPattern extends AbstractPattern {
private final Pattern pattern;
+ private final MutableBlockVector3 mutable = new MutableBlockVector3();
public NoYPattern(Pattern pattern) {
this.pattern = pattern;
}
-// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
-
@Override
public BaseBlock apply(BlockVector3 pos) {
-// mutable.mutX((pos.getX()));
-// mutable.mutZ((pos.getZ()));
- return pattern.apply(pos);
+ mutable.mutX((pos.getX()));
+ mutable.mutZ((pos.getZ()));
+ return pattern.apply(mutable);
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
-// mutable.mutX((get.getX()));
-// mutable.mutZ((get.getZ()));
- return pattern.apply(extent, set, get);
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
-// mutable = new MutableBlockVector3();
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ mutable.mutX((get.getX()));
+ mutable.mutZ((get.getZ()));
+ return pattern.apply(extent, mutable, set);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java
index 2a4e3f362..e01894ae4 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java
@@ -1,5 +1,7 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.DelegateFilterBlock;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -20,24 +22,19 @@ public class NoZPattern extends AbstractPattern {
this.pattern = pattern;
}
-// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
+ private transient MutableBlockVector3 mutable = new MutableBlockVector3();
@Override
public BaseBlock apply(BlockVector3 pos) {
-// mutable.mutX((pos.getX()));
-// mutable.mutY((pos.getY()));
- return pattern.apply(pos);
+ mutable.mutX((pos.getX()));
+ mutable.mutY((pos.getY()));
+ return pattern.apply(mutable);
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
-// mutable.mutX((get.getX()));
-// mutable.mutY((get.getY()));
- return pattern.apply(extent, set, get);
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
-// mutable = new MutableBlockVector3();
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ mutable.mutX((get.getX()));
+ mutable.mutY((get.getY()));
+ return pattern.apply(extent, mutable, set);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java
index fd34ba1eb..bc53d1864 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@@ -15,7 +16,7 @@ import java.io.IOException;
public class OffsetPattern extends AbstractPattern {
private final int dx, dy, dz;
-// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
+ private transient MutableBlockVector3 mutable = new MutableBlockVector3();
private final Pattern pattern;
public OffsetPattern(Pattern pattern, int dx, int dy, int dz) {
@@ -27,24 +28,17 @@ public class OffsetPattern extends AbstractPattern {
@Override
public BaseBlock apply(BlockVector3 position) {
-// mutable.mutX((position.getX() + dx));
-// mutable.mutY((position.getY() + dy));
-// mutable.mutZ((position.getZ() + dz));
-// return pattern.apply(mutable);
- return pattern.apply(BlockVector3.at(position.getX() + dx, position.getY() + dy, position.getZ() + dz));
+ mutable.mutX((position.getX() + dx));
+ mutable.mutY((position.getY() + dy));
+ mutable.mutZ((position.getZ() + dz));
+ return pattern.apply(mutable);
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
-// mutable.mutX((get.getX() + dx));
-// mutable.mutY((get.getY() + dy));
-// mutable.mutZ((get.getZ() + dz));
-// return pattern.apply(extent, set, mutable);
- return pattern.apply(extent, set, BlockVector3.at(get.getX() + dx, get.getY() + dy, get.getZ() + dz));
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
-// mutable = new MutableBlockVector3();
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ mutable.mutX((get.getX() + dx));
+ mutable.mutY((get.getY() + dy));
+ mutable.mutZ((get.getZ() + dz));
+ return pattern.apply(extent, get, mutable);
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java
deleted file mode 100644
index 534c9c694..000000000
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package com.boydti.fawe.object.pattern;
-
-import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
-import com.sk89q.worldedit.entity.BaseEntity;
-import com.sk89q.worldedit.entity.Entity;
-import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.function.operation.Operation;
-import com.sk89q.worldedit.function.pattern.AbstractPattern;
-import com.sk89q.worldedit.function.pattern.Pattern;
-import com.sk89q.worldedit.math.BlockVector2;
-import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.regions.Region;
-import com.sk89q.worldedit.util.Location;
-import com.sk89q.worldedit.world.biome.BiomeType;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.Nullable;
-
-public class PatternExtent extends AbstractPattern implements Extent {
- private final Pattern pattern;
- private transient BlockStateHolder block;
- private transient BlockVector3 target = BlockVector3.at(0, 0, 0);
-
- public PatternExtent(Pattern pattern) {
- this.pattern = pattern;
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- target = BlockVector3.at(0, 0, 0);
- }
-
- @Override
- public BlockVector3 getMinimumPoint() {
- return BlockVector3.at(Integer.MIN_VALUE, 0, Integer.MIN_VALUE);
- }
-
- @Override
- public BlockVector3 getMaximumPoint() {
- return BlockVector3.at(Integer.MAX_VALUE, 255, Integer.MAX_VALUE);
- }
-
- @Override
- public List extends Entity> getEntities(Region region) {
- return new ArrayList<>();
- }
-
- @Override
- public List extends Entity> getEntities() {
- return new ArrayList<>();
- }
-
- @Nullable
- @Override
- public Entity createEntity(Location location, BaseEntity entity) {
- return null;
- }
-
- @Override
- public BlockState getBlock(BlockVector3 position) {
- BlockStateHolder tmp = pattern.apply(position);
- if (position == target || (position.getX() == target.getX() && position.getY() == target.getY() && position.getZ() == target.getZ())) {
- block = tmp;
- } else {
- block = null;
- }
- return (BlockState) tmp;
- }
-
- public void setTarget(BlockVector3 vector) {
- this.target = vector;
- }
-
- public boolean getAndResetTarget(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
- BlockStateHolder result = block;
- if (result != null) {
- block = null;
- return extent.setBlock(set, result);
- } else {
- return pattern.apply(extent, set, target);
- }
- }
-
- public BlockStateHolder getAndResetTarget() {
- BlockStateHolder result = block;
- if (result != null) {
- block = null;
- return result;
- } else {
- return pattern.apply(target);
- }
- }
-
- @Override
- public BaseBlock getFullBlock(BlockVector3 position) {
- return getBlock(position).toBaseBlock();
- }
-
- @Override
- public BiomeType getBiome(BlockVector2 position) {
- return null;
- }
-
- @Override
- public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
- return false;
- }
-
- @Override
- public boolean setBiome(BlockVector2 position, BiomeType biome) {
- return false;
- }
-
- @Nullable
- @Override
- public Operation commit() {
- return null;
- }
-
- @Override
- public BaseBlock apply(BlockVector3 position) {
- return pattern.apply(position);
- }
-
- @Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
- return pattern.apply(extent, set, get);
- }
-}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java
index 2533017a2..cb2ee7301 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.string.MutableCharSequence;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.StringMan;
@@ -14,7 +15,6 @@ import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@@ -211,11 +211,11 @@ public class PropertyPattern extends AbstractExtentPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
- BaseBlock block = getExtent().getFullBlock(get);
- block = apply(block, null);
- if (block != null) {
- return extent.setBlock(set, block);
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ int ordinal = get.getOrdinal(extent);
+ int newOrdinal = transformed[ordinal];
+ if (newOrdinal != ordinal) {
+ set.setOrdinal(extent, newOrdinal);
}
return false;
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java
index 82863af97..77f5d0a3e 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java
@@ -38,7 +38,7 @@ public class RandomFullClipboardPattern extends AbstractPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
AffineTransform transform = new AffineTransform();
if (randomRotate) {
@@ -55,9 +55,9 @@ public class RandomFullClipboardPattern extends AbstractPattern {
Schematic schematic = new Schematic(clipboard);
Transform newTransform = holder.getTransform();
if (newTransform.isIdentity()) {
- schematic.paste(extent, setPosition, false);
+ schematic.paste(extent, set, false);
} else {
- schematic.paste(extent, setPosition, false, newTransform);
+ schematic.paste(extent, set, false, newTransform);
}
return true;
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java
index 904364739..d43d2a416 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
@@ -40,19 +41,10 @@ public class RandomOffsetPattern extends AbstractPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
- mutable.mutX((get.getX() + r.nextInt(dx2) - dx));
- mutable.mutY((get.getY() + r.nextInt(dy2) - dy));
- mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz));
- return pattern.apply(extent, set, mutable);
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- this.dx2 = dx * 2 + 1;
- this.dy2 = dy * 2 + 1;
- this.dz2 = dz * 2 + 1;
- this.r = new SplittableRandom();
- this.mutable = new MutableBlockVector3();
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ mutable.mutX((set.getX() + r.nextInt(dx2) - dx));
+ mutable.mutY((set.getY() + r.nextInt(dy2) - dy));
+ mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz));
+ return pattern.apply(extent, get, mutable);
}
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java
index e8f3f56ea..4900a5317 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
@@ -13,8 +14,8 @@ import java.io.IOException;
public class RelativePattern extends AbstractPattern implements ResettablePattern {
private final Pattern pattern;
- private transient BlockVector3 origin;
- private transient MutableBlockVector3 mutable = new MutableBlockVector3();
+ private BlockVector3 origin;
+ private final MutableBlockVector3 mutable = new MutableBlockVector3();
public RelativePattern(Pattern pattern) {
this.pattern = pattern;
@@ -32,19 +33,14 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
if (origin == null) {
- origin = get;
+ origin = set;
}
- mutable.mutX((get.getX() - origin.getX()));
- mutable.mutY((get.getY() - origin.getY()));
- mutable.mutZ((get.getZ() - origin.getZ()));
- return pattern.apply(extent, set, mutable);
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- mutable = new MutableBlockVector3();
+ mutable.mutX((set.getX() - origin.getX()));
+ mutable.mutY((set.getY() - origin.getY()));
+ mutable.mutZ((set.getZ() - origin.getZ()));
+ return pattern.apply(extent, get, mutable);
}
@Override
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java
index 5499b1507..53b04c2c8 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java
@@ -1,22 +1,19 @@
package com.boydti.fawe.object.pattern;
-import com.boydti.fawe.Fawe;
+import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.util.TextureHolder;
import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import java.awt.Color;
-import java.io.IOException;
public class SaturatePattern extends AbstractPattern {
- private transient TextureHolder holder;
+ private final TextureHolder holder;
private final int color;
private final Extent extent;
@@ -37,19 +34,14 @@ public class SaturatePattern extends AbstractPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
- BlockType block = extent.getBlockType(getPosition);
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BlockType block = get.getBlock(extent).getBlockType();
TextureUtil util = holder.getTextureUtil();
int currentColor = util.getColor(block);
if (currentColor == 0) return false;
int newColor = util.multiplyColor(currentColor, color);
BlockType newBlock = util.getNearestBlock(newColor);
if (newBlock.equals(block)) return false;
- return extent.setBlock(setPosition, newBlock.getDefaultState());
- }
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
+ return set.setBlock(extent, newBlock.getDefaultState());
}
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java
index 5c8a910f2..e91989de5 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java
@@ -1,22 +1,19 @@
package com.boydti.fawe.object.pattern;
-import com.boydti.fawe.Fawe;
+import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.util.TextureUtil;
+import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
-import java.io.IOException;
-
import static com.google.common.base.Preconditions.checkNotNull;
public class ShadePattern extends AbstractPattern {
- private transient TextureUtil util;
+ private final TextureUtil util;
private final Extent extent;
private final boolean darken;
@@ -33,8 +30,13 @@ public class ShadePattern extends AbstractPattern {
return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState().toBaseBlock();
}
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- util = Fawe.get().getCachedTextureUtil(true, 0, 100);
+ @Override
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BlockType type = get.getBlock(extent).getBlockType();
+ BlockType newType = (darken ? util.getDarkerBlock(type) : util.getLighterBlock(type));
+ if (type != newType) {
+ return set.setBlock(extent, newType.getDefaultState());
+ }
+ return false;
}
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java
index 3ac516bc7..b5ab2fd4c 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
@@ -9,6 +10,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
+import com.sk89q.worldedit.world.block.BlockType;
+import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.IOException;
import java.util.SplittableRandom;
@@ -17,25 +20,27 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
private final int dx, dy, dz;
private final Pattern pattern;
- private transient int dx2, dy2, dz2;
- private transient MutableBlockVector3 mutable;
- private transient boolean[] solid;
+ private final int dx2, dy2, dz2;
+ private final MutableBlockVector3 mutable;
private SplittableRandom r;
+ public static boolean[] getTypes() {
+ boolean[] types = new boolean[BlockTypes.size()];
+ for (BlockType type : BlockTypes.values) {
+ types[type.getInternalId()] = type.getMaterial().isSolid();
+ }
+ return types;
+ }
public SolidRandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) {
this.pattern = pattern;
this.dx = dx;
this.dy = dy;
this.dz = dz;
- init();
- }
- private void init() {
this.dx2 = dx * 2 + 1;
this.dy2 = dy * 2 + 1;
this.dz2 = dz * 2 + 1;
- solid = SolidBlockMask.getTypes();
this.r = new SplittableRandom();
this.mutable = new MutableBlockVector3();
}
@@ -46,7 +51,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
mutable.mutY((position.getY() + r.nextInt(dy2) - dy));
mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz));
BaseBlock block = pattern.apply(mutable);
- if (solid[block.getInternalBlockTypeId()]) {
+ if (block.getMaterial().isSolid()) {
return block;
} else {
return pattern.apply(position);
@@ -54,20 +59,15 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
- mutable.mutX((get.getX() + r.nextInt(dx2) - dx));
- mutable.mutY((get.getY() + r.nextInt(dy2) - dy));
- mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz));
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ mutable.mutX((set.getX() + r.nextInt(dx2) - dx));
+ mutable.mutY((set.getY() + r.nextInt(dy2) - dy));
+ mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz));
BlockStateHolder block = pattern.apply(mutable);
- if (solid[block.getInternalBlockTypeId()]) {
- return pattern.apply(extent, set, mutable);
+ if (block.getMaterial().isSolid()) {
+ return pattern.apply(extent, get, mutable);
} else {
- return pattern.apply(extent, set, get);
+ return pattern.apply(extent, get, set);
}
}
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- init();
- }
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java
index 92020ef76..36a63f937 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java
@@ -1,5 +1,6 @@
package com.boydti.fawe.object.pattern;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
@@ -13,20 +14,16 @@ import java.util.concurrent.ThreadLocalRandom;
public class SurfaceRandomOffsetPattern extends AbstractPattern {
private final Pattern pattern;
- private int moves;
+ private final int moves;
- private transient MutableBlockVector3 cur;
- private transient MutableBlockVector3[] buffer;
- private transient MutableBlockVector3[] allowed;
- private transient MutableBlockVector3 next;
+ private final MutableBlockVector3 cur;
+ private final MutableBlockVector3[] buffer;
+ private final MutableBlockVector3[] allowed;
+ private MutableBlockVector3 next;
public SurfaceRandomOffsetPattern(Pattern pattern, int distance) {
this.pattern = pattern;
this.moves = Math.min(255, distance);
- init();
- }
-
- private void init() {
cur = new MutableBlockVector3();
this.buffer = new MutableBlockVector3[BreadthFirstSearch.DIAGONAL_DIRECTIONS.length];
for (int i = 0; i < buffer.length; i++) {
@@ -110,9 +107,4 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
BlockStateHolder block = pattern.apply(v);
return !block.getBlockType().getMaterial().isMovementBlocker();
}
-
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- init();
- }
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java
index f2f67ab60..db0c437fe 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java
@@ -49,7 +49,7 @@ public class FaweQueueDelegateExtent extends DelegateFaweQueue {
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
- return getLazyBlock(x, y, z).getInternalId();
+ return getBlock(x, y, z).getInternalId();
}
@Override
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/IDelegateFaweQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/IDelegateFaweQueue.java
index c88cca70b..3404c1553 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/IDelegateFaweQueue.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/IDelegateFaweQueue.java
@@ -61,8 +61,8 @@ public interface IDelegateFaweQueue extends FaweQueue {
}
@Override
- default BlockState getLazyBlock(int x, int y, int z) {
- return getQueue().getLazyBlock(x, y, z);
+ default BlockState getBlock(int x, int y, int z) {
+ return getQueue().getBlock(x, y, z);
}
@Override
@@ -453,11 +453,6 @@ public interface IDelegateFaweQueue extends FaweQueue {
return getQueue().createEntity(location, entity);
}
- @Override
- default BlockState getLazyBlock(BlockVector3 position) {
- return getQueue().getLazyBlock(position);
- }
-
@Nullable
@Override
default Operation commit() {
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 ae0989472..d764cc68d 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
@@ -1,25 +1,18 @@
package com.boydti.fawe.util;
import com.boydti.fawe.Fawe;
-import com.boydti.fawe.FaweCache;
+import com.boydti.fawe.beta.SingleFilterBlock;
import com.boydti.fawe.config.Settings;
-import com.boydti.fawe.object.pattern.PatternExtent;
import com.boydti.fawe.util.image.ImageUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
-
-import com.sk89q.worldedit.util.command.binding.Text;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask;
-import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
-import com.sk89q.worldedit.world.registry.BundledBlockData;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArraySet;
@@ -27,12 +20,23 @@ import it.unimi.dsi.fastutil.longs.LongArrayList;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
-import java.io.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
@@ -61,14 +65,15 @@ public class TextureUtil implements TextureHolder {
public static TextureUtil fromMask(Mask mask) throws FileNotFoundException {
HashSet blocks = new HashSet<>();
- BlockPattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
- PatternExtent extent = new PatternExtent(pattern);
+
+ SingleFilterBlock extent = new SingleFilterBlock();
new MaskTraverser(mask).reset(extent);
+
TextureUtil tu = Fawe.get().getTextureUtil();
for (int typeId : tu.getValidBlockIds()) {
BlockType block = BlockTypes.get(typeId);
- pattern.setBlock(block.getDefaultState());
- if (mask.test(BlockVector3.ZERO)) {
+ extent.init(0, 0, 0, block.getDefaultState().toBaseBlock());
+ if (mask.test(extent)) {
blocks.add(block);
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java
index af1392e4a..2e954e9a8 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java
@@ -151,7 +151,7 @@ public class CuboidClipboard {
/* ------------------------------------------------------------------------------------------------------------- */
- public BaseBlock getBlock(BlockVector3 position) {
+ public BaseBlock getLazyBlock(BlockVector3 position) {
return getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
}
@@ -161,7 +161,7 @@ public class CuboidClipboard {
return clipboard.IMP.getBlock(x, y, z);
}
- public BaseBlock getLazyBlock(BlockVector3 position) {
+ public BaseBlock getBlock(BlockVector3 position) {
return getBlock(position);
}
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 b4390ec65..035021a68 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
@@ -100,6 +100,7 @@ import com.sk89q.worldedit.function.mask.MaskUnion;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
import com.sk89q.worldedit.function.mask.RegionMask;
+import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
@@ -164,7 +165,9 @@ import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -203,15 +206,15 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
private final World world;
private final String worldName;
private final FaweQueue queue;
- private final boolean wrapped;
- private final boolean fastMode;
+ private boolean wrapped;
+ private boolean fastMode;
private final HistoryExtent history;
private AbstractDelegateExtent bypassHistory;
private AbstractDelegateExtent bypassAll;
private final FaweLimit originalLimit;
private final FaweLimit limit;
private final FawePlayer player;
- private final FaweChangeSet changeTask;
+ private FaweChangeSet changeTask;
private final MutableBlockVector3 mutablebv = new MutableBlockVector3();
@@ -294,6 +297,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
this(world, null, null, null, null, null, true, null, null, null, blockBag, eventBus, event);
}
+ public void setExtent(AbstractDelegateExtent extent) {
+ new ExtentTraverser(this).setNext(extent);
+ }
+
/**
* The limit for this specific edit (blocks etc)
*
@@ -552,7 +559,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return mask, may be null
*/
public Mask getMask() {
- ExtentTraverser maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
+ ExtentTraverser maskingExtent = new ExtentTraverser(getExtent()).find(MaskingExtent.class);
return maskingExtent != null ? maskingExtent.get().getMask() : null;
}
@@ -562,28 +569,19 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return mask, may be null
*/
public Mask getSourceMask() {
- ExtentTraverser maskingExtent = new ExtentTraverser(this.extent).find(SourceMaskExtent.class);
+ ExtentTraverser maskingExtent = new ExtentTraverser(getExtent()).find(SourceMaskExtent.class);
return maskingExtent != null ? maskingExtent.get().getMask() : null;
}
public void addTransform(ResettableExtent transform) {
+ checkNotNull(transform);
wrapped = true;
- if (transform == null) {
- ExtentTraverser traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
- AbstractDelegateExtent next = extent;
- while (traverser != null && traverser.get() instanceof ResettableExtent) {
- traverser = traverser.next();
- next = traverser.get();
- }
- this.extent = next;
- return;
- } else {
- this.extent = transform.setExtent(extent);
- }
+ transform.setExtent(getExtent());
+ new ExtentTraverser(this).setNext(transform);
}
public @Nullable ResettableExtent getTransform() {
- ExtentTraverser traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
+ ExtentTraverser traverser = new ExtentTraverser(getExtent()).find(ResettableExtent.class);
if (traverser != null) {
return (ResettableExtent) traverser.get();
}
@@ -601,7 +599,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} else {
new MaskTraverser(mask).reset(this);
}
- ExtentTraverser maskingExtent = new ExtentTraverser(this.extent).find(SourceMaskExtent.class);
+ ExtentTraverser maskingExtent = new ExtentTraverser(getExtent()).find(SourceMaskExtent.class);
if (maskingExtent != null && maskingExtent.get() != null) {
Mask oldMask = maskingExtent.get().getMask();
if (oldMask instanceof ResettableMask) {
@@ -609,7 +607,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
maskingExtent.get().setMask(mask);
} else if (mask != Masks.alwaysTrue()) {
- this.extent = new SourceMaskExtent(this.extent, mask);
+ SourceMaskExtent next = new SourceMaskExtent(getExtent(), mask);
+ new ExtentTraverser(this).setNext(next);
}
}
@@ -618,13 +617,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
Mask existing = getSourceMask();
if (existing != null) {
if (existing instanceof MaskIntersection) {
- ((MaskIntersection) existing).add(mask);
- return;
+ Collection masks = new HashSet<>(((MaskIntersection) existing).getMasks());
+ masks.add(mask);
+ mask = new MaskIntersection(masks);
} else {
- MaskIntersection intersection = new MaskIntersection(existing);
- intersection.add(mask);
- mask = intersection;
+ mask = new MaskIntersection(existing, mask);
}
+ mask = mask.optimize();
}
setSourceMask(mask);
}
@@ -640,7 +639,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} else {
new MaskTraverser(mask).reset(this);
}
- ExtentTraverser maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
+ ExtentTraverser maskingExtent = new ExtentTraverser(getExtent()).find(MaskingExtent.class);
if (maskingExtent != null && maskingExtent.get() != null) {
Mask oldMask = maskingExtent.get().getMask();
if (oldMask instanceof ResettableMask) {
@@ -648,7 +647,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
maskingExtent.get().setMask(mask);
} else if (mask != Masks.alwaysTrue()) {
- this.extent = new MaskingExtent(this.extent, mask);
+ MaskingExtent next = new MaskingExtent(getExtent(), mask);
+ new ExtentTraverser(this).setNext(next);
}
}
@@ -658,13 +658,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return the survival simulation extent
*/
public SurvivalModeExtent getSurvivalExtent() {
- ExtentTraverser survivalExtent = new ExtentTraverser(this.extent).find(SurvivalModeExtent.class);
+ ExtentTraverser survivalExtent = new ExtentTraverser(getExtent()).find(SurvivalModeExtent.class);
if (survivalExtent != null) {
return survivalExtent.get();
} else {
- AbstractDelegateExtent extent = this.extent;
- SurvivalModeExtent survival = new SurvivalModeExtent(extent.getExtent(), getWorld());
- new ExtentTraverser(extent).setNext(survival);
+ SurvivalModeExtent survival = new SurvivalModeExtent(bypassAll.getExtent(), getWorld());
+ new ExtentTraverser(bypassAll).setNext(survival);
return survival;
}
}
@@ -691,7 +690,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (history == null) {
return;
}
- ExtentTraverser traverseHistory = new ExtentTraverser(this.extent).find(HistoryExtent.class);
+ ExtentTraverser traverseHistory = new ExtentTraverser(getExtent()).find(HistoryExtent.class);
if (disableHistory) {
if (traverseHistory != null && traverseHistory.exists()) {
ExtentTraverser beforeHistory = traverseHistory.previous();
@@ -699,11 +698,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (beforeHistory != null && beforeHistory.exists()) {
beforeHistory.setNext(afterHistory.get());
} else {
- extent = (AbstractDelegateExtent) afterHistory.get();
+ new ExtentTraverser(this).setNext(afterHistory.get());
}
}
} else if (traverseHistory == null || !traverseHistory.exists()) {
- ExtentTraverser traverseBypass = new ExtentTraverser(this.extent).find(bypassHistory);
+ ExtentTraverser traverseBypass = new ExtentTraverser(getExtent()).find(bypassHistory);
if (traverseBypass != null) {
ExtentTraverser beforeHistory = traverseBypass.previous();
beforeHistory.setNext(history);
@@ -750,7 +749,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (changeSet instanceof BlockBagChangeSet) {
missingBlocks = ((BlockBagChangeSet) changeSet).popMissing();
} else {
- ExtentTraverser find = new ExtentTraverser(extent).find(BlockBagExtent.class);
+ ExtentTraverser find = new ExtentTraverser(getExtent()).find(BlockBagExtent.class);
if (find != null && find.get() != null) {
missingBlocks = find.get().popMissing();
} else {
@@ -1068,7 +1067,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
@Override
@Nullable
public Entity createEntity(final com.sk89q.worldedit.util.Location location, final BaseEntity entity) {
- Entity result = this.extent.createEntity(location, entity);
+ Entity result = getExtent().createEntity(location, entity);
return result;
}
@@ -1142,30 +1141,22 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
@Override
public BlockVector3 getMinimumPoint() {
- if (extent != null) {
- return this.extent.getMinimumPoint();
- } else {
- return BlockVector3.at(-30000000, 0, -30000000);
- }
+ return getExtent().getMinimumPoint();
}
@Override
public BlockVector3 getMaximumPoint() {
- if (extent != null) {
- return this.extent.getMaximumPoint();
- } else {
- return BlockVector3.at(30000000, 255, 30000000);
- }
+ return getExtent().getMaximumPoint();
}
@Override
public List extends Entity> getEntities(final Region region) {
- return this.extent.getEntities(region);
+ return getExtent().getEntities(region);
}
@Override
public List extends Entity> getEntities() {
- return this.extent.getEntities();
+ return getExtent().getEntities();
}
/**
@@ -1186,7 +1177,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
@Override
public @Nullable Operation commit() {
- return extent.commit();
+ return getExtent().commit();
}
/**
@@ -1285,7 +1276,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return the number of blocks that matched the pattern
*/
public int countBlocks(final Region region, final Set searchBlocks) {
- Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(extent);
+ Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(getExtent());
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
@Override
public boolean apply(BlockVector3 position) throws WorldEditException {
@@ -1514,7 +1505,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
checkNotNull(position);
checkArgument(apothem >= 1, "apothem >= 1");
- Mask mask = new BlockTypeMask(this, blockType);
+ Mask mask = new SingleBlockTypeMask(this, blockType);
BlockVector3 adjustment = BlockVector3.ONE.multiply(apothem - 1);
Region region = new CuboidRegion(
getWorld(), // Causes clamping of Y range
@@ -1542,12 +1533,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
try {
if (hasExtraExtents()) {
- RegionVisitor visitor = new RegionVisitor(region, new BlockReplace(extent, (block)), this);
+ RegionVisitor visitor = new RegionVisitor(region, new BlockReplace(getExtent(), (block)), this);
Operations.completeBlindly(visitor);
this.changes += visitor.getAffected();
} else {
for (BlockVector3 blockVector3 : region) {
- if (this.extent.setBlock(blockVector3, block)) {
+ if (getExtent().setBlock(blockVector3, block)) {
changes++;
}
}
@@ -2004,7 +1995,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
blockMask);
- BlockReplace replace = new BlockReplace(this, new BlockPattern(fluid.getDefaultState()));
+ BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
// Around the origin in a 3x3 block
@@ -2917,7 +2908,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
}
this.changes++;
- pattern.apply(this.extent, position, position);
+ pattern.apply(getExtent(), position, position);
}
} catch (WorldEditException e) {
throw new RuntimeException(e);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/TileEntityBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/TileEntityBlock.java
index 3c67bf0e8..c193e5f4c 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/TileEntityBlock.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/TileEntityBlock.java
@@ -19,6 +19,9 @@
package com.sk89q.worldedit.blocks;
+import com.sk89q.jnbt.CompoundTag;
+import com.sk89q.jnbt.StringTag;
+import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.world.NbtValued;
/**
@@ -34,6 +37,17 @@ public interface TileEntityBlock extends NbtValued {
*
* @return tile entity ID, non-null string
*/
- String getNbtId();
+ default String getNbtId() {
+ CompoundTag nbtData = getNbtData();
+ if (nbtData == null) {
+ return "";
+ }
+ Tag idTag = nbtData.getValue().get("id");
+ if (idTag instanceof StringTag) {
+ return ((StringTag) idTag).getValue();
+ } else {
+ return "";
+ }
+ }
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java
index 4d222a1d5..fa09aa1a7 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java
@@ -235,7 +235,7 @@ public class PatternCommands extends MethodCommands {
min = 2,
max = 2
)
- public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
+ public Pattern iddatamask(Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
return new IdDataMaskPattern(extent, pattern, bitmask);
}
@@ -246,7 +246,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+ public Pattern id(Extent extent, Pattern pattern) {
return new IdPattern(extent, pattern);
}
@@ -257,7 +257,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+ public Pattern data(Extent extent, Pattern pattern) {
return new DataPattern(extent, pattern);
}
@@ -268,7 +268,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
+ public Pattern biome(Extent extent, BiomeType biome) {
return new BiomePattern(extent, biome);
}
@@ -279,7 +279,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+ public Pattern relative(Pattern pattern) {
return new RelativePattern(pattern);
}
@@ -292,7 +292,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+ public Pattern nox(Pattern pattern) {
return new NoXPattern(pattern);
}
@@ -303,7 +303,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+ public Pattern noy(Pattern pattern) {
return new NoYPattern(pattern);
}
@@ -314,7 +314,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+ public Pattern noz(Pattern pattern) {
return new NoZPattern(pattern);
}
@@ -325,9 +325,8 @@ public class PatternCommands extends MethodCommands {
min = 3,
max = 3
)
- public Pattern mask(Actor actor, LocalSession session, Mask mask, Pattern pass, Pattern fail) {
- PatternExtent extent = new PatternExtent(pass);
- return new MaskedPattern(mask, extent, fail);
+ public Pattern mask(Mask mask, Pattern pass, @Optional Pattern fail) {
+ return new MaskedPattern(mask, pass, fail);
}
@Command(
@@ -337,7 +336,7 @@ public class PatternCommands extends MethodCommands {
min = 4,
max = 4
)
- public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
+ public Pattern offset(double x, double y, double z, Pattern pattern) {
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@@ -348,7 +347,7 @@ public class PatternCommands extends MethodCommands {
min = 2,
max = 2
)
- public Pattern surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
+ public Pattern surfacespread(double distance, Pattern pattern) {
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
}
@@ -359,7 +358,7 @@ public class PatternCommands extends MethodCommands {
min = 4,
max = 4
)
- public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
+ public Pattern solidspread(double x, double y, double z, Pattern pattern) {
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@@ -370,7 +369,7 @@ public class PatternCommands extends MethodCommands {
min = 4,
max = 4
)
- public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
+ public Pattern spread(double x, double y, double z, Pattern pattern) {
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@@ -381,7 +380,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern linear(Actor actor, LocalSession session, Pattern other) {
+ public Pattern linear(Pattern other) {
if (other instanceof RandomPattern) {
Set patterns = ((RandomPattern) other).getPatterns();
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
@@ -396,7 +395,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
+ public Pattern linear3d(Pattern other) {
if (other instanceof RandomPattern) {
Set patterns = ((RandomPattern) other).getPatterns();
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
@@ -411,7 +410,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
+ public Pattern linear2d(Pattern other) {
if (other instanceof RandomPattern) {
Set patterns = ((RandomPattern) other).getPatterns();
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
@@ -426,7 +425,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
- public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
+ public Pattern expression(Extent extent, String input) throws ExpressionException {
Expression exp = Expression.compile(input, "x", "y", "z");
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
exp.setEnvironment(env);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
index 27d4d33a6..09ff62c4f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
@@ -25,6 +25,7 @@ import com.boydti.fawe.object.clipboard.URIClipboardHolder;
import com.boydti.fawe.object.mask.IdMask;
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
+import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
@@ -702,7 +703,7 @@ public class SelectionCommands {
// TODO multi clipboard distribution
Clipboard clipboard = session.getClipboard().getClipboard();
region = clipboard.getRegion();
- editSession.setExtent(new AbstractDelegateExtent(clipboard));
+ new ExtentTraverser(editSession).setNext(new AbstractDelegateExtent(clipboard));
} else {
region = session.getSelection(player.getWorld());
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java
index 960be3c95..985f3f671 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java
@@ -609,9 +609,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
.blockBag(null)
.changeSetNull()
.combineStages(false);
-
- builder.commit();
-
EditSession editSession = builder.build();
VisualExtent newVisualExtent = new VisualExtent(builder.getExtent(), builder.getQueue());
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java
index 3bbaa8ca0..7c59cf4ea 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java
@@ -57,7 +57,7 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
*
* @return the extent
*/
- public final Extent getExtent() {
+ public Extent getExtent() {
return extent;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java
index ec4c276a7..ac980a52f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java
@@ -72,15 +72,10 @@ public class NullExtent implements Extent {
return null;
}
- @Override
public BlockState getBlock(BlockVector3 position) {
return BlockTypes.AIR.getDefaultState();
}
- public BlockState getLazyBlock(BlockVector3 position) {
- return BlockTypes.AIR.getDefaultState();
- }
-
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
return getBlock(position).toBaseBlock();
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java
index 819329d64..0765ad86c 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java
@@ -208,11 +208,6 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
return IMP.getBlock(x, y, z).toImmutableState();
}
- @Override
- public BlockState getLazyBlock(BlockVector3 position) {
- return getBlock(position);
- }
-
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
if(region.contains(position)) {
@@ -290,11 +285,11 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
@Override
public int getOpacity(int x, int y, int z) {
- return getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().getLightOpacity();
+ return getBlock(x, y, z).getBlockType().getMaterial().getLightOpacity();
}
@Override
public int getBrightness(int x, int y, int z) {
- return getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().getLightValue();
+ return getBlock(x, y, z).getBlockType().getMaterial().getLightValue();
}
}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java
index 04ec91136..3e1641446 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java
@@ -93,7 +93,7 @@ public class BlockBagExtent extends AbstractDelegateExtent {
@Override
public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
if(blockBag != null) {
- BlockStateHolder lazyBlock = getExtent().getLazyBlock(x, y, z);
+ BlockStateHolder lazyBlock = getExtent().getBlock(x, y, z);
BlockType fromType = lazyBlock.getBlockType();
if(!block.getBlockType().equals(fromType)) {
BlockType type = block.getBlockType();
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java
index 1c1a9cdb4..0925430fa 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java
@@ -442,8 +442,8 @@ public class BlockTransformExtent extends ResettableExtent {
}
@Override
- public BlockState getLazyBlock(int x, int y, int z) {
- return transform(super.getLazyBlock(x, y, z));
+ public BlockState getBlock(int x, int y, int z) {
+ return transform(super.getBlock(x, y, z));
}
@Override
@@ -451,11 +451,6 @@ public class BlockTransformExtent extends ResettableExtent {
return transform(super.getFullBlock(position));
}
- @Override
- public BlockState getLazyBlock(BlockVector3 position) {
- return transform(super.getLazyBlock(position));
- }
-
@Override
public BlockState getBlock(BlockVector3 position) {
return transform(super.getBlock(position));
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
new file mode 100644
index 000000000..5f26ef942
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java
@@ -0,0 +1,84 @@
+package com.sk89q.worldedit.function.mask;
+
+import com.boydti.fawe.util.StringMan;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.util.command.parametric.Optional;
+import com.sk89q.worldedit.world.block.BlockState;
+import com.sk89q.worldedit.world.block.BlockType;
+import com.sk89q.worldedit.world.block.BlockTypes;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+public abstract class ABlockMask extends AbstractExtentMask {
+ public ABlockMask(Extent extent) {
+ super(extent);
+ }
+
+ public abstract boolean test(BlockState state);
+
+ @Override
+ public String toString() {
+ List strings = new ArrayList<>();
+ for (BlockType type : BlockTypes.values) {
+ if (type != null) {
+ boolean hasAll = true;
+ boolean hasAny = false;
+ List all = type.getAllStates();
+ for (BlockState state : all) {
+ hasAll &= test(state);
+ hasAny = true;
+ }
+ if (hasAll) {
+ strings.add(type.getId());
+ } else if (hasAny) {
+ for (BlockState state : all) {
+ if (test(state)) {
+ strings.add(state.getAsString());
+ }
+ }
+ }
+ }
+ }
+ return StringMan.join(strings, ",");
+ }
+
+ @Override
+ public Mask and(Mask mask) {
+ if (mask instanceof ABlockMask) {
+ ABlockMask other = (ABlockMask) mask;
+ BlockMask newMask = new BlockMask(getExtent());
+ for (BlockState state : BlockTypes.states) {
+ if (state != null) {
+ if (test(state) && other.test(state)) {
+ newMask.add(state);
+ }
+ }
+ }
+ Mask tmp = newMask.optimize();
+ if (tmp == null) tmp = newMask;
+ return tmp;
+ }
+ return null;
+ }
+
+ @Override
+ public Mask or(Mask mask) {
+ if (mask instanceof ABlockMask) {
+ ABlockMask other = (ABlockMask) mask;
+ BlockMask newMask = new BlockMask(getExtent());
+ for (BlockState state : BlockTypes.states) {
+ if (state != null) {
+ if (test(state) || other.test(state)) {
+ newMask.add(state);
+ }
+ }
+ }
+ Mask tmp = newMask.optimize();
+ if (tmp == null) tmp = newMask;
+ return tmp;
+ }
+ return null;
+ }
+}
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 dbb3f28cc..a5478156c 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
@@ -44,7 +44,7 @@ public abstract class AbstractExtentMask extends AbstractMask {
*
* @return the extent
*/
- public Extent getExtent() {
+ public final Extent getExtent() {
return extent;
}
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 625d8b781..024630cd0 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
@@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
+import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockCategory;
@@ -42,7 +43,7 @@ public class BlockCategoryMask extends AbstractExtentMask {
@Override
public boolean test(BlockVector3 vector) {
- return category.contains(getExtent().getBlock(vector));
+ return category.contains(vector.getBlock(getExtent()));
}
@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 1e5a2e8e3..6e3598513 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
@@ -1,250 +1,194 @@
package com.sk89q.worldedit.function.mask;
-import com.boydti.fawe.object.collection.FastBitSet;
-import com.boydti.fawe.util.MainUtil;
-import com.boydti.fawe.util.StringMan;
-import com.sk89q.worldedit.extent.NullExtent;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
-import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.registry.state.AbstractProperty;
-import com.sk89q.worldedit.registry.state.Property;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.sk89q.worldedit.math.BlockVector3;
-import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
+
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.annotation.Nullable;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import java.util.function.Predicate;
-/**
- * A mask that checks whether blocks at the given positions are matched by
- * a block in a list.
- *
- * This mask checks for both an exact block type and state value match,
- * respecting fuzzy status of the BlockState.
- */
-public class BlockMask extends AbstractExtentMask {
+public class BlockMask extends ABlockMask {
+ private final boolean[] ordinals;
- private final long[][] bitSets;
- protected final static long[] ALL = new long[0];
+ public BlockMask(Extent extent) {
+ this(extent, new boolean[BlockTypes.states.length]);
+ }
+ public BlockMask(Extent extent, boolean[] ordinals) {
+ super(extent);
+ this.ordinals = ordinals;
+ }
+
+ /**
+ * @deprecated NBT not supported by this mask
+ */
@Deprecated
public BlockMask(Extent extent, Collection blocks) {
- super(extent);
- MainUtil.warnDeprecated(BlockMaskBuilder.class);
- this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits();
+ this(extent);
+ add(blocks);
}
+ public BlockMask add(Predicate predicate) {
+ for (int i = 0; i < ordinals.length; i++) {
+ if (!ordinals[i]) {
+ BlockState state = BlockTypes.states[i];
+ if (state != null) ordinals[i] = predicate.test(state);
+ }
+ }
+ return this;
+ }
+
+ public BlockMask add(BlockState... states) {
+ addStates(Arrays.asList(states));
+ return this;
+ }
+
+ public BlockMask addStates(Collection states) {
+ for (BlockState state : states) ordinals[state.getOrdinal()] = true;
+ return this;
+ }
+
+ public BlockMask add(BlockType... types) {
+ addTypes(Arrays.asList(types));
+ return this;
+ }
+
+ public BlockMask addTypes(Collection types) {
+ for (BlockType type : types) {
+ for (BlockState state : type.getAllStates()) {
+ ordinals[state.getOrdinal()] = true;
+ }
+ }
+ return this;
+ }
+
+ /**
+ * @deprecated NBT not supported by this mask
+ */
@Deprecated
- public BlockMask(Extent extent, BaseBlock... blocks) {
- super(extent);
- MainUtil.warnDeprecated(BlockMaskBuilder.class);
- this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits();
- }
-
- public BlockMask() {
- super(NullExtent.INSTANCE);
- this.bitSets = new long[BlockTypes.size()][];
- }
-
- protected BlockMask(Extent extent, long[][] bitSets) {
- super(extent);
- this.bitSets = bitSets;
- }
-
- public BlockMaskBuilder toBuilder() {
- return new BlockMaskBuilder(this.bitSets);
+ public void add(Collection blocks) {
+ for (BaseBlock block : blocks) {
+ add(block.toBlockState());
+ }
}
@Override
- public String toString() {
- List strings = new ArrayList<>();
- for (int i = 0; i < bitSets.length; i++) {
- if (bitSets[i] != null) {
- long[] set = bitSets[i];
- BlockType type = BlockTypes.get(i);
- if (set == ALL) {
- strings.add(type.getId());
- } else {
- for (BlockState state : type.getAllStates()) {
- if (test(state)) {
- strings.add(state.getAsString());
- }
- }
- }
- }
- }
- return StringMan.join(strings, ",");
+ public boolean test(BlockState state) {
+ return ordinals[state.getOrdinal()];
}
@Override
- public Mask optimize() {
- Map