From 90e381a13297a709b3e0cdd3beda280369b6b249 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 13 Jan 2017 06:05:32 +1100 Subject: [PATCH] Minor vector optimizations For the MutableBlockVector, use int instead of double - Should reduce how quickly memory is used/collected --- .../boydti/fawe/command/AnvilCommands.java | 10 +- .../com/boydti/fawe/object/FawePlayer.java | 2 +- .../com/boydti/fawe/object/FaweQueue.java | 17 ++-- .../boydti/fawe/object/brush/HeightBrush.java | 12 +-- .../boydti/fawe/object/brush/RaiseBrush.java | 20 ++++ .../boydti/fawe/object/brush/SplineBrush.java | 12 +-- .../brush/heightmap/ScalableHeightMap.java | 4 +- .../clipboard/CPUOptimizedClipboard.java | 6 +- .../clipboard/DiskOptimizedClipboard.java | 12 +-- .../clipboard/MemoryOptimizedClipboard.java | 6 +- .../object/clipboard/OffsetFaweClipboard.java | 6 +- .../object/clipboard/WorldCopyClipboard.java | 30 +++--- .../collection/LocalBlockVectorSet.java | 15 +-- .../object/extent/BlockTranslateExtent.java | 15 +-- .../fawe/object/extent/ClipboardExtent.java | 9 +- .../extent/PositionTransformExtent.java | 39 ++++---- .../fawe/object/extent/ScaleTransform.java | 31 +++--- .../fawe/object/extent/SourceMaskExtent.java | 9 +- .../fawe/object/extent/TransformExtent.java | 39 ++++---- .../boydti/fawe/object/mask/AdjacentMask.java | 30 +++--- .../boydti/fawe/object/mask/AngleMask.java | 11 ++- .../boydti/fawe/object/mask/PlaneMask.java | 69 ++++++++++++++ .../fawe/object/mask/SolidPlaneMask.java | 94 +++++++++++++++++++ .../com/boydti/fawe/object/mask/WallMask.java | 20 ++-- .../object/pattern/FullClipboardPattern.java | 3 +- .../fawe/object/pattern/NoXPattern.java | 7 +- .../fawe/object/pattern/NoYPattern.java | 7 +- .../fawe/object/pattern/NoZPattern.java | 7 +- .../fawe/object/pattern/OffsetPattern.java | 9 +- .../object/pattern/RandomOffsetPattern.java | 9 +- .../fawe/object/pattern/RelativePattern.java | 9 +- .../pattern/SolidRandomOffsetPattern.java | 9 +- .../pattern/SurfaceRandomOffsetPattern.java | 11 ++- .../fawe/object/regions/FuzzyRegion.java | 6 +- .../fawe/object/schematic/FaweFormat.java | 9 +- .../fawe/object/schematic/PNGWriter.java | 27 +++--- .../object/schematic/StructureFormat.java | 3 +- .../fawe/object/visitor/DFSVisitor.java | 15 +-- .../fawe/object/visitor/FuzzySearch.java | 6 +- .../com/sk89q/worldedit/CuboidClipboard.java | 12 +-- .../java/com/sk89q/worldedit/EditSession.java | 20 ++-- .../sk89q/worldedit/MutableBlockVector.java | 81 ++++++++++++++++ .../main/java/com/sk89q/worldedit/Vector.java | 80 +++++++++++----- .../worldedit/command/BrushCommands.java | 2 +- .../worldedit/command/ClipboardCommands.java | 26 ++--- .../command/FlattenedClipboardTransform.java | 24 +++-- .../worldedit/command/GenerationCommands.java | 12 +-- .../worldedit/command/HistoryCommands.java | 4 +- .../worldedit/command/RegionCommands.java | 6 +- .../command/tool/brush/GravityBrush.java | 10 +- .../extension/platform/PlatformManager.java | 6 +- .../extent/AbstractDelegateExtent.java | 15 +-- .../extent/clipboard/BlockArrayClipboard.java | 15 +-- .../extent/clipboard/io/SchematicWriter.java | 9 +- .../function/block/ExtentBlockCopy.java | 6 +- .../worldedit/function/mask/OffsetMask.java | 11 ++- .../function/pattern/ClipboardPattern.java | 10 +- .../worldedit/function/pattern/Patterns.java | 10 +- .../function/visitor/BreadthFirstSearch.java | 21 +++-- .../KochanekBartelsInterpolation.java | 11 ++- .../math/transform/AffineTransform.java | 9 +- .../sk89q/worldedit/regions/CuboidRegion.java | 43 ++++----- 62 files changed, 717 insertions(+), 381 deletions(-) create mode 100644 core/src/main/java/com/boydti/fawe/object/brush/RaiseBrush.java create mode 100644 core/src/main/java/com/boydti/fawe/object/mask/PlaneMask.java create mode 100644 core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java create mode 100644 core/src/main/java/com/sk89q/worldedit/MutableBlockVector.java diff --git a/core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index e62f4971..2cd36281 100644 --- a/core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -10,7 +10,7 @@ import com.boydti.fawe.object.number.LongAdder; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; @@ -95,14 +95,14 @@ public class AnvilCommands { MCAQueue queue = new MCAQueue(folder, root, true); final LongAdder count = new LongAdder(); queue.filterWorld(new MCAFilter() { - private final Vector mutable = new Vector(0, 0, 0); + private final MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); @Override public void applyBlock(int x, int y, int z, BaseBlock block) { if (matchFrom.apply(block)) { - mutable.x = x; - mutable.y = y; - mutable.z = z; + mutable.mutX(x); + mutable.mutY(y); + mutable.mutZ(z); BaseBlock newBlock = to.apply(mutable); int currentId = block.getId(); if (FaweCache.hasNBT(currentId)) { diff --git a/core/src/main/java/com/boydti/fawe/object/FawePlayer.java b/core/src/main/java/com/boydti/fawe/object/FawePlayer.java index 9e944ebc..3bc60bb4 100644 --- a/core/src/main/java/com/boydti/fawe/object/FawePlayer.java +++ b/core/src/main/java/com/boydti/fawe/object/FawePlayer.java @@ -372,7 +372,7 @@ public abstract class FawePlayer extends Metadatable { public void setSelection(final RegionWrapper region) { final Player player = this.getPlayer(); Vector top = region.getTopVector(); - top.y = getWorld().getMaxY(); + top.mutY(getWorld().getMaxY()); final RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getBottomVector(), top); this.getSession().setRegionSelector(player.getWorld(), selector); } diff --git a/core/src/main/java/com/boydti/fawe/object/FaweQueue.java b/core/src/main/java/com/boydti/fawe/object/FaweQueue.java index b698b56b..3882a697 100644 --- a/core/src/main/java/com/boydti/fawe/object/FaweQueue.java +++ b/core/src/main/java/com/boydti/fawe/object/FaweQueue.java @@ -14,6 +14,7 @@ import com.boydti.fawe.util.MemUtil; import com.boydti.fawe.util.SetQueue; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockMaterial; @@ -218,20 +219,20 @@ public abstract class FaweQueue { public void forEachBlockInChunk(int cx, int cz, RunnableVal2 onEach) { int bx = cx << 4; int bz = cz << 4; - Vector mutable = new Vector(0, 0, 0); + MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); for (int x = 0; x < 16; x++) { int xx = x + bx; - mutable.x = xx; + mutable.mutX(xx); for (int z = 0; z < 16; z++) { int zz = z + bz; - mutable.z = zz; + mutable.mutZ(zz); for (int y = 0; y <= getMaxY(); y++) { int combined = getCombinedId4Data(xx, y, zz); if (combined == 0) { continue; } int id = FaweCache.getId(combined); - mutable.y = y; + mutable.mutY(y); if (FaweCache.hasNBT(id)) { CompoundTag tile = getTileEntity(x, y, z); BaseBlock block = new BaseBlock(id, FaweCache.getData(combined), tile); @@ -247,7 +248,7 @@ public abstract class FaweQueue { public void forEachTileInChunk(int cx, int cz, RunnableVal2 onEach) { int bx = cx << 4; int bz = cz << 4; - Vector mutable = new Vector(0, 0, 0); + MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); for (int x = 0; x < 16; x++) { int xx = x + bx; for (int z = 0; z < 16; z++) { @@ -259,9 +260,9 @@ public abstract class FaweQueue { } int id = FaweCache.getId(combined); if (FaweCache.hasNBT(id)) { - mutable.x = xx; - mutable.z = zz; - mutable.y = y; + mutable.mutX(xx); + mutable.mutZ(zz); + mutable.mutY(y); CompoundTag tile = getTileEntity(x, y, z); BaseBlock block = new BaseBlock(id, FaweCache.getData(combined), tile); onEach.run(mutable, block); diff --git a/core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java b/core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java index f8a440a4..50ea684a 100644 --- a/core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java +++ b/core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java @@ -6,8 +6,6 @@ import com.boydti.fawe.object.exception.FaweException; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.command.tool.BrushTool; -import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Masks; @@ -15,14 +13,14 @@ import com.sk89q.worldedit.function.pattern.Pattern; import java.io.File; import java.io.IOException; -public class HeightBrush implements Brush { +public class HeightBrush implements DoubleActionBrush { public final ScalableHeightMap heightMap; private final int rotation; double yscale = 1; - private final BrushTool tool; + private final DoubleActionBrushTool tool; - public HeightBrush(File file, int rotation, double yscale, BrushTool tool, Clipboard clipboard) { + public HeightBrush(File file, int rotation, double yscale, DoubleActionBrushTool tool, Clipboard clipboard) { this.tool = tool; this.rotation = (rotation / 90) % 4; this.yscale = yscale; @@ -43,12 +41,12 @@ public class HeightBrush implements Brush { } @Override - public void build(EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException { + public void build(DoubleActionBrushTool.BrushAction action, EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException { + int size = (int) (action == DoubleActionBrushTool.BrushAction.PRIMARY ? sizeDouble : -sizeDouble); Mask mask = tool.getMask(); if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) { mask = null; } - int size = (int) sizeDouble; heightMap.setSize(size); heightMap.apply(editSession, mask, position, size, rotation, yscale, true); } diff --git a/core/src/main/java/com/boydti/fawe/object/brush/RaiseBrush.java b/core/src/main/java/com/boydti/fawe/object/brush/RaiseBrush.java new file mode 100644 index 00000000..78146158 --- /dev/null +++ b/core/src/main/java/com/boydti/fawe/object/brush/RaiseBrush.java @@ -0,0 +1,20 @@ +package com.boydti.fawe.object.brush; + +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.function.pattern.Pattern; + +public class RaiseBrush implements DoubleActionBrush { + + + @Override + public void build(DoubleActionBrushTool.BrushAction action, EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { + switch (action) { + case PRIMARY: + break; + case SECONDARY: + break; + } + } +} \ No newline at end of file diff --git a/core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java b/core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java index dfd97360..6b9e3cfb 100644 --- a/core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java +++ b/core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java @@ -123,9 +123,9 @@ public class SplineBrush implements DoubleActionBrush { private Vector getCentroid(Collection points) { Vector sum = new Vector(); for (Vector p : points) { - sum.x += p.getX(); - sum.y += p.getY(); - sum.z += p.getZ(); + sum.mutX(sum.getX() + p.getX()); + sum.mutY(sum.getY() + p.getY()); + sum.mutZ(sum.getZ() + p.getZ()); } return sum.multiply(1.0 / points.size()); } @@ -147,9 +147,9 @@ public class SplineBrush implements DoubleActionBrush { Vector r = new Vector(); for (Vector p : points) { - r.x = (p.getX() - centroid.getX()); - r.y = (p.getY() - centroid.getY()); - r.z = (p.getZ() - centroid.getZ()); + r.mutX((p.getX() - centroid.getX())); + r.mutY((p.getY() - centroid.getY())); + r.mutZ((p.getZ() - centroid.getZ())); xx += r.getX() * r.getX(); xy += r.getX() * r.getY(); xz += r.getX() * r.getZ(); diff --git a/core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java b/core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java index 87263ec8..62d53167 100644 --- a/core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java +++ b/core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java @@ -70,7 +70,7 @@ public class ScalableHeightMap { int zz = pos.getBlockZ(); int highestY = minY; for (int y = minY; y <= maxY; y++) { - pos.y = y; + pos.mutY(y); BaseBlock block = clipboard.getBlock(pos); if (block != EditSession.nullBlock) { highestY = y + 1; @@ -115,7 +115,7 @@ public class ScalableHeightMap { Vector mutablePos = new Vector(0, 0, 0); for (int x = -size; x <= size; x++) { int xx = centerX + x; - mutablePos.x = xx; + mutablePos.mutX(xx); for (int z = -size; z <= size; z++) { int index = (z + size) * diameter + (x + size); int zz = centerZ + z; diff --git a/core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java b/core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java index 822f561f..5bb4d635 100644 --- a/core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java +++ b/core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java @@ -165,9 +165,9 @@ public class CPUOptimizedClipboard extends FaweClipboard { if (!air && task.value2.getId() == 0) { continue; } - task.value1.x = x; - task.value1.y = y; - task.value1.z = z; + task.value1.mutX(x); + task.value1.mutY(y); + task.value1.mutZ(z); task.run(); } } diff --git a/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java b/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java index ea278120..b7bf53c7 100644 --- a/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java +++ b/core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java @@ -277,9 +277,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { block.setNbtData(nbt); } } - pos.x = x; - pos.y = y; - pos.z = z; + pos.mutX(x); + pos.mutY(y); + pos.mutZ(z); task.run(pos, block); } } @@ -299,9 +299,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { block.setNbtData(nbt); } } - pos.x = x; - pos.y = y; - pos.z = z; + pos.mutX(x); + pos.mutY(y); + pos.mutZ(z); task.run(pos, block); } } diff --git a/core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java b/core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java index 61ea905f..bb470034 100644 --- a/core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java +++ b/core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java @@ -387,9 +387,9 @@ public class MemoryOptimizedClipboard extends FaweClipboard { if (!air && task.value2.getId() == 0) { continue; } - task.value1.x = x; - task.value1.y = y; - task.value1.z = z; + task.value1.mutX(x); + task.value1.mutY(y); + task.value1.mutZ(z); task.run(); } } diff --git a/core/src/main/java/com/boydti/fawe/object/clipboard/OffsetFaweClipboard.java b/core/src/main/java/com/boydti/fawe/object/clipboard/OffsetFaweClipboard.java index 06d0de3f..37f27523 100644 --- a/core/src/main/java/com/boydti/fawe/object/clipboard/OffsetFaweClipboard.java +++ b/core/src/main/java/com/boydti/fawe/object/clipboard/OffsetFaweClipboard.java @@ -39,9 +39,9 @@ public class OffsetFaweClipboard extends AbstractDelegateFaweClipboard { super.forEach(new RunnableVal2() { @Override public void run(Vector value, BaseBlock block) { - value.x -= ox; - value.y -= oy; - value.z -= oz; + value.mutX(value.getX() - ox); + value.mutY(value.getY() - oy); + value.mutZ(value.getZ() - oz); task.run(value, block); } }, air); diff --git a/core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java b/core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java index afc42aa5..4e97d7fb 100644 --- a/core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java +++ b/core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java @@ -53,9 +53,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { BaseBlock block = getBlockAbs(x, y, z); - pos.x = x - mx; - pos.y = y - my; - pos.z = z - mz; + pos.mutX(x - mx); + pos.mutY(y - my); + pos.mutZ(z - mz); CompoundTag tag = block.getNbtData(); if (tag != null) { Map values = ReflectionUtils.getMap(tag.getValue()); @@ -75,9 +75,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { if (block == EditSession.nullBlock) { continue; } - pos.x = x - mx; - pos.y = y - my; - pos.z = z - mz; + pos.mutX(x - mx); + pos.mutY(y - my); + pos.mutZ(z - mz); CompoundTag tag = block.getNbtData(); if (tag != null) { Map values = ReflectionUtils.getMap(tag.getValue()); @@ -94,17 +94,17 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { - pos.x = x; - pos.y = y; - pos.z = z; + pos.mutX(x); + pos.mutY(y); + pos.mutZ(z); if (region.contains(pos)) { BaseBlock block = getBlockAbs(x, y, z); if (!air && block == EditSession.nullBlock) { continue; } - pos.x -= mx; - pos.y -= my; - pos.z -= mz; + pos.mutX(pos.getX() - mx); + pos.mutY(pos.getY() - my); + pos.mutZ(pos.getZ() - mz); CompoundTag tag = block.getNbtData(); if (tag != null) { Map values = ReflectionUtils.getMap(tag.getValue()); @@ -114,9 +114,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { } task.run(pos, block); } else if (air) { - pos.x -= mx; - pos.y -= my; - pos.z -= mz; + pos.mutX(pos.getX() - mx); + pos.mutY(pos.getY() - my); + pos.mutZ(pos.getZ() - mz); task.run(pos, EditSession.nullBlock); } } diff --git a/core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java b/core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java index 9bb94634..e60d4b78 100644 --- a/core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java +++ b/core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.BlockVector; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import java.util.Collection; import java.util.Iterator; @@ -49,7 +50,7 @@ public class LocalBlockVectorSet implements Set { return new Iterator() { int index = set.nextSetBit(0); int previous = -1; - BlockVector mutable = new BlockVector(0, 0, 0); + MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); @Override public void remove() { set.clear(previous); @@ -65,9 +66,9 @@ public class LocalBlockVectorSet implements Set { int b2 = ((byte) (index >> 8)) & 0x7F; int b3 = ((byte)(index >> 15)) & 0xFF; int b4 = ((byte) (index >> 23)) & 0xFF; - mutable.x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); - mutable.y = b1; - mutable.z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); + mutable.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21)); + mutable.mutY(b1); + mutable.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21)); previous = index; index = set.nextSetBit(index + 1); return mutable; @@ -172,9 +173,9 @@ public class LocalBlockVectorSet implements Set { int b2 = ((byte) (index >> 8)) & 0x7F; int b3 = ((byte)(index >> 15)) & 0xFF; int b4 = ((byte) (index >> 23)) & 0xFF; - mVec.x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); - mVec.y = b1; - mVec.z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); + mVec.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21)); + mVec.mutY(b1); + mVec.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21)); if (!c.contains(mVec)) { result = true; set.clear(index); diff --git a/core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java b/core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java index 7b182ead..074da922 100644 --- a/core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java +++ b/core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.extent; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; @@ -11,7 +12,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome; public class BlockTranslateExtent extends AbstractDelegateExtent { private final int dx,dy,dz; private final Extent extent; - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); public BlockTranslateExtent(Extent extent, int dx, int dy, int dz) { super(extent); @@ -23,17 +24,17 @@ public class BlockTranslateExtent extends AbstractDelegateExtent { @Override public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { - mutable.x = (location.getX() + dx); - mutable.y = (location.getY() + dy); - mutable.z = (location.getZ() + dz); + mutable.mutX((location.getX() + dx)); + mutable.mutY((location.getY() + dy)); + mutable.mutZ((location.getZ() + dz)); return extent.setBlock(mutable, block); } @Override public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException { - mutable.x = x + dx; - mutable.y = y + dy; - mutable.z = z + dz; + mutable.mutX(x + dx); + mutable.mutY(y + dy); + mutable.mutZ(z + dz); return extent.setBlock(mutable, block); } diff --git a/core/src/main/java/com/boydti/fawe/object/extent/ClipboardExtent.java b/core/src/main/java/com/boydti/fawe/object/extent/ClipboardExtent.java index 852c1a28..2cd42c25 100644 --- a/core/src/main/java/com/boydti/fawe/object/extent/ClipboardExtent.java +++ b/core/src/main/java/com/boydti/fawe/object/extent/ClipboardExtent.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.extent; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; @@ -20,7 +21,7 @@ public class ClipboardExtent extends ResettableExtent { private final boolean ignoreAir; private Extent extent; - private final Vector mutable = new Vector(); + private final MutableBlockVector mutable = new MutableBlockVector(); public ClipboardExtent(Extent parent, Clipboard clipboard, boolean ignoreAir) { super(parent); @@ -44,9 +45,9 @@ public class ClipboardExtent extends ResettableExtent { @Override public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException { - mutable.x = x; - mutable.y = y; - mutable.z = z; + mutable.mutX(x); + mutable.mutY(y); + mutable.mutZ(z); return setBlock(mutable, block); } diff --git a/core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java b/core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java index 38591602..6ab83a62 100644 --- a/core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java +++ b/core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.extent; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; @@ -10,7 +11,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome; public class PositionTransformExtent extends ResettableExtent { - private final Vector mutable = new Vector(); + private final MutableBlockVector mutable = new MutableBlockVector(); private Transform transform; private Vector min; @@ -33,13 +34,13 @@ public class PositionTransformExtent extends ResettableExtent { if (min == null) { min = new Vector(pos); } - mutable.x = ((pos.getX() - min.getX())); - mutable.y = ((pos.getY() - min.getY())); - mutable.z = ((pos.getZ() - min.getZ())); + mutable.mutX(((pos.getX() - min.getX()))); + mutable.mutY(((pos.getY() - min.getY()))); + mutable.mutZ(((pos.getZ() - min.getZ()))); Vector tmp = transform.apply(mutable); - tmp.x = (tmp.getX() + min.getX()); - tmp.y = (tmp.getY() + min.getY()); - tmp.z = (tmp.getZ() + min.getZ()); + tmp.mutX((tmp.getX() + min.getX())); + tmp.mutY((tmp.getY() + min.getY())); + tmp.mutZ((tmp.getZ() + min.getZ())); return tmp; } @@ -47,13 +48,13 @@ public class PositionTransformExtent extends ResettableExtent { if (min == null) { min = new Vector(x, y, z); } - mutable.x = ((x - min.getX())); - mutable.y = ((y - min.getY())); - mutable.z = ((z - min.getZ())); + mutable.mutX(((x - min.getX()))); + mutable.mutY(((y - min.getY()))); + mutable.mutZ(((z - min.getZ()))); Vector tmp = transform.apply(mutable); - tmp.x = (tmp.getX() + min.getX()); - tmp.y = (tmp.getY() + min.getY()); - tmp.z = (tmp.getZ() + min.getZ()); + tmp.mutX((tmp.getX() + min.getX())); + tmp.mutY((tmp.getY() + min.getY())); + tmp.mutZ((tmp.getZ() + min.getZ())); return tmp; } @@ -74,9 +75,9 @@ public class PositionTransformExtent extends ResettableExtent { @Override public BaseBiome getBiome(Vector2D position) { - mutable.x = position.getBlockX(); - mutable.z = position.getBlockZ(); - mutable.y = 0; + mutable.mutX(position.getBlockX()); + mutable.mutZ(position.getBlockZ()); + mutable.mutY(0); return super.getBiome(getPos(mutable).toVector2D()); } @@ -93,9 +94,9 @@ public class PositionTransformExtent extends ResettableExtent { @Override public boolean setBiome(Vector2D position, BaseBiome biome) { - mutable.x = position.getBlockX(); - mutable.z = position.getBlockZ(); - mutable.y = 0; + mutable.mutX(position.getBlockX()); + mutable.mutZ(position.getBlockZ()); + mutable.mutY(0); return super.setBiome(getPos(mutable).toVector2D(), biome); } diff --git a/core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java b/core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java index 326ee03a..77befbbf 100644 --- a/core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java +++ b/core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.extent; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; @@ -12,7 +13,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome; import javax.annotation.Nullable; public class ScaleTransform extends ResettableExtent { - private final Vector mutable = new Vector(); + private final MutableBlockVector mutable = new MutableBlockVector(); private final double dx,dy,dz; private int maxy; @@ -37,9 +38,9 @@ public class ScaleTransform extends ResettableExtent { if (min == null) { min = new Vector(pos); } - mutable.x = (min.getX() + (pos.getX() - min.getX()) * dx); - mutable.y = (min.getY() + (pos.getY() - min.getY()) * dy); - mutable.z = (min.getZ() + (pos.getZ() - min.getZ()) * dz); + mutable.mutX((min.getX() + (pos.getX() - min.getX()) * dx)); + mutable.mutY((min.getY() + (pos.getY() - min.getY()) * dy)); + mutable.mutZ((min.getZ() + (pos.getZ() - min.getZ()) * dz)); return mutable; } @@ -47,9 +48,9 @@ public class ScaleTransform extends ResettableExtent { if (min == null) { min = new Vector(x, y, z); } - mutable.x = (min.getX() + (x - min.getX()) * dx); - mutable.y = (min.getY() + (y - min.getY()) * dy); - mutable.z = (min.getZ() + (z - min.getZ()) * dz); + mutable.mutX((min.getX() + (x - min.getX()) * dx)); + mutable.mutY((min.getY() + (y - min.getY()) * dy)); + mutable.mutZ((min.getZ() + (z - min.getZ()) * dz)); return mutable; } @@ -64,9 +65,9 @@ public class ScaleTransform extends ResettableExtent { double ex = sx + dx; double ey = Math.min(maxy, sy + dy); double ez = sz + dz; - for (pos.y = sy; pos.y < ey; pos.y++) { - for (pos.z = sz; pos.z < ez; pos.z++) { - for (pos.x = sx; pos.x < ex; pos.x++) { + for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) { + for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { + for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { result |= super.setBlock(pos, block); } } @@ -82,8 +83,8 @@ public class ScaleTransform extends ResettableExtent { double sz = pos.getZ(); double ex = pos.getX() + dx; double ez = pos.getZ() + dz; - for (pos.z = sz; pos.z < ez; pos.z++) { - for (pos.x = sx; pos.x < ex; pos.x++) { + for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { + for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { result |= super.setBiome(pos.toVector2D(), biome); } } @@ -100,9 +101,9 @@ public class ScaleTransform extends ResettableExtent { double ex = pos.getX() + dx; double ey = Math.min(maxy, sy + dy); double ez = pos.getZ() + dz; - for (pos.y = sy; pos.y < ey; pos.y++) { - for (pos.z = sz; pos.z < ez; pos.z++) { - for (pos.x = sx; pos.x < ex; pos.x++) { + for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) { + for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { + for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { result |= super.setBlock(pos, block); } } diff --git a/core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java b/core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java index 3c8b2452..6cfc6c18 100644 --- a/core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java +++ b/core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.extent; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; @@ -11,7 +12,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class SourceMaskExtent extends TemporalExtent { private Mask mask; - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); /** @@ -47,9 +48,9 @@ public class SourceMaskExtent extends TemporalExtent { @Override public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException { set(x, y, z, block); - mutable.x = x; - mutable.y = y; - mutable.z = z; + mutable.mutX(x); + mutable.mutY(y); + mutable.mutZ(z); return mask.test(mutable) && super.setBlock(x, y, z, block); } } diff --git a/core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java b/core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java index 08143111..979a5d68 100644 --- a/core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java +++ b/core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.extent; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; @@ -11,7 +12,7 @@ import com.sk89q.worldedit.world.registry.BlockRegistry; public class TransformExtent extends BlockTransformExtent { - private final Vector mutable = new Vector(); + private final MutableBlockVector mutable = new MutableBlockVector(); private Vector min; private int maxy; @@ -35,13 +36,13 @@ public class TransformExtent extends BlockTransformExtent { if (min == null) { min = new Vector(pos); } - mutable.x = ((pos.getX() - min.getX())); - mutable.y = ((pos.getY() - min.getY())); - mutable.z = ((pos.getZ() - min.getZ())); + mutable.mutX(((pos.getX() - min.getX()))); + mutable.mutY(((pos.getY() - min.getY()))); + mutable.mutZ(((pos.getZ() - min.getZ()))); Vector tmp = getTransform().apply(mutable); - tmp.x = (tmp.getX() + min.getX()); - tmp.y = (tmp.getY() + min.getY()); - tmp.z = (tmp.getZ() + min.getZ()); + tmp.mutX((tmp.getX() + min.getX())); + tmp.mutY((tmp.getY() + min.getY())); + tmp.mutZ((tmp.getZ() + min.getZ())); return tmp; } @@ -49,13 +50,13 @@ public class TransformExtent extends BlockTransformExtent { if (min == null) { min = new Vector(x, y, z); } - mutable.x = ((x - min.getX())); - mutable.y = ((y - min.getY())); - mutable.z = ((z - min.getZ())); + mutable.mutX(((x - min.getX()))); + mutable.mutY(((y - min.getY()))); + mutable.mutZ(((z - min.getZ()))); Vector tmp = getTransform().apply(mutable); - tmp.x = (tmp.getX() + min.getX()); - tmp.y = (tmp.getY() + min.getY()); - tmp.z = (tmp.getZ() + min.getZ()); + tmp.mutX((tmp.getX() + min.getX())); + tmp.mutY((tmp.getY() + min.getY())); + tmp.mutZ((tmp.getZ() + min.getZ())); return tmp; } @@ -76,9 +77,9 @@ public class TransformExtent extends BlockTransformExtent { @Override public BaseBiome getBiome(Vector2D position) { - mutable.x = position.getBlockX(); - mutable.z = position.getBlockZ(); - mutable.y = 0; + mutable.mutX(position.getBlockX()); + mutable.mutZ(position.getBlockZ()); + mutable.mutY(0); return super.getBiome(getPos(mutable).toVector2D()); } @@ -95,9 +96,9 @@ public class TransformExtent extends BlockTransformExtent { @Override public boolean setBiome(Vector2D position, BaseBiome biome) { - mutable.x = position.getBlockX(); - mutable.z = position.getBlockZ(); - mutable.y = 0; + mutable.mutX(position.getBlockX()); + mutable.mutZ(position.getBlockZ()); + mutable.mutY(0); return super.setBiome(getPos(mutable).toVector2D(), biome); } } diff --git a/core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java b/core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java index 331e649a..ca539a73 100644 --- a/core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java +++ b/core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java @@ -21,21 +21,21 @@ public class AdjacentMask extends BlockMask { double x = v.getX(); double y = v.getY(); double z = v.getZ(); - v.x = x + 1; - if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } - v.x = x - 1; - if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } - v.x = x; - v.y = y + 1; - if (super.test(v) && ++count == min && max >= 8) { v.y = y; return true; } - v.y = y - 1; - if (super.test(v) && ++count == min && max >= 8) { v.y = y; return true; } - v.y = y; - v.z = z + 1; - if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; } - v.z = z - 1; - if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; } - v.z = z; + v.mutX(x + 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } + v.mutX(x - 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } + v.mutX(x); + v.mutY(y + 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutY(y); return true; } + v.mutY(y - 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutY(y); return true; } + v.mutY(y); + v.mutZ(z + 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } + v.mutZ(z - 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } + v.mutZ(z); return count >= min && count <= max; } } diff --git a/core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java b/core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java index ea1b470c..8e7d76f7 100644 --- a/core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java +++ b/core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.mask; import com.boydti.fawe.Fawe; import com.boydti.fawe.util.MathMan; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask2D; @@ -65,7 +66,7 @@ public class AngleMask extends SolidBlockMask implements ResettableMask { return false; } - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); private int getHighestTerrainBlock(final int x, final int z, int minY, int maxY) { long pair = MathMan.pairInt(x, z); @@ -79,15 +80,15 @@ public class AngleMask extends SolidBlockMask implements ResettableMask { } int maxSearchY = Math.min(this.maxY, Math.max(0, maxY)); int minSearchY = Math.min(this.maxY, Math.max(0, minY)); - mutable.x = x; - mutable.z = z; + mutable.mutX(x); + mutable.mutZ(z); boolean air = false; if (maxSearchY != this.maxY) { - mutable.y = maxSearchY + 1; + mutable.mutY(maxSearchY + 1); air = !super.test(mutable); } for (int y = maxSearchY; y >= minSearchY; --y) { - mutable.y = y; + mutable.mutY(y); if (super.test(mutable)) { if (!air) { break; diff --git a/core/src/main/java/com/boydti/fawe/object/mask/PlaneMask.java b/core/src/main/java/com/boydti/fawe/object/mask/PlaneMask.java new file mode 100644 index 00000000..3e7a789f --- /dev/null +++ b/core/src/main/java/com/boydti/fawe/object/mask/PlaneMask.java @@ -0,0 +1,69 @@ +package com.boydti.fawe.object.mask; + +import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.mask.Mask2D; +import javax.annotation.Nullable; + +/** + * Restricts the + */ +public class PlaneMask implements Mask, ResettableMask { + + private int mode = -1; + + private int originX = Integer.MAX_VALUE,originY = Integer.MAX_VALUE,originZ = Integer.MAX_VALUE; + + @Override + public boolean test(Vector vector) { + switch (mode) { + case -1: + originX = vector.getBlockX(); + originY = vector.getBlockY(); + originZ = vector.getBlockZ(); + mode = 0; + return true; + case 0: + case 1: + case 2: + case 4: + int original = mode; + if (originX != vector.getBlockX()) { + mode &= 1; + } + if (originY != vector.getBlockY()) { + mode &= 2; + } + if (originZ != vector.getBlockZ()) { + mode &= 4; + } + if (Integer.bitCount(mode) >= 3) { + mode = original; + return false; + } + default: + if (originX != vector.getBlockX() && (mode & 1) == 0) { + return false; + } + if (originZ != vector.getBlockZ() && (mode & 4) == 0) { + return false; + } + if (originY != vector.getBlockY() && (mode & 2) == 0) { + return false; + } + return true; + + } + } + + @Override + public void reset() { + mode = -1; + } + + @Nullable + @Override + public Mask2D toMask2D() { + return null; + } +} diff --git a/core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java b/core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java new file mode 100644 index 00000000..07e8a1c3 --- /dev/null +++ b/core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java @@ -0,0 +1,94 @@ +package com.boydti.fawe.object.mask; + +import com.sk89q.worldedit.MutableBlockVector; +import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.function.mask.Mask2D; +import com.sk89q.worldedit.function.mask.SolidBlockMask; +import javax.annotation.Nullable; + +/** + * Restricts the + */ +public class SolidPlaneMask extends SolidBlockMask implements ResettableMask { + + private int mode = -1; + private MutableBlockVector mutable = new MutableBlockVector(); + + private int originX = Integer.MAX_VALUE,originY = Integer.MAX_VALUE,originZ = Integer.MAX_VALUE; + + public SolidPlaneMask(Extent extent) { + super(extent); + } + + @Override + public boolean test(Vector vector) { + switch (mode) { + case -1: + if (!super.test(vector)) { + return false; + } + originX = vector.getBlockX(); + originY = vector.getBlockY(); + originZ = vector.getBlockZ(); + mode = 0; + Extent extent = getExtent(); + if (extent.getBlock(mutable.setComponents(originX - 1, originY, originZ)).getId() != 0 && extent.getBlock(mutable.setComponents(originX + 1, originY, originZ)).getId() != 0) { + mode &= 1; + } + if (extent.getBlock(mutable.setComponents(originX, originY, originZ - 1)).getId() != 0 && extent.getBlock(mutable.setComponents(originX, originY, originZ + 1)).getId() != 0) { + mode &= 4; + } + if (extent.getBlock(mutable.setComponents(originX, originY - 1, originZ + 1)).getId() != 0 && extent.getBlock(mutable.setComponents(originX, originY + 1, originZ + 1)).getId() != 0) { + mode &= 2; + } + if (Integer.bitCount(mode) >= 3) { + return false; + } + case 0: + case 1: + case 2: + case 4: + if (!super.test(vector)) { + return false; + } + int original = mode; + if (originX != vector.getBlockX()) { + mode &= 1; + } + if (originY != vector.getBlockY()) { + mode &= 2; + } + if (originZ != vector.getBlockZ()) { + mode &= 4; + } + if (Integer.bitCount(mode) >= 3) { + mode = original; + return false; + } + default: + if (originX != vector.getBlockX() && (mode & 1) == 0) { + return false; + } + if (originZ != vector.getBlockZ() && (mode & 4) == 0) { + return false; + } + if (originY != vector.getBlockY() && (mode & 2) == 0) { + return false; + } + return super.test(vector); + + } + } + + @Override + public void reset() { + mode = -1; + } + + @Nullable + @Override + public Mask2D toMask2D() { + return null; + } +} diff --git a/core/src/main/java/com/boydti/fawe/object/mask/WallMask.java b/core/src/main/java/com/boydti/fawe/object/mask/WallMask.java index d7268931..5dab7d9b 100644 --- a/core/src/main/java/com/boydti/fawe/object/mask/WallMask.java +++ b/core/src/main/java/com/boydti/fawe/object/mask/WallMask.java @@ -21,16 +21,16 @@ public class WallMask extends BlockMask { double x = v.getX(); double y = v.getY(); double z = v.getZ(); - v.x = x + 1; - if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } - v.x = x - 1; - if (super.test(v) && ++count == min && max >= 8) { v.x = x; return true; } - v.x = x; - v.z = z + 1; - if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; } - v.z = z - 1; - if (super.test(v) && ++count == min && max >= 8) { v.z = z; return true; } - v.z = z; + v.mutX(x + 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } + v.mutX(x - 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } + v.mutX(x); + v.mutZ(z + 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } + v.mutZ(z - 1); + if (super.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } + v.mutZ(z); return count >= min && count <= max; } } diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java index 37a9ce5a..130af219 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.pattern; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.Extent; @@ -21,7 +22,7 @@ public class FullClipboardPattern extends AbstractPattern { private final Clipboard clipboard; private final BaseBlock block; - private final Vector mutable = new Vector(); + private final MutableBlockVector mutable = new MutableBlockVector(); /** * Create a new clipboard pattern. diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java index ed55bc0e..19c6df6c 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.pattern; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -13,12 +14,12 @@ public class NoXPattern extends AbstractPattern { this.pattern = pattern; } - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); @Override public BaseBlock apply(Vector pos) { - mutable.y = (pos.getY()); - mutable.z = (pos.getZ()); + mutable.mutY((pos.getY())); + mutable.mutZ((pos.getZ())); return pattern.apply(mutable); } } diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java index f02a9ff0..3cb6b960 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.pattern; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -13,12 +14,12 @@ public class NoYPattern extends AbstractPattern { this.pattern = pattern; } - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); @Override public BaseBlock apply(Vector pos) { - mutable.x = (pos.getX()); - mutable.z = (pos.getZ()); + mutable.mutX((pos.getX())); + mutable.mutZ((pos.getZ())); return pattern.apply(mutable); } } diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java index 7e88445a..6f8b5ddf 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.pattern; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -13,12 +14,12 @@ public class NoZPattern extends AbstractPattern { this.pattern = pattern; } - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); @Override public BaseBlock apply(Vector pos) { - mutable.x = (pos.getX()); - mutable.y = (pos.getY()); + mutable.mutX((pos.getX())); + mutable.mutY((pos.getY())); return pattern.apply(mutable); } } diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java index d2f7abe8..0dde03ce 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.pattern; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -8,7 +9,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; public class OffsetPattern extends AbstractPattern { private final int dx,dy,dz; - private final Vector mutable = new Vector(); + private final MutableBlockVector mutable = new MutableBlockVector(); private final Pattern pattern; public OffsetPattern(Pattern pattern, int dx, int dy, int dz) { @@ -20,9 +21,9 @@ public class OffsetPattern extends AbstractPattern { @Override public BaseBlock apply(Vector position) { - mutable.x = (position.getX() + dx); - mutable.y = (position.getY() + dy); - mutable.z = (position.getZ() + dz); + mutable.mutX((position.getX() + dx)); + mutable.mutY((position.getY() + dy)); + mutable.mutZ((position.getZ() + dz)); return pattern.apply(mutable); } } diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java index e61c9662..ea43075b 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java @@ -1,6 +1,7 @@ package com.boydti.fawe.object.pattern; import com.boydti.fawe.object.PseudoRandom; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -10,7 +11,7 @@ public class RandomOffsetPattern extends AbstractPattern { private final PseudoRandom r = new PseudoRandom(); private final int dx, dy, dz, dx2, dy2, dz2; private final Pattern pattern; - private final Vector mutable = new Vector(); + private final MutableBlockVector mutable = new MutableBlockVector(); public RandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) { this.pattern = pattern; @@ -25,9 +26,9 @@ public class RandomOffsetPattern extends AbstractPattern { @Override public BaseBlock apply(Vector position) { - mutable.x = (position.getX() + r.nextInt(dx2) - dx); - mutable.y = (position.getY() + r.nextInt(dy2) - dy); - mutable.z = (position.getZ() + r.nextInt(dz2) - dz); + mutable.mutX((position.getX() + r.nextInt(dx2) - dx)); + mutable.mutY((position.getY() + r.nextInt(dy2) - dy)); + mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz)); return pattern.apply(mutable); } } \ No newline at end of file diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java index 6d741ee0..1ce2bd9e 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.pattern; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -14,16 +15,16 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter } private Vector origin; - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); @Override public BaseBlock apply(Vector pos) { if (origin == null) { origin = new Vector(pos); } - mutable.x = (pos.getX() - origin.getX()); - mutable.y = (pos.getY() - origin.getY()); - mutable.z = (pos.getZ() - origin.getZ()); + mutable.mutX((pos.getX() - origin.getX())); + mutable.mutY((pos.getY() - origin.getY())); + mutable.mutZ((pos.getZ() - origin.getZ())); return pattern.apply(mutable); } diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java index dc1174c8..ace3237e 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.pattern; import com.boydti.fawe.FaweCache; import com.boydti.fawe.object.PseudoRandom; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockType; @@ -12,7 +13,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern { private final PseudoRandom r = new PseudoRandom(); private final int dx, dy, dz, dx2, dy2, dz2; private final Pattern pattern; - private final Vector mutable = new Vector(); + private final MutableBlockVector mutable = new MutableBlockVector(); boolean[] solid; public SolidRandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) { @@ -35,9 +36,9 @@ public class SolidRandomOffsetPattern extends AbstractPattern { @Override public BaseBlock apply(Vector position) { - mutable.x = (position.getX() + r.nextInt(dx2) - dx); - mutable.y = (position.getY() + r.nextInt(dy2) - dy); - mutable.z = (position.getZ() + r.nextInt(dz2) - dz); + mutable.mutX((position.getX() + r.nextInt(dx2) - dx)); + mutable.mutY((position.getY() + r.nextInt(dy2) - dy)); + mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz)); BaseBlock block = pattern.apply(mutable); if (solid[FaweCache.getCombined(block)]) { return block; diff --git a/core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java b/core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java index 38ac9686..cec348cd 100644 --- a/core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java +++ b/core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.pattern; import com.boydti.fawe.FaweCache; import com.boydti.fawe.object.PseudoRandom; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockType; @@ -12,7 +13,7 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { private final PseudoRandom r = new PseudoRandom(); private final int dx, dy, dz, dx2, dy2, dz2; private final Pattern pattern; - private final Vector mutable = new Vector(); + private final MutableBlockVector mutable = new MutableBlockVector(); boolean[] solid; public SurfaceRandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) { @@ -35,12 +36,12 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { @Override public BaseBlock apply(Vector position) { - mutable.x = (position.getX() + r.nextInt(dx2) - dx); - mutable.y = (position.getY() + r.nextInt(dy2) - dy); - mutable.z = (position.getZ() + r.nextInt(dz2) - dz); + mutable.mutX((position.getX() + r.nextInt(dx2) - dx)); + mutable.mutY((position.getY() + r.nextInt(dy2) - dy)); + mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz)); BaseBlock block = pattern.apply(mutable); if (solid[FaweCache.getCombined(block)]) { - mutable.y++; + mutable.mutY(mutable.getY() + 1); if (!solid[FaweCache.getCombined(pattern.apply(mutable))]) { return block; } diff --git a/core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java b/core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java index 8b6f8405..cf4fdaf6 100644 --- a/core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java +++ b/core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java @@ -68,9 +68,9 @@ public class FuzzyRegion extends AbstractRegion { int b2 = ((byte) (index >> 8)) & 0x7F; int b3 = ((byte)(index >> 15)) & 0xFF; int b4 = ((byte) (index >> 23)) & 0xFF; - pos.x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); - pos.y = offsetY + b1; - pos.z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); + pos.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21)); + pos.mutY(offsetY + b1); + pos.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21)); return pos; } diff --git a/core/src/main/java/com/boydti/fawe/object/schematic/FaweFormat.java b/core/src/main/java/com/boydti/fawe/object/schematic/FaweFormat.java index 4798c80f..df6ae5e2 100644 --- a/core/src/main/java/com/boydti/fawe/object/schematic/FaweFormat.java +++ b/core/src/main/java/com/boydti/fawe/object/schematic/FaweFormat.java @@ -17,6 +17,7 @@ import com.sk89q.jnbt.NamedTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; @@ -311,13 +312,13 @@ public class FaweFormat implements ClipboardReader, ClipboardWriter { out.writeShort((short) origin.getBlockX()); out.writeShort((short) origin.getBlockY()); out.writeShort((short) origin.getBlockZ()); - Vector mutable = new Vector(0, 0, 0); + MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { - mutable.y = y; + mutable.mutY(y); for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { - mutable.x = x; + mutable.mutX(x); for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { - mutable.z = z; + mutable.mutZ(z); BaseBlock block = clipboard.getBlock(mutable); if (block == EditSession.nullBlock) { out.writeShort((short) 0); diff --git a/core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java b/core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java index b41d47aa..0cce0101 100644 --- a/core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java +++ b/core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.schematic; import com.boydti.fawe.FaweCache; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -80,7 +81,7 @@ public class PNGWriter implements ClipboardWriter { boolean fill = length * 4 < imageSize && width * 4 < imageSize; - Vector mutable = new Vector(0, 0, 0); + MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); Vector mutableTop = new Vector(0, 0, 0); Vector mutableRight = new Vector(0, 0, 0); Vector mutableLeft = new Vector(0, 0, 0); @@ -90,30 +91,30 @@ public class PNGWriter implements ClipboardWriter { int z0 = min.getBlockZ(); int x0 = min.getBlockX(); for (int x = x0; x < x0 + width; x++) { - mutable.x = x; - mutableTop.x = x; - mutableRight.x = x; - mutableLeft.x = x + 1; + mutable.mutX(x); + mutableTop.mutX(x); + mutableRight.mutX(x); + mutableLeft.mutX(x + 1); int xx = x - x0; double cpx1 = -dpxi[xx]; double cpy1 = dpyi[xx]; for (int z = z0; z < z0 + length; z++) { - mutable.z = z; - mutableTop.z = z; - mutableRight.z = z + 1; - mutableLeft.z = z; + mutable.mutZ(z); + mutableTop.mutZ(z); + mutableRight.mutZ(z + 1); + mutableLeft.mutZ(z); int zz = z - z0; double cpx = cpx1 + dpxj[zz]; double cpy2 = cpy1 + dpyj[zz]; for (int y = y0; y < y0 + height; y++) { - mutable.y = y; + mutable.mutY(y); BaseBlock block = clipboard.getBlock(mutable); if (block == EditSession.nullBlock) { continue; } - mutableTop.y = y + 1; - mutableRight.y = y; - mutableLeft.y = y; + mutableTop.mutY(y + 1); + mutableRight.mutY(y); + mutableLeft.mutY(y); if (clipboard.getBlock(mutableTop) != EditSession.nullBlock && clipboard.getBlock(mutableRight) != EditSession.nullBlock && clipboard.getBlock(mutableLeft) != EditSession.nullBlock) { continue; } diff --git a/core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java b/core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java index 23b14a1c..17e9f829 100644 --- a/core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java +++ b/core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java @@ -13,6 +13,7 @@ import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.NamedTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.entity.BaseEntity; @@ -171,7 +172,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { Map structure = FaweCache.asMap("version", 1, "author", owner); // ignored: version / owner - Vector mutable = new Vector(0, 0, 0); + MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); int[] indexes = new int[MAX_SIZE]; // Size structure.put("size", Arrays.asList(width, height, length)); diff --git a/core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java b/core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java index 91a22e38..1a777dd5 100644 --- a/core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java +++ b/core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.visitor; import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.IntegerTrio; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; @@ -76,7 +77,7 @@ public abstract class DFSVisitor implements Operation { NodePair current; Node from; Node adjacent; - Vector mutable = new Vector(); + MutableBlockVector mutable = new MutableBlockVector(); Vector mutable2 = new Vector(); int countAdd,countAttempt; IntegerTrio[] dirs = getIntDirections(); @@ -88,16 +89,16 @@ public abstract class DFSVisitor implements Operation { if (visited.containsKey(from)) { continue; } - mutable.x = from.getX(); - mutable.y = from.getY(); - mutable.z = from.getZ(); + mutable.mutX(from.getX()); + mutable.mutY(from.getY()); + mutable.mutZ(from.getZ()); function.apply(mutable); countAdd = 0; countAttempt = 0; for (IntegerTrio direction : dirs) { - mutable2.x = from.getX() + direction.x; - mutable2.y = from.getY() + direction.y; - mutable2.z = from.getZ() + direction.z; + mutable2.mutX(from.getX() + direction.x); + mutable2.mutY(from.getY() + direction.y); + mutable2.mutZ(from.getZ() + direction.z); if (isVisitable(mutable, mutable2)) { adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ()); if ((current.from == null || !adjacent.equals(current.from))) { diff --git a/core/src/main/java/com/boydti/fawe/object/visitor/FuzzySearch.java b/core/src/main/java/com/boydti/fawe/object/visitor/FuzzySearch.java index 3b34b11d..2512d333 100644 --- a/core/src/main/java/com/boydti/fawe/object/visitor/FuzzySearch.java +++ b/core/src/main/java/com/boydti/fawe/object/visitor/FuzzySearch.java @@ -72,9 +72,9 @@ public class FuzzySearch implements Operation { int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); int y = b1; int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); - pos.x = x; - pos.y = y; - pos.z = z; + pos.mutX(x); + pos.mutY(y); + pos.mutZ(z); if (mask.test(pos)) { affected++; region.set(x, y, z); diff --git a/core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java b/core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java index 89d47b62..509e756e 100644 --- a/core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java +++ b/core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java @@ -531,7 +531,7 @@ public class CuboidClipboard { } if (aroundPlayer) { - offset.x = 1 - offset.x - width; + offset.mutX(1 - offset.getX() - width); } break; @@ -565,7 +565,7 @@ public class CuboidClipboard { } if (aroundPlayer) { - offset.z = 1 - offset.getZ() - length; + offset.mutZ(1 - offset.getZ() - length); } break; @@ -597,7 +597,7 @@ public class CuboidClipboard { } if (aroundPlayer) { - offset.y = 1 - offset.getY() - height; + offset.mutY(1 - offset.getY() - height); } break; @@ -697,11 +697,11 @@ public class CuboidClipboard { int oy = newOrigin.getBlockY(); int oz = newOrigin.getBlockZ(); for (int x = 0; x < size.getBlockX(); ++x) { - v.x = x + ox; + v.mutX(x + ox); for (int y = 0; y < size.getBlockY(); ++y) { - v.y = y + oy; + v.mutY(y + oy); for (int z = 0; z < size.getBlockZ(); ++z) { - v.z = z + oz; + v.mutZ(z + oz); final BaseBlock block = getBlock(x,y,z); if (block == null) { continue; diff --git a/core/src/main/java/com/sk89q/worldedit/EditSession.java b/core/src/main/java/com/sk89q/worldedit/EditSession.java index 070a06a4..12af9dba 100644 --- a/core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -182,7 +182,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting private int changes = 0; private BlockBag blockBag; - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); private final int maxY; @@ -1956,9 +1956,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting @Override // Only copy what's necessary public boolean apply(Vector position) throws WorldEditException { - mutable.x = (position.getX() - displace.getX()); - mutable.y = (position.getY() - displace.getY()); - mutable.z = (position.getZ() - displace.getZ()); + mutable.mutX((position.getX() - displace.getX())); + mutable.mutY((position.getY() - displace.getY())); + mutable.mutZ((position.getZ() - displace.getZ())); if (region.contains(mutable)) { return false; } @@ -2157,11 +2157,11 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting return this.changes; } else if (height < 0) { height = -height; - pos.y -= height; + pos.mutY(pos.getY() - height); } if (pos.getBlockY() < 0) { - pos.y = 0; + pos.mutY(0); } else if (((pos.getBlockY() + height) - 1) > maxY) { height = (maxY - pos.getBlockY()) + 1; } @@ -3198,15 +3198,15 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting if (!chunks.contains(new Vector2D(cx + 1, cz + 1)) && !conNextX && !conNextZ) { setExistingBlocks(new Vector(bx + 16, 0, bz + 16), new Vector(bx + 31, getMaxY(), bz + 31)); } - Vector mutable = new Vector(0,0,0); + MutableBlockVector mutable = new MutableBlockVector(0,0,0); for (int x = 0; x < tx; x++) { int xx = x + bx; - mutable.x = xx; + mutable.mutX(xx); for (int z = 0; z < tz; z++) { int zz = z + bz; - mutable.z = zz; + mutable.mutZ(zz); for (int y = 0; y < getMaxY() + 1; y++) { - mutable.y = y; + mutable.mutY(y); int from = queue.getCombinedId4Data(xx, y, zz); boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mutable); if (contains) { diff --git a/core/src/main/java/com/sk89q/worldedit/MutableBlockVector.java b/core/src/main/java/com/sk89q/worldedit/MutableBlockVector.java new file mode 100644 index 00000000..9e748fc7 --- /dev/null +++ b/core/src/main/java/com/sk89q/worldedit/MutableBlockVector.java @@ -0,0 +1,81 @@ +package com.sk89q.worldedit; + +public class MutableBlockVector extends BlockVector { + private int x,y,z; + + public MutableBlockVector(int x, int y, int z) { + super(0, 0, 0); + this.x = x; + this.y = y; + this.z = z; + } + + public MutableBlockVector() { + super(0, 0, 0); + } + + @Override + public Vector setComponents(double x, double y, double z) { + return this.setComponents((int) x, (int) y, (int) z); + } + + @Override + public final void mutX(double x) { + this.x = (int) x; + } + + @Override + public final void mutY(double y) { + this.y = (int) y; + } + + @Override + public final void mutZ(double z) { + this.z = (int) z; + } + + @Override + public final void mutX(int x) { + this.x = x; + } + + @Override + public final void mutY(int y) { + this.y = y; + } + + @Override + public final void mutZ(int z) { + this.z = z; + } + + @Override + public final double getX() { + return x; + } + + @Override + public final double getY() { + return y; + } + + @Override + public final double getZ() { + return z; + } + + @Override + public int getBlockX() { + return this.x; + } + + @Override + public int getBlockY() { + return this.y; + } + + @Override + public int getBlockZ() { + return this.z; + } +} diff --git a/core/src/main/java/com/sk89q/worldedit/Vector.java b/core/src/main/java/com/sk89q/worldedit/Vector.java index 280dcae8..5938c130 100644 --- a/core/src/main/java/com/sk89q/worldedit/Vector.java +++ b/core/src/main/java/com/sk89q/worldedit/Vector.java @@ -34,9 +34,9 @@ public class Vector implements Comparable { public static final Vector UNIT_Z = new Vector(0, 0, 1); public static final Vector ONE = new Vector(1, 1, 1); - public double x; - public double y; - public double z; + private double x; + private double y; + private double z; /** * Construct an instance. @@ -46,9 +46,9 @@ public class Vector implements Comparable { * @param z the Z coordinate */ public Vector(double x, double y, double z) { - this.x = x; - this.y = y; - this.z = z; + this.mutX(x); + this.mutY(y); + this.mutZ(z); } /** @@ -59,9 +59,9 @@ public class Vector implements Comparable { * @param z the Z coordinate */ public Vector(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; + this.mutX(x); + this.mutY(y); + this.mutZ(z); } /** @@ -72,9 +72,9 @@ public class Vector implements Comparable { * @param z the Z coordinate */ public Vector(float x, float y, float z) { - this.x = x; - this.y = y; - this.z = z; + this.mutX(x); + this.mutY(y); + this.mutZ(z); } /** @@ -83,9 +83,9 @@ public class Vector implements Comparable { * @param other another vector to make a copy of */ public Vector(Vector other) { - this.x = other.x; - this.y = other.y; - this.z = other.z; + this.mutX(other.getX()); + this.mutY(other.getY()); + this.mutZ(other.getZ()); } /** @@ -94,9 +94,47 @@ public class Vector implements Comparable { *

One can also refer to a static {@link #ZERO}.

*/ public Vector() { - this.x = 0; - this.y = 0; - this.z = 0; + this.mutX(0); + this.mutY(0); + this.mutZ(0); + } + + public Vector setComponents(int x, int y, int z) { + this.mutX(x); + this.mutY(y); + this.mutZ(z); + return this; + } + + public Vector setComponents(double x, double y, double z) { + this.mutX(x); + this.mutY(y); + this.mutZ(z); + return this; + } + + public void mutX(int x) { + this.x = x; + } + + public void mutY(int y) { + this.y = y; + } + + public void mutZ(int z) { + this.z = z; + } + + public void mutX(double x) { + this.x = x; + } + + public void mutY(double y) { + this.y = y; + } + + public void mutZ(double z) { + this.z = z; } /** @@ -104,7 +142,7 @@ public class Vector implements Comparable { * * @return the x coordinate */ - public final double getX() { + public double getX() { return x; } @@ -142,7 +180,7 @@ public class Vector implements Comparable { * * @return the y coordinate */ - public final double getY() { + public double getY() { return y; } @@ -180,7 +218,7 @@ public class Vector implements Comparable { * * @return the z coordinate */ - public final double getZ() { + public double getZ() { return z; } diff --git a/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 8bd82a61..0f8de610 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -360,7 +360,7 @@ public class BrushCommands { public void heightBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); File file = new File(Fawe.imp().getDirectory(), "heightmap" + File.separator + (filename.endsWith(".png") ? filename : filename + ".png")); - BrushTool tool = session.getBrushTool(player.getItemInHand()); + DoubleActionBrushTool tool = session.getDoubleActionBrushTool(player.getItemInHand()); tool.setSize(radius); try { tool.setBrush(new HeightBrush(file, rotation, yscale, tool, session.getClipboard().getClipboard()), "worldedit.brush.height"); diff --git a/core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index d620093d..5526d520 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -363,12 +363,12 @@ public class ClipboardCommands { BlockArrayClipboard bac = (BlockArrayClipboard) clipboard; bac.IMP.forEach(new RunnableVal2() { @Override - public void run(Vector pos, BaseBlock block) { - pos.x += relx; - pos.y += rely; - pos.z += relz; - if (pos.getY() >= 0 && pos.getY() <= maxY) { - editSession.setBlockFast(pos, block); + public void run(Vector mutable, BaseBlock block) { + mutable.mutX(mutable.getX() + relx); + mutable.mutY(mutable.getY() + rely); + mutable.mutZ(mutable.getZ() + relz); + if (mutable.getY() >= 0 && mutable.getY() <= maxY) { + editSession.setBlockFast(mutable, block); } } }, !ignoreAirBlocks); @@ -379,16 +379,16 @@ public class ClipboardCommands { final int relz = to.getBlockZ() - origin.getBlockZ(); Iterator iter = region.iterator(); while (iter.hasNext()) { - BlockVector loc = iter.next(); - BaseBlock block = clipboard.getBlock(loc); + BlockVector mutable = iter.next(); + BaseBlock block = clipboard.getBlock(mutable); if (block == EditSession.nullBlock && ignoreAirBlocks) { continue; } - loc.x += relx; - loc.y += rely; - loc.z += relz; - if (loc.getY() >= 0 && loc.getY() <= maxY) { - editSession.setBlockFast(loc, block); + mutable.mutX(mutable.getX() + relx); + mutable.mutY(mutable.getY() + rely); + mutable.mutZ(mutable.getZ() + relz); + if (mutable.getY() >= 0 && mutable.getY() <= maxY) { + editSession.setBlockFast(mutable, block); } } } diff --git a/core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java b/core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java index d557ed88..fddeed77 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java +++ b/core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java @@ -80,15 +80,17 @@ public class FlattenedClipboardTransform { transform, new AffineTransform().translate(original.getOrigin())); + // new Vector(minimum.getX(), minimum.getY(), minimum.getZ()) + // new Vector(maximum.getX(), maximum.getY(), maximum.getZ()) Vector[] corners = new Vector[] { minimum, maximum, - minimum.setX(maximum.getX()), - minimum.setY(maximum.getY()), - minimum.setZ(maximum.getZ()), - maximum.setX(minimum.getX()), - maximum.setY(minimum.getY()), - maximum.setZ(minimum.getZ()) }; + new Vector(maximum.getX(), minimum.getY(), minimum.getZ()), + new Vector(minimum.getX(), maximum.getY(), minimum.getZ()), + new Vector(minimum.getX(), minimum.getY(), maximum.getZ()), + new Vector(minimum.getX(), maximum.getY(), maximum.getZ()), + new Vector(maximum.getX(), minimum.getY(), maximum.getZ()), + new Vector(maximum.getX(), maximum.getY(), minimum.getZ()) }; for (int i = 0; i < corners.length; i++) { corners[i] = transformAround.apply(new Vector(corners[i])); @@ -104,13 +106,9 @@ public class FlattenedClipboardTransform { // After transformation, the points may not really sit on a block, // so we should expand the region for edge cases - newMinimum = newMinimum.setX(Math.floor(newMinimum.getX())); - newMinimum = newMinimum.setY(Math.floor(newMinimum.getY())); - newMinimum = newMinimum.setZ(Math.floor(newMinimum.getZ())); - - newMaximum = newMaximum.setX(Math.ceil(newMaximum.getX())); - newMaximum = newMaximum.setY(Math.ceil(newMaximum.getY())); - newMaximum = newMaximum.setZ(Math.ceil(newMaximum.getZ())); + newMinimum.mutX(Math.ceil(Math.floor(newMinimum.getX()))); + newMinimum.mutY(Math.ceil(Math.floor(newMinimum.getY()))); + newMinimum.mutZ(Math.ceil(Math.floor(newMinimum.getZ()))); return new CuboidRegion(newMinimum, newMaximum); } diff --git a/core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index d6b3f422..f93839b5 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -301,9 +301,9 @@ public class GenerationCommands { zero = max.add(min).multiply(0.5); unit = max.subtract(zero); - if (unit.getX() == 0) unit.x = 1; - if (unit.getY() == 0) unit.y = 1; - if (unit.getZ() == 0) unit.z = 1; + if (unit.getX() == 0) unit.mutX(1); + if (unit.getY() == 0) unit.mutY(1); + if (unit.getZ() == 0) unit.mutZ(1); } try { @@ -366,9 +366,9 @@ public class GenerationCommands { zero = max.add(min).multiply(0.5); unit = max.subtract(zero); - if (unit.getX() == 0) unit.x = 1; - if (unit.getY() == 0) unit.y = 1; - if (unit.getZ() == 0) unit.z = 1; + if (unit.getX() == 0) unit.mutX(1); + if (unit.getY() == 0) unit.mutY(1); + if (unit.getZ() == 0) unit.mutZ(1); } try { diff --git a/core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java b/core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java index 3189b558..56f9b573 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java @@ -170,9 +170,9 @@ public class HistoryCommands { final World world = player.getWorld(); WorldVector origin = player.getPosition(); Vector bot = origin.subtract(radius, radius, radius); - bot.y = Math.max(0, bot.getY()); + bot.mutY(Math.max(0, bot.getY())); Vector top = origin.add(radius, radius, radius); - top.y = Math.min(255, top.getY()); + top.mutY(Math.min(255, top.getY())); RollbackDatabase database = DBHandler.IMP.getDatabase(world); final AtomicInteger count = new AtomicInteger(); final FawePlayer fp = FawePlayer.wrap(player); diff --git a/core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 8544f1fa..8682db64 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -595,9 +595,9 @@ public class RegionCommands { zero = max.add(min).multiply(0.5); unit = max.subtract(zero); - if (unit.getX() == 0) unit.x = 1; - if (unit.getY() == 0) unit.y = 1; - if (unit.getZ() == 0) unit.z = 1; + if (unit.getX() == 0) unit.mutX(1); + if (unit.getY() == 0) unit.mutY(1); + if (unit.getZ() == 0) unit.mutZ(1); } try { diff --git a/core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java b/core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java index 927fc7fa..ede143b9 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java +++ b/core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java @@ -60,14 +60,14 @@ public class GravityBrush implements Brush { continue; } BaseBlock block = editSession.getLazyBlock(x, y, z); - mutablePos.x = x; - mutablePos.y = y; - mutablePos.z = z; + mutablePos.mutX(x); + mutablePos.mutY(y); + mutablePos.mutZ(z); if (block != EditSession.nullBlock && (mask == null || mask.test(mutablePos))) { if (freeSpot != y) { - mutablePos.y = freeSpot; + mutablePos.mutY(freeSpot); editSession.setBlockFast(mutablePos, block); - mutablePos.y = y; + mutablePos.mutY(y); editSession.setBlockFast(mutablePos, EditSession.nullBlock); } freeSpot++; diff --git a/core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 6ecacf00..c448452b 100644 --- a/core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -74,7 +74,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class PlatformManager { - private static final Logger logger = Logger.getLogger(PlatformManager.class.getCanonicalName()); + private final Logger logger = Logger.getLogger(PlatformManager.class.getCanonicalName()); private final WorldEdit worldEdit; private final CommandManager commandManager; @@ -337,6 +337,10 @@ public class PlatformManager { return tool; } + public void handleMove() { + + } + @SuppressWarnings("deprecation") @Subscribe public void handleBlockInteract(BlockInteractEvent event) { diff --git a/core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index 1af33258..cf5d5b70 100644 --- a/core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.extent; import com.boydti.fawe.object.extent.LightingExtent; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; @@ -114,12 +115,12 @@ public abstract class AbstractDelegateExtent implements LightingExtent { return extent.getLazyBlock(position); } - private Vector mutable = new Vector(0,0,0); + private MutableBlockVector mutable = new MutableBlockVector(0,0,0); public BaseBlock getLazyBlock(int x, int y, int z) { - mutable.x = x; - mutable.y = y; - mutable.z = z; + mutable.mutX(x); + mutable.mutY(y); + mutable.mutZ(z); return extent.getLazyBlock(mutable); } @@ -129,9 +130,9 @@ public abstract class AbstractDelegateExtent implements LightingExtent { } public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException { - mutable.x = x; - mutable.y = y; - mutable.z = z; + mutable.mutX(x); + mutable.mutY(y); + mutable.mutZ(z); return setBlock(mutable, block); } diff --git a/core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index 857cab03..394182b7 100644 --- a/core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -26,6 +26,7 @@ import com.boydti.fawe.object.clipboard.MemoryOptimizedClipboard; import com.boydti.fawe.object.extent.LightingExtent; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; @@ -60,7 +61,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent { private int my; private int mz; private Vector origin; - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); public BlockArrayClipboard(Region region) { checkNotNull(region); @@ -249,9 +250,9 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent { @Override public int getOpacity(int x, int y, int z) { - mutable.x = x; - mutable.y = y; - mutable.z = z; + mutable.mutX(x); + mutable.mutY(y); + mutable.mutZ(z); BlockMaterial block = BundledBlockData.getInstance().getMaterialById(getBlock(mutable).getId()); if (block == null) { return 15; @@ -261,9 +262,9 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent { @Override public int getBrightness(int x, int y, int z) { - mutable.x = x; - mutable.y = y; - mutable.z = z; + mutable.mutX(x); + mutable.mutY(y); + mutable.mutZ(z); BlockMaterial block = BundledBlockData.getInstance().getMaterialById(getBlock(mutable).getId()); if (block == null) { return 15; diff --git a/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java b/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java index 8e698069..09654632 100644 --- a/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java +++ b/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java @@ -16,6 +16,7 @@ import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.entity.BaseEntity; @@ -286,12 +287,12 @@ public class SchematicWriter implements ClipboardWriter { final int mx = min.getBlockX(); final int my = min.getBlockY(); final int mz = min.getBlockZ(); - Vector mutable = new Vector(0, 0, 0); + MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); ForEach forEach = new ForEach(yarea, zwidth, blocks, blockData, tileEntities); for (Vector point : region) { - mutable.x = (point.getX() - mx); - mutable.y = (point.getY() - my); - mutable.z = (point.getZ() - mz); + mutable.mutX((point.getX() - mx)); + mutable.mutY((point.getY() - my)); + mutable.mutZ((point.getZ() - mz)); forEach.run(mutable, clipboard.getBlock(point)); } addBlocks = forEach.addBlocks; diff --git a/core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java b/core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java index 2e1a77bc..bd79f153 100644 --- a/core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java +++ b/core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java @@ -101,9 +101,9 @@ public class ExtentBlockCopy implements RegionFunction { if (direction != null) { Vector applyAbsolute = transform.apply(direction.toVector()); Vector applyOrigin = transform.apply(Vector.ZERO); - applyAbsolute.x -= applyOrigin.getX(); - applyAbsolute.y -= applyOrigin.getY(); - applyAbsolute.z -= applyOrigin.getZ(); + applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX()); + applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY()); + applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ()); Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL); diff --git a/core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java b/core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java index 61c4d0a7..34882a0c 100644 --- a/core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java +++ b/core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java @@ -1,9 +1,10 @@ package com.sk89q.worldedit.function.mask; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; - import javax.annotation.Nullable; + import static com.google.common.base.Preconditions.checkNotNull; /** @@ -14,7 +15,7 @@ public class OffsetMask extends AbstractMask { private Mask mask; private Vector offset; - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); /** * Create a new instance. @@ -69,9 +70,9 @@ public class OffsetMask extends AbstractMask { @Override public boolean test(Vector vector) { - mutable.x = (vector.getX() + offset.getX()); - mutable.y = (vector.getY() + offset.getY()); - mutable.z = (vector.getZ() + offset.getZ()); + mutable.mutX((vector.getX() + offset.getX())); + mutable.mutY((vector.getY() + offset.getY())); + mutable.mutZ((vector.getZ() + offset.getZ())); return getMask().test(mutable); } diff --git a/core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java b/core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java index 4a89ec8a..c8a46cd2 100644 --- a/core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java +++ b/core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java @@ -1,9 +1,11 @@ package com.sk89q.worldedit.function.pattern; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.clipboard.Clipboard; + import static com.google.common.base.Preconditions.checkNotNull; /** @@ -30,7 +32,7 @@ public class ClipboardPattern extends AbstractPattern { this.min = clipboard.getMinimumPoint(); } - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); @Override public BaseBlock apply(Vector position) { @@ -40,9 +42,9 @@ public class ClipboardPattern extends AbstractPattern { if (xp < 0) xp += sx; if (yp < 0) yp += sy; if (zp < 0) zp += sz; - mutable.x = (min.getX() + xp); - mutable.y = (min.getY() + yp); - mutable.z = (min.getZ() + zp); + mutable.mutX((min.getX() + xp)); + mutable.mutY((min.getY() + yp)); + mutable.mutZ((min.getZ() + zp)); return clipboard.getBlock(mutable); } diff --git a/core/src/main/java/com/sk89q/worldedit/function/pattern/Patterns.java b/core/src/main/java/com/sk89q/worldedit/function/pattern/Patterns.java index 36ea51db..f71f3ba8 100644 --- a/core/src/main/java/com/sk89q/worldedit/function/pattern/Patterns.java +++ b/core/src/main/java/com/sk89q/worldedit/function/pattern/Patterns.java @@ -1,8 +1,10 @@ package com.sk89q.worldedit.function.pattern; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; + import static com.google.common.base.Preconditions.checkNotNull; /** @@ -38,7 +40,7 @@ public final class Patterns { public static com.sk89q.worldedit.patterns.Pattern wrap(final Pattern pattern) { checkNotNull(pattern); return new com.sk89q.worldedit.patterns.Pattern() { - private Vector mutable = new Vector(0, 0, 0); + private MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); @Override public BaseBlock next(Vector position) { return pattern.apply(position); @@ -46,9 +48,9 @@ public final class Patterns { @Override public BaseBlock next(int x, int y, int z) { - mutable.x = x; - mutable.y = y; - mutable.z = z; + mutable.mutX(x); + mutable.mutY(y); + mutable.mutZ(z); return next(mutable); } }; diff --git a/core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index b7ee5440..33e525ed 100644 --- a/core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -2,6 +2,7 @@ package com.sk89q.worldedit.function.visitor; import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.IntegerTrio; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; @@ -97,7 +98,7 @@ public abstract class BreadthFirstSearch implements Operation { public Operation resume(RunContext run) throws WorldEditException { Node from; Node adjacent; - Vector mutable = new Vector(); + MutableBlockVector mutable = new MutableBlockVector(); Vector mutable2 = new Vector(); boolean shouldTrim = false; IntegerTrio[] dirs = getIntDirections(); @@ -106,9 +107,9 @@ public abstract class BreadthFirstSearch implements Operation { if (layer == maxDepth) { cleanVisited(Integer.MAX_VALUE); for (Node current : queue) { - mutable.x = current.getX(); - mutable.y = current.getY(); - mutable.z = current.getZ(); + mutable.mutX(current.getX()); + mutable.mutY(current.getY()); + mutable.mutZ(current.getZ()); function.apply(mutable); affected++; } @@ -116,15 +117,15 @@ public abstract class BreadthFirstSearch implements Operation { } for (int i = 0; i < size; i++) { from = queue.poll(); - mutable.x = from.getX(); - mutable.y = from.getY(); - mutable.z = from.getZ(); + mutable.mutX(from.getX()); + mutable.mutY(from.getY()); + mutable.mutZ(from.getZ()); function.apply(mutable); affected++; for (IntegerTrio direction : dirs) { - mutable2.x = from.getX() + direction.x; - mutable2.y = from.getY() + direction.y; - mutable2.z = from.getZ() + direction.z; + mutable2.mutX(from.getX() + direction.x); + mutable2.mutY(from.getY() + direction.y); + mutable2.mutZ(from.getZ() + direction.z); if (isVisitable(mutable, mutable2)) { adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ()); if (!isVisited(adjacent)) { diff --git a/core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java b/core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java index a7ad1ed6..10995790 100644 --- a/core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java +++ b/core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java @@ -21,11 +21,12 @@ package com.sk89q.worldedit.math.interpolation; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; - import java.util.Collections; import java.util.List; + import static com.google.common.base.Preconditions.checkNotNull; /** @@ -136,7 +137,7 @@ public class KochanekBartelsInterpolation implements Interpolation { return nodes.get(index).getPosition(); } - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); @Override public Vector getPosition(double position) { @@ -158,9 +159,9 @@ public class KochanekBartelsInterpolation implements Interpolation { double r2 = remainder * remainder; double r3 = r2 * remainder; - mutable.x = (a.getX() * r3 + b.getX() * r2 + c.getX() * remainder + d.getX()); - mutable.y = (a.getY() * r3 + b.getY() * r2 + c.getY() * remainder + d.getY()); - mutable.z = (a.getZ() * r3 + b.getZ() * r2 + c.getZ() * remainder + d.getZ()); + mutable.mutX((a.getX() * r3 + b.getX() * r2 + c.getX() * remainder + d.getX())); + mutable.mutY((a.getY() * r3 + b.getY() * r2 + c.getY() * remainder + d.getY())); + mutable.mutZ((a.getZ() * r3 + b.getZ() * r2 + c.getZ() * remainder + d.getZ())); return mutable; } diff --git a/core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java index c9aff7ce..249475a7 100644 --- a/core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java +++ b/core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java @@ -1,5 +1,6 @@ package com.sk89q.worldedit.math.transform; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.math.MathUtils; @@ -12,7 +13,7 @@ import com.sk89q.worldedit.math.MathUtils; */ public class AffineTransform implements Transform { - private Vector mutable = new Vector(); + private MutableBlockVector mutable = new MutableBlockVector(); /** * coefficients for x coordinate. @@ -274,9 +275,9 @@ public class AffineTransform implements Transform { // vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03 // vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13 // vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23 - mutable.x = (vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03); - mutable.y = (vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13); - mutable.z = (vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23); + mutable.mutX((vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03)); + mutable.mutY((vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13)); + mutable.mutZ((vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23)); return mutable; // return new Vector( // vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03, diff --git a/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index c513e1bf..0eb307b2 100644 --- a/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -23,6 +23,7 @@ import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.LocalWorld; +import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.world.World; @@ -146,16 +147,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return new RegionIntersection( // Project to Z-Y plane - new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())), - new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())), + new CuboidRegion(new Vector(min.getX(), pos1.getY(), pos1.getZ()), new Vector(min.getX(), pos2.getY(), pos2.getZ())), + new CuboidRegion(new Vector(max.getX(), pos1.getY(), pos1.getZ()), new Vector(max.getX(), pos2.getY(), pos2.getZ())), // Project to X-Y plane - new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())), - new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ())), + new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), min.getZ()), new Vector(pos2.getX(), pos2.getY(), min.getZ())), + new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), max.getZ()), new Vector(pos2.getX(), pos2.getY(), max.getZ())), // Project to the X-Z plane - new CuboidRegion(pos1.setY(min.getY()), pos2.setY(min.getY())), - new CuboidRegion(pos1.setY(max.getY()), pos2.setY(max.getY()))); + new CuboidRegion(new Vector(pos1.getX(), min.getY(), pos1.getZ()), new Vector(pos2.getX(), min.getY(), pos2.getZ())), + new CuboidRegion(new Vector(pos1.getX(), max.getY(), pos1.getZ()), new Vector(pos2.getX(), max.getY(), pos2.getZ()))); } /** @@ -170,12 +171,12 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return new RegionIntersection( // Project to Z-Y plane - new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())), - new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())), + new CuboidRegion(new Vector(min.getX(), pos1.getY(), pos1.getZ()), new Vector(min.getX(), pos2.getY(), pos2.getZ())), + new CuboidRegion(new Vector(max.getX(), pos1.getY(), pos1.getZ()), new Vector(max.getX(), pos2.getY(), pos2.getZ())), // Project to X-Y plane - new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())), - new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ()))); + new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), min.getZ()), new Vector(pos2.getX(), pos2.getY(), min.getZ())), + new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), max.getZ()), new Vector(pos2.getX(), pos2.getY(), max.getZ()))); } @Override @@ -359,7 +360,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { if (Settings.HISTORY.COMPRESSION_LEVEL >= 9) { return iterator_old(); } - final BlockVector v = new BlockVector(0,0,0); + final MutableBlockVector mutable = new MutableBlockVector(0,0,0); return new Iterator() { private Vector min = getMinimumPoint(); private Vector max = getMaximumPoint(); @@ -392,9 +393,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public BlockVector next() { - v.x = x; - v.y = y; - v.z = z; + mutable.mutX(x); + mutable.mutY(y); + mutable.mutZ(z); if (++x > ctx) { if (++z > ctz) { if (++y > ty) { @@ -403,7 +404,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { x = bx; if (z > tz) { hasNext = false; - return v; + return mutable; } } else { z = cbz; @@ -422,7 +423,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { x = cbx; } } - return v; + return mutable; } @Override @@ -433,7 +434,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } public Iterator iterator_old() { - final BlockVector v = new BlockVector(0,0,0); + final MutableBlockVector mutable = new MutableBlockVector(0,0,0); return new Iterator() { private Vector min = getMinimumPoint(); private Vector max = getMaximumPoint(); @@ -448,9 +449,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public BlockVector next() { - v.x = nextX; - v.y = nextY; - v.z = nextZ; + mutable.mutX(nextX); + mutable.mutY(nextY); + mutable.mutZ(nextZ); if (++nextX > max.getBlockX()) { nextX = min.getBlockX(); if (++nextY > max.getBlockY()) { @@ -460,7 +461,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } } } - return v; + return mutable; } @Override