From 92a7bd5e44dbf34870e90d66f224b66ef1e09508 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 1 Apr 2019 03:09:20 +1100 Subject: [PATCH] minor tweak for mutable vectors --- .../bukkit/adapter/IBukkitAdapter.java | 2 +- .../jnbt/anvil/HeightMapMCAGenerator.java | 65 +- .../filters/MappedReplacePatternFilter.java | 2 +- .../fawe/jnbt/anvil/generator/OreGen.java | 11 +- .../fawe/jnbt/anvil/generator/SchemGen.java | 10 +- .../boydti/fawe/logging/LoggingChangeSet.java | 4 +- .../boydti/fawe/logging/MutableVector.java | 4 +- .../com/boydti/fawe/object/FaweQueue.java | 12 +- .../boydti/fawe/object/brush/BlobBrush.java | 7 +- .../boydti/fawe/object/brush/CircleBrush.java | 2 +- .../boydti/fawe/object/brush/ImageBrush.java | 10 +- .../fawe/object/brush/InspectBrush.java | 4 +- .../boydti/fawe/object/brush/LayerBrush.java | 10 +- .../fawe/object/brush/ShatterBrush.java | 8 +- .../boydti/fawe/object/brush/SplineBrush.java | 8 +- .../fawe/object/brush/StencilBrush.java | 9 +- .../fawe/object/brush/SurfaceSpline.java | 4 +- .../object/brush/heightmap/HeightMap.java | 3 +- .../brush/heightmap/RotatableHeightMap.java | 8 +- .../brush/heightmap/ScalableHeightMap.java | 7 +- .../fawe/object/brush/sweep/SweepBrush.java | 6 +- .../object/change/MutableBiomeChange.java | 8 +- .../object/clipboard/WorldCopyClipboard.java | 16 +- .../object/collection/BlockVectorSet.java | 10 +- .../collection/LocalBlockVector2DSet.java | 8 +- .../collection/LocalBlockVectorSet.java | 12 +- .../object/extent/BlockTranslateExtent.java | 7 +- .../fawe/object/extent/OffsetExtent.java | 9 +- .../extent/PositionTransformExtent.java | 15 +- .../object/extent/RandomOffsetTransform.java | 9 +- .../fawe/object/extent/ScaleTransform.java | 21 +- .../fawe/object/extent/SourceMaskExtent.java | 7 +- .../fawe/object/extent/TransformExtent.java | 16 +- .../function/SurfaceRegionFunction.java | 6 +- .../fawe/object/function/block/BiomeCopy.java | 8 +- .../fawe/object/mask/AdjacentAnyMask.java | 10 +- .../boydti/fawe/object/mask/AdjacentMask.java | 18 +- .../boydti/fawe/object/mask/AngleMask.java | 6 +- .../boydti/fawe/object/mask/BiomeMask.java | 8 +- .../boydti/fawe/object/mask/CachedMask.java | 10 +- .../fawe/object/mask/MaskedTargetBlock.java | 2 +- .../fawe/object/mask/SolidPlaneMask.java | 12 +- .../com/boydti/fawe/object/mask/WallMask.java | 14 +- .../fawe/object/pattern/BiomePattern.java | 6 +- .../object/pattern/FullClipboardPattern.java | 4 +- .../fawe/object/pattern/NoXPattern.java | 8 +- .../fawe/object/pattern/NoYPattern.java | 6 +- .../fawe/object/pattern/NoZPattern.java | 6 +- .../fawe/object/pattern/OffsetPattern.java | 6 +- .../pattern/RandomFullClipboardPattern.java | 4 +- .../object/pattern/RandomOffsetPattern.java | 12 +- .../fawe/object/pattern/RelativePattern.java | 12 +- .../pattern/SolidRandomOffsetPattern.java | 14 +- .../pattern/SurfaceRandomOffsetPattern.java | 38 +- .../object/queue/FaweQueueDelegateExtent.java | 4 +- .../fawe/object/regions/PolyhedralRegion.java | 8 +- .../fawe/object/schematic/PNGWriter.java | 14 +- .../fawe/object/schematic/Schematic.java | 14 +- .../object/schematic/StructureFormat.java | 4 +- .../object/schematic/visualizer/SchemVis.java | 14 +- .../fawe/object/visitor/DFSVisitor.java | 6 +- .../com/boydti/fawe/util/TaskManager.java | 14 - .../java/com/sk89q/worldedit/EditSession.java | 63 +- .../com/sk89q/worldedit/LocalSession.java | 6 +- .../worldedit/command/BiomeCommands.java | 6 +- .../command/FlattenedClipboardTransform.java | 10 +- .../worldedit/command/GenerationCommands.java | 10 +- .../worldedit/command/HistoryCommands.java | 5 +- .../worldedit/command/NavigationCommands.java | 2 +- .../worldedit/command/RegionCommands.java | 5 +- .../worldedit/command/SelectionCommands.java | 17 +- .../worldedit/command/tool/AreaPickaxe.java | 7 +- .../command/tool/BlockDataCyler.java | 5 +- .../worldedit/command/tool/BlockReplacer.java | 12 +- .../worldedit/command/tool/BrushTool.java | 16 +- .../worldedit/command/tool/DistanceWand.java | 4 +- .../command/tool/FloatingTreeRemover.java | 4 +- .../worldedit/command/tool/FloodFillTool.java | 3 +- .../command/tool/LongRangeBuildTool.java | 8 +- .../worldedit/command/tool/QueryTool.java | 4 +- .../command/tool/RecursivePickaxe.java | 17 +- .../worldedit/command/tool/SinglePickaxe.java | 4 +- .../worldedit/command/tool/TreePlanter.java | 2 +- .../command/tool/brush/SmoothBrush.java | 2 +- .../platform/AbstractPlayerActor.java | 15 +- .../extension/platform/PlatformManager.java | 4 +- .../extension/platform/PlayerProxy.java | 3 +- .../extent/AbstractDelegateExtent.java | 4 +- .../sk89q/worldedit/extent/MaskingExtent.java | 2 +- .../extent/clipboard/BlockArrayClipboard.java | 6 +- .../transform/BlockTransformExtent.java | 2 + .../function/entity/ExtentEntityCopy.java | 5 +- .../operation/BackwardsExtentBlockCopy.java | 2 +- .../function/operation/ForwardExtentCopy.java | 2 +- .../function/pattern/FawePattern.java | 3 +- .../function/visitor/BreadthFirstSearch.java | 6 +- .../function/visitor/DirectionalVisitor.java | 2 +- .../command/CommandLoggingHandler.java | 2 +- .../sk89q/worldedit/math/BlockVector2.java | 67 +- .../sk89q/worldedit/math/BlockVector3.java | 52 +- .../worldedit/math/MutableBlockVector.java | 629 ------------------ .../worldedit/math/MutableBlockVector2.java | 52 ++ .../worldedit/math/MutableBlockVector2D.java | 594 ----------------- .../worldedit/math/MutableBlockVector3.java | 73 ++ .../sk89q/worldedit/math/MutableVector.java | 581 ---------------- .../sk89q/worldedit/math/MutableVector2.java | 70 ++ .../sk89q/worldedit/math/MutableVector3.java | 82 +++ .../com/sk89q/worldedit/math/Vector2.java | 68 +- .../com/sk89q/worldedit/math/Vector3.java | 89 ++- .../KochanekBartelsInterpolation.java | 4 +- .../math/transform/AffineTransform.java | 6 +- .../math/transform/RoundedTransform.java | 2 +- .../worldedit/math/transform/Transforms.java | 2 +- .../sk89q/worldedit/regions/CuboidRegion.java | 27 +- .../worldedit/regions/CylinderRegion.java | 2 +- .../worldedit/regions/EllipsoidRegion.java | 2 +- .../shape/WorldEditExpressionEnvironment.java | 7 +- .../com/sk89q/worldedit/util/Location.java | 37 +- .../com/sk89q/worldedit/util/TargetBlock.java | 9 +- .../sk89q/worldedit/util/LocationTest.java | 2 +- 120 files changed, 923 insertions(+), 2426 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2D.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector2.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java index 242e61796..1f6f5f3ec 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java @@ -113,7 +113,7 @@ public interface IBukkitAdapter { */ default org.bukkit.Location adapt(Location location) { checkNotNull(location); - Vector3 position = location.toVector(); + Vector3 position = location; return new org.bukkit.Location( adapt((World) location.getExtent()), position.getX(), position.getY(), position.getZ(), diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java index d64f2c702..96f7478cd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java @@ -16,6 +16,7 @@ import com.boydti.fawe.util.image.Drawable; import com.boydti.fawe.util.image.ImageViewer; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.*; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -24,8 +25,6 @@ import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; @@ -51,7 +50,7 @@ import javax.annotation.Nullable; // TODO FIXME public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld { - private final MutableBlockVector mutable = new MutableBlockVector(); + private final MutableBlockVector3 mutable = new MutableBlockVector3(); private final ThreadLocal indexStore = new ThreadLocal() { @Override @@ -528,7 +527,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights[index] & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { + if (mask.test(mutable)) { int newHeight = table.average(x, z, index); setLayerHeightRaw(index, newHeight); } @@ -583,7 +582,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } mutable.mutX(x); mutable.mutY(y); - if (!mask.test(mutable.toBlockVector3())) { + if (!mask.test(mutable)) { continue; } if (placed.containsRadius(x, z, distance)) { @@ -603,9 +602,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { - schematic.paste(this, mutable.toBlockVector3(), false); + schematic.paste(this, mutable, false); } else { - schematic.paste(this, mutable.toBlockVector3(), false, transform); + schematic.paste(this, mutable, false, transform); } if (x + distance < getWidth()) { x += distance; @@ -631,7 +630,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } mutable.mutX(x); mutable.mutY(y); - if (!mask.test(mutable.toBlockVector3())) { + if (!mask.test(mutable)) { continue; } if (placed.containsRadius(x, z, distance)) { @@ -652,9 +651,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { - schematic.paste(this, mutable.toBlockVector3(), false); + schematic.paste(this, mutable, false); } else { - schematic.paste(this, mutable.toBlockVector3(), false, transform); + schematic.paste(this, mutable, false, transform); } if (x + distance < getWidth()) { x += distance; @@ -1135,7 +1134,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (mask != null) { mutable.mutX(z); mutable.mutY(heights.getByte(index) & 0xFF); - if (!mask.test(mutable.toBlockVector3())) continue; + if (!mask.test(mutable)) continue; } if (imgMask != null) { int height = imgMask.getRGB(x, z) & 0xFF; @@ -1256,7 +1255,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr for (int x = 0; x < getWidth(); x++, index++) { mutable.mutX(x); mutable.mutY(heights.getByte(index) & 0xFF); - if (mask.test(mutable.toBlockVector3())) { + if (mask.test(mutable)) { int color = img.getRGB(x, z); BlockType block = textureUtil.getNearestBlock(color); if (block != null) { @@ -1332,7 +1331,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { + if (mask.test(mutable)) { biomes.setByte(index, biome); } } @@ -1362,7 +1361,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr .nextInt(256) <= height) { mutable.mutX(x); mutable.mutY(height); - overlayArr[index] = pattern.apply(mutable.toBlockVector3()).getInternalId(); + overlayArr[index] = pattern.apply(mutable).getInternalId(); } } } @@ -1390,7 +1389,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr .nextInt(256) <= height) { mutable.mutX(x); mutable.mutY(height); - mainArr[index] = pattern.apply(mutable.toBlockVector3()).getInternalId(); + mainArr[index] = pattern.apply(mutable).getInternalId(); } } } @@ -1416,7 +1415,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr .nextInt(256) <= height) { mutable.mutX(x); mutable.mutY(height); - floorArr[index] = pattern.apply(mutable.toBlockVector3()).getInternalId(); + floorArr[index] = pattern.apply(mutable).getInternalId(); } } } @@ -1444,7 +1443,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr .nextInt(256) <= height) { mutable.mutX(x); mutable.mutY(height); - int combined = pattern.apply(mutable.toBlockVector3()).getInternalId(); + int combined = pattern.apply(mutable).getInternalId(); mainArr[index] = combined; floorArr[index] = combined; } @@ -1466,8 +1465,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { - overlay.setInt(index, pattern.apply(mutable.toBlockVector3()).getInternalId()); + if (mask.test(mutable)) { + overlay.setInt(index, pattern.apply(mutable).getInternalId()); } } } @@ -1485,8 +1484,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { - floor.setInt(index, pattern.apply(mutable.toBlockVector3()).getInternalId()); + if (mask.test(mutable)) { + floor.setInt(index, pattern.apply(mutable).getInternalId()); } } } @@ -1505,8 +1504,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { - main.setInt(index, pattern.apply(mutable.toBlockVector3()).getInternalId()); + if (mask.test(mutable)) { + main.setInt(index, pattern.apply(mutable).getInternalId()); } } } @@ -1525,8 +1524,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { - int combined = pattern.apply(mutable.toBlockVector3()).getInternalId(); + if (mask.test(mutable)) { + int combined = pattern.apply(mutable).getInternalId(); floor.setInt(index, combined); main.setInt(index, combined); } @@ -1552,7 +1551,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - floorArr[index] = value.apply(mutable.toBlockVector3()).getInternalId(); + floorArr[index] = value.apply(mutable).getInternalId(); } } }); @@ -1573,7 +1572,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - int combined = value.apply(mutable.toBlockVector3()).getInternalId(); + int combined = value.apply(mutable).getInternalId(); mainArr[index] = combined; floorArr[index] = combined; } @@ -1595,7 +1594,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - mainArr[index] = value.apply(mutable.toBlockVector3()).getInternalId(); + mainArr[index] = value.apply(mutable).getInternalId(); } } }); @@ -1616,7 +1615,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - overlayArr[index] = value.apply(mutable.toBlockVector3()).getInternalId(); + overlayArr[index] = value.apply(mutable).getInternalId(); } } }); @@ -2003,7 +2002,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { + if (mask.test(mutable)) { overlay.setInt(index, combined); } } @@ -2018,7 +2017,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { + if (mask.test(mutable)) { floor.setInt(index, combined); } } @@ -2034,7 +2033,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { + if (mask.test(mutable)) { main.setInt(index, combined); } } @@ -2050,7 +2049,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable.toBlockVector3())) { + if (mask.test(mutable)) { floor.setInt(index, combined); main.setInt(index, combined); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/filters/MappedReplacePatternFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/filters/MappedReplacePatternFilter.java index 6023c0280..7be8caf8b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/filters/MappedReplacePatternFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/filters/MappedReplacePatternFilter.java @@ -52,7 +52,7 @@ public class MappedReplacePatternFilter extends MCAFilterCounter { // map[block.getCombined()] = pattern; } -// private final MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); +// private final MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); @Override public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong ignore) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/OreGen.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/OreGen.java index 8ce917252..7ded48ea7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/OreGen.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/OreGen.java @@ -1,12 +1,11 @@ package com.boydti.fawe.jnbt.anvil.generator; -import com.boydti.fawe.object.PseudoRandom; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import java.util.Random; @@ -20,7 +19,7 @@ public class OreGen extends Resource { private final Pattern pattern; private final Extent extent; private final Mask mask; - private MutableBlockVector mutable = new MutableBlockVector(); + private MutableBlockVector3 mutable = new MutableBlockVector3(); private double ONE_2 = 1 / 2F; private double ONE_8 = 1 / 8F; @@ -43,7 +42,7 @@ public class OreGen extends Resource { @Override public boolean spawn(Random rand, int x, int z) throws WorldEditException { int y = rand.nextInt(maxY - minY) + minY; - if (!mask.test(mutable.setComponents(x, y, z).toBlockVector3())) { + if (!mask.test(mutable.setComponents(x, y, z))) { return false; } double f = rand.nextDouble() * Math.PI; @@ -106,8 +105,8 @@ public class OreGen extends Resource { double dz = (zz + 0.5D - d9) * id11o2; double dxyz2 = dxy2 + dz * dz; if ((dxyz2 < 1)) { - if (mask.test(mutable.toBlockVector3())) - pattern.apply(extent, mutable.toBlockVector3(), mutable.toBlockVector3()); + if (mask.test(mutable)) + pattern.apply(extent, mutable, mutable); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/SchemGen.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/SchemGen.java index bf0570823..a404b38e5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/SchemGen.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/SchemGen.java @@ -2,7 +2,7 @@ package com.boydti.fawe.jnbt.anvil.generator; import com.boydti.fawe.object.PseudoRandom; import com.boydti.fawe.object.schematic.Schematic; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -20,7 +20,7 @@ public class SchemGen extends Resource { private final boolean randomRotate; private final Mask mask; - private MutableBlockVector mutable = new MutableBlockVector(); + private MutableBlockVector3 mutable = new MutableBlockVector3(); public SchemGen(Mask mask, Extent extent, List clipboards, boolean randomRotate) { this.mask = mask; @@ -36,7 +36,7 @@ public class SchemGen extends Resource { int y = extent.getNearestSurfaceTerrainBlock(x, z, mutable.getBlockY(), 0, 255); if (y == -1) return false; mutable.mutY(y); - if (!mask.test(mutable.toBlockVector3())) { + if (!mask.test(mutable)) { return false; } mutable.mutY(y + 1); @@ -48,9 +48,9 @@ public class SchemGen extends Resource { Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { - schematic.paste(extent, mutable.toBlockVector3(), false); + schematic.paste(extent, mutable, false); } else { - schematic.paste(extent, mutable.toBlockVector3(), false, transform); + schematic.paste(extent, mutable, false, transform); } mutable.mutY(y); return true; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java index 13c6e0ed5..8ac50bbde 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java @@ -27,7 +27,7 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet { // public static IBlocksHubApi api; // -// private final MutableVector loc; +// private final MutableVector3 loc; // private final IPlayer player; // private IWorld world; // private final MutableBlockData oldBlock; @@ -46,7 +46,7 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet { // } catch (Throwable ignore) { // this.world = api.getWorld(world); // } -// this.loc = new MutableVector(); +// this.loc = new MutableVector3(); // this.oldBlock = new MutableBlockData(); // this.newBlock = new MutableBlockData(); // this.player = api.getPlayer(player.getUUID()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/logging/MutableVector.java b/worldedit-core/src/main/java/com/boydti/fawe/logging/MutableVector.java index 974fd06ea..d2a4e4af0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/logging/MutableVector.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/logging/MutableVector.java @@ -2,11 +2,11 @@ // //import org.primesoft.blockshub.api.Vector; // -//public class MutableVector extends Vector { +//public class MutableVector3 extends Vector { // // public double x, y, z; // -// public MutableVector() { +// public MutableVector3() { // super(0, 0, 0); // this.x = 0; // this.y = 0; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweQueue.java index eb6dd406a..026d9d38f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweQueue.java @@ -18,7 +18,7 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BaseBiome; @@ -273,7 +273,7 @@ public interface FaweQueue extends HasFaweQueue, Extent { default void forEachBlockInChunk(int cx, int cz, RunnableVal2 onEach) { int bx = cx << 4; int bz = cz << 4; - MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); + MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); for (int x = 0; x < 16; x++) { int xx = x + bx; mutable.mutX(xx); @@ -290,9 +290,9 @@ public interface FaweQueue extends HasFaweQueue, Extent { mutable.mutY(y); CompoundTag tile = getTileEntity(x, y, z); if (tile != null) { - onEach.run(mutable.toBlockVector3(), block.toBaseBlock(tile)); + onEach.run(mutable, block.toBaseBlock(tile)); } else { - onEach.run(mutable.toBlockVector3(), block); + onEach.run(mutable, block); } } } @@ -302,7 +302,7 @@ public interface FaweQueue extends HasFaweQueue, Extent { default void forEachTileInChunk(int cx, int cz, RunnableVal2 onEach) { int bx = cx << 4; int bz = cz << 4; - MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); + MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); for (int x = 0; x < 16; x++) { int xx = x + bx; for (int z = 0; z < 16; z++) { @@ -320,7 +320,7 @@ public interface FaweQueue extends HasFaweQueue, Extent { mutable.mutZ(zz); mutable.mutY(y); BaseBlock block = BaseBlock.getFromInternalId(combined, tile); - onEach.run(mutable.toBlockVector3(), block); + onEach.run(mutable, block); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java index 4cf217e94..db139fbf7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java @@ -7,8 +7,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import java.util.concurrent.ThreadLocalRandom; @@ -72,7 +71,7 @@ public class BlobBrush implements Brush { double manScaleY = (1.25 + seedY * 0.5); double manScaleZ = (1.25 + seedZ * 0.5); - MutableVector mutable = new MutableVector(); + MutableVector3 mutable = new MutableVector3(); double roughness = 1 - sphericity; for (int xr = -sizeInt; xr <= sizeInt; xr++) { mutable.mutX(xr); @@ -80,7 +79,7 @@ public class BlobBrush implements Brush { mutable.mutY(yr); for (int zr = -sizeInt; zr <= sizeInt; zr++) { mutable.mutZ(zr); - Vector3 pt = transform.apply(mutable.toVector3()); + Vector3 pt = transform.apply(mutable); int x = MathMan.roundInt(pt.getX()); int y = MathMan.roundInt(pt.getY()); int z = MathMan.roundInt(pt.getZ()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CircleBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CircleBrush.java index e5228c347..cea101db8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CircleBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CircleBrush.java @@ -19,7 +19,7 @@ public class CircleBrush implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { - Vector3 normal = position.toVector3().subtract(player.getLocation().toVector()); + Vector3 normal = position.toVector3().subtract(player.getLocation()); editSession.makeCircle(position, pattern, size, size, size, false, normal); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java index 4dd7018c0..31d9ace89 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java @@ -6,16 +6,14 @@ import com.boydti.fawe.util.TextureUtil; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.util.Location; @@ -89,7 +87,7 @@ public class ImageBrush implements Brush { AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX((pitch - 90) % 360).inverse(); RecursiveVisitor visitor = new RecursiveVisitor(new Mask() { - private final MutableVector mutable = new MutableVector(); + private final MutableVector3 mutable = new MutableVector3(); @Override public boolean test(BlockVector3 vector) { if (solid.test(vector)) { @@ -97,11 +95,11 @@ public class ImageBrush implements Brush { int dy = vector.getBlockY() - cy; int dz = vector.getBlockZ() - cz; - Vector3 pos1 = transform.apply(mutable.setComponents(dx - 0.5, dy - 0.5, dz - 0.5).toVector3()); + Vector3 pos1 = transform.apply(mutable.setComponents(dx - 0.5, dy - 0.5, dz - 0.5)); int x1 = (int) (pos1.getX() * scale + centerX); int z1 = (int) (pos1.getZ() * scale + centerZ); - Vector3 pos2 = transform.apply(mutable.setComponents(dx + 0.5, dy + 0.5, dz + 0.5).toVector3()); + Vector3 pos2 = transform.apply(mutable.setComponents(dx + 0.5, dy + 0.5, dz + 0.5)); int x2 = (int) (pos2.getX() * scale + centerX); int z2 = (int) (pos2.getZ() * scale + centerZ); if (x2 < x1) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java index c2fd28bae..785ab43af 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java @@ -53,9 +53,9 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool { int range = this.range > -1 ? getRange() : MAX_RANGE; if (adjacent) { Location face = player.getBlockTraceFace(range, true); - return face.toVector().add(face.getDirection()); + return face.add(face.getDirection()); } else { - return player.getBlockTrace(getRange(), true).toVector(); + return player.getBlockTrace(getRange(), true); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java index 31e41cb2c..fccf2502c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java @@ -7,7 +7,6 @@ import com.boydti.fawe.object.mask.RadiusMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.command.tool.brush.Brush; -import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.SolidBlockMask; @@ -16,8 +15,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.BreadthFirstSearch; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; @@ -27,7 +25,7 @@ public class LayerBrush implements Brush { private final BlockStateHolder[] layers; private RecursiveVisitor visitor; - private MutableBlockVector mutable = new MutableBlockVector(); + private MutableBlockVector3 mutable = new MutableBlockVector3(); public LayerBrush(BlockStateHolder[] layers) { this.layers = layers; @@ -53,9 +51,9 @@ public class LayerBrush implements Brush { int previous2 = layers[depth - 2].getInternalId(); for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) { mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ()); - if (visitor.isVisited(mutable.toBlockVector3()) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) { + if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) { mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2); - if (visitor.isVisited(mutable.toBlockVector3()) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) { + if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) { found = true; break; } else { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java index e2f9560ac..6b4fb75c9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java @@ -10,10 +10,10 @@ import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.BreadthFirstSearch; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; public class ShatterBrush extends ScatterBrush { - private final MutableBlockVector mutable = new MutableBlockVector(); + private final MutableBlockVector3 mutable = new MutableBlockVector3(); public ShatterBrush(int count) { super(count, 1); @@ -76,8 +76,8 @@ public class ShatterBrush extends ScatterBrush { int dz = position.getBlockZ() - z2; int dSqr = (dx * dx) + (dy * dy) + (dz * dz); if (dSqr <= radius2) { - MutableBlockVector v = mutable.setComponents(x2, y2, z2); - BlockVector3 bv = v.toBlockVector3(); + MutableBlockVector3 v = mutable.setComponents(x2, y2, z2); + BlockVector3 bv = v; if (surfaceTest.test(bv) && finalMask.test(bv)) { // (collision) If it's visited and part of another frontier, set the block if (!placed.add(x2, y2, z2)) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java index 685725ac3..c4f7d817d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java @@ -17,7 +17,7 @@ import com.sk89q.worldedit.function.mask.MaskIntersection; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.interpolation.Node; import java.util.ArrayList; @@ -151,13 +151,13 @@ public class SplineBrush implements Brush, ResettableTool { } private Vector3 getCentroid(Collection points) { - MutableVector sum = new MutableVector(); + MutableVector3 sum = new MutableVector3(); for (BlockVector3 p : points) { 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()).toVector3(); + return sum.multiply(1.0 / points.size()); } private BlockVector3 normal(Collection points, BlockVector3 centroid) { @@ -179,7 +179,7 @@ public class SplineBrush implements Brush, ResettableTool { double yz = 0.0; double zz = 0.0; - MutableVector r = new MutableVector(); + MutableVector3 r = new MutableVector3(); for (BlockVector3 p : points) { r.mutX((p.getX() - centroid.getX())); r.mutY((p.getY() - centroid.getY())); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java index e3220fe89..fbd2b5158 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java @@ -15,8 +15,7 @@ import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.util.Location; @@ -54,7 +53,7 @@ public class StencilBrush extends HeightBrush { Player player = editSession.getPlayer().getPlayer(); -// BlockVector3 pos = player.getLocation().toVector(); +// BlockVector3 pos = player.getLocation(); @@ -65,7 +64,7 @@ public class StencilBrush extends HeightBrush { RecursiveVisitor visitor = new RecursiveVisitor(new Mask() { - private final MutableVector mutable = new MutableVector(); + private final MutableVector3 mutable = new MutableVector3(); @Override public boolean test(BlockVector3 vector) { if (solid.test(vector)) { @@ -73,7 +72,7 @@ public class StencilBrush extends HeightBrush { int dy = vector.getBlockY() - cy; int dz = vector.getBlockZ() - cz; - Vector3 srcPos = transform.apply(mutable.setComponents(dx, dy, dz).toVector3()); + Vector3 srcPos = transform.apply(mutable.setComponents(dx, dy, dz)); dx = MathMan.roundInt(srcPos.getX()); dz = MathMan.roundInt(srcPos.getZ()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java index 6cac08257..d3b9eb4d8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java @@ -8,7 +8,7 @@ import com.sk89q.worldedit.*; import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation; import com.sk89q.worldedit.math.interpolation.Node; @@ -60,7 +60,7 @@ public class SurfaceSpline implements Brush { tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, 0, maxY); if (tipy == -1) continue; if (radius == 0) { - BlockVector3 set = MutableBlockVector.get(tipx, tipy, tipz).toBlockVector3(); + BlockVector3 set = MutableBlockVector3.get(tipx, tipy, tipz); try { pattern.apply(editSession, set, set); } catch (WorldEditException e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java index a20256397..0e07d6eb6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java @@ -4,7 +4,6 @@ import com.boydti.fawe.object.PseudoRandom; import com.boydti.fawe.util.MainUtil; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.convolution.GaussianKernel; @@ -31,7 +30,7 @@ public interface HeightMap { int iterations = 1; Location min = new Location(session.getWorld(), pos.subtract(size, maxY, size).toVector3()); BlockVector3 max = pos.add(size, maxY, size); - Region region = new CuboidRegion(session.getWorld(), min.toVector().toBlockPoint(), max); + Region region = new CuboidRegion(session.getWorld(), min.toBlockPoint(), max); com.sk89q.worldedit.math.convolution.HeightMap heightMap = new com.sk89q.worldedit.math.convolution.HeightMap(session, region, data[0], layers); if (smooth) { try { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java index 29b8c66de..eff992937 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java @@ -1,16 +1,16 @@ package com.boydti.fawe.object.brush.heightmap; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.transform.AffineTransform; public class RotatableHeightMap extends AbstractDelegateHeightMap { private AffineTransform transform; - private MutableVector mutable; + private MutableVector3 mutable; public RotatableHeightMap(HeightMap parent) { super(parent); - mutable = new MutableVector(); + mutable = new MutableVector3(); this.transform = new AffineTransform(); } @@ -22,7 +22,7 @@ public class RotatableHeightMap extends AbstractDelegateHeightMap { public double getHeight(int x, int z) { mutable.mutX(x); mutable.mutZ(z); - BlockVector3 pos = transform.apply(mutable.setComponents(x, 0, z).toVector3()).toBlockPoint(); + BlockVector3 pos = transform.apply(mutable.setComponents(x, 0, z)).toBlockPoint(); return super.getHeight(pos.getBlockX(), pos.getBlockZ()); } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java index 3667aee37..68c200f8e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java @@ -3,10 +3,9 @@ package com.boydti.fawe.object.brush.heightmap; import com.boydti.fawe.object.IntegerPair; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.awt.image.BufferedImage; @@ -77,10 +76,10 @@ public class ScalableHeightMap implements com.boydti.fawe.object.brush.heightmap int xx = pos.getBlockX(); int zz = pos.getBlockZ(); int highestY = minY; - MutableBlockVector bv = new MutableBlockVector(pos); + MutableBlockVector3 bv = new MutableBlockVector3(pos); for (int y = minY; y <= maxY; y++) { bv.mutY(y); - BlockStateHolder block = clipboard.getBlock(bv.toBlockVector3()); + BlockStateHolder block = clipboard.getBlock(bv); if (!block.getBlockType().getMaterial().isAir()) { highestY = y + 1; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/SweepBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/SweepBrush.java index d9825241b..707925c5e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/SweepBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/SweepBrush.java @@ -13,7 +13,7 @@ import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.interpolation.Interpolation; import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation; @@ -95,10 +95,10 @@ public class SweepBrush implements Brush, ResettableTool { double blockDistance = 1d / splineLength; double step = blockDistance / quality; double accumulation = 0; - MutableVector last = new MutableVector(0, 0, 0); + MutableVector3 last = new MutableVector3(0, 0, 0); for (double pos = 0D; pos <= 1D; pos += step) { Vector3 gradient = interpol.get1stDerivative(pos); - if (last == null) last = new MutableVector(interpol.get1stDerivative(pos)); + if (last == null) last = new MutableVector3(interpol.get1stDerivative(pos)); double dist = MathMan.sqrtApprox(last.distanceSq(gradient)); last.mutX(gradient.getX()); last.mutY(gradient.getY()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java index 7df002287..f2a0cde4e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java @@ -3,12 +3,12 @@ package com.boydti.fawe.object.change; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.change.Change; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.biome.BaseBiome; public class MutableBiomeChange implements Change { - private MutableBlockVector2D mutable = new MutableBlockVector2D(); + private MutableBlockVector2 mutable = new MutableBlockVector2(); private BaseBiome from; private BaseBiome to; @@ -25,11 +25,11 @@ public class MutableBiomeChange implements Change { @Override public void undo(UndoContext context) throws WorldEditException { - context.getExtent().setBiome(mutable.toBlockVector2(), from); + context.getExtent().setBiome(mutable, from); } @Override public void redo(UndoContext context) throws WorldEditException { - context.getExtent().setBiome(mutable.toBlockVector2(), to); + context.getExtent().setBiome(mutable, to); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java index 9f174663f..43a59a2e6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java @@ -1,21 +1,19 @@ package com.boydti.fawe.object.clipboard; import com.boydti.fawe.util.ReflectionUtils; -import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector3; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.biome.BaseBiome; @@ -29,7 +27,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { public final int mx, my, mz; private final boolean hasBiomes; private final boolean hasEntities; - private MutableBlockVector2D mutableBlockVector2D = new MutableBlockVector2D(); + private MutableBlockVector2 MutableBlockVector2 = new MutableBlockVector2(); public final Extent extent; public WorldCopyClipboard(Extent editSession, Region region) { @@ -58,7 +56,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { @Override public BaseBiome getBiome(int x, int z) { - return extent.getBiome(mutableBlockVector2D.setComponents(mx + x, mz + z).toBlockVector2()); + return extent.getBiome(MutableBlockVector2.setComponents(mx + x, mz + z)); } @Override @@ -76,7 +74,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { public void forEach(BlockReader task, boolean air) { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - MutableBlockVector pos = new MutableBlockVector(); + MutableBlockVector3 pos = new MutableBlockVector3(); if (region instanceof CuboidRegion) { if (air) { ((CuboidRegion) region).setUseOldIterator(true); @@ -137,9 +135,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { pos.mutX(x); int xx = pos.getBlockX() - mx; - if (region.contains(pos.toBlockVector3())) { + if (region.contains(pos)) { // BlockState block = getBlockAbs(x, y, z); - BaseBlock block = extent.getFullBlock(pos.toBlockVector3()); + BaseBlock block = extent.getFullBlock(pos); if (!air && block.getBlockType().getMaterial().isAir()) { continue; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java index be4dc649a..a16f43a9d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java @@ -2,7 +2,7 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @@ -43,14 +43,14 @@ public class BlockVectorSet extends AbstractCollection implements int newSize = count + size; if (newSize > index) { int localIndex = index - count; - MutableBlockVector pos = new MutableBlockVector(set.getIndex(localIndex)); + MutableBlockVector3 pos = new MutableBlockVector3(set.getIndex(localIndex)); if (pos != null) { int pair = entry.getIntKey(); int cx = MathMan.unpairX(pair); int cz = MathMan.unpairY(pair); pos.mutX((cx << 11) + pos.getBlockX()); pos.mutZ((cz << 11) + pos.getBlockZ()); - return pos.toBlockVector3(); + return pos; } } count += newSize; @@ -92,7 +92,7 @@ public class BlockVectorSet extends AbstractCollection implements return new Iterator() { Int2ObjectMap.Entry entry = entries.next(); Iterator entryIter = entry.getValue().iterator(); - MutableBlockVector mutable = new MutableBlockVector(); + MutableBlockVector3 mutable = new MutableBlockVector3(); @Override public void remove() { @@ -117,7 +117,7 @@ public class BlockVectorSet extends AbstractCollection implements int pair = entry.getIntKey(); int cx = MathMan.unpairX(pair); int cz = MathMan.unpairY(pair); - return mutable.setComponents((cx << 11) + localPos.getBlockX(), localPos.getBlockY(), (cz << 11) + localPos.getBlockZ()).toBlockVector3(); + return mutable.setComponents((cx << 11) + localPos.getBlockX(), localPos.getBlockY(), (cz << 11) + localPos.getBlockZ()); } }; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVector2DSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVector2DSet.java index afe99f1c7..47b2f9749 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVector2DSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVector2DSet.java @@ -2,7 +2,7 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; import java.util.Collection; import java.util.Iterator; @@ -15,7 +15,7 @@ import java.util.Set; */ public class LocalBlockVector2DSet implements Set { private final SparseBitSet set; - private final MutableBlockVector2D mutable = new MutableBlockVector2D(); + private final MutableBlockVector2 mutable = new MutableBlockVector2(); public LocalBlockVector2DSet() { this.set = new SparseBitSet(); @@ -102,7 +102,7 @@ public class LocalBlockVector2DSet implements Set { if (index != -1) { int x = MathMan.unpairSearchCoordsX(index); int y = MathMan.unpairSearchCoordsY(index); - return mutable.setComponents(x, y).toBlockVector2(); + return mutable.setComponents(x, y); } return null; } @@ -131,7 +131,7 @@ public class LocalBlockVector2DSet implements Set { mutable.setComponents(x, y); previous = index; index = set.nextSetBit(index + 1); - return mutable.toBlockVector2(); + return mutable; } return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java index 12b03cee3..863de2781 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java @@ -2,7 +2,7 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import java.util.Collection; import java.util.Iterator; @@ -117,7 +117,7 @@ public class LocalBlockVectorSet implements Set { int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); int y = b1; int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); - return MutableBlockVector.get(x, y, z).toBlockVector3(); + return MutableBlockVector3.get(x, y, z); } return null; } @@ -127,7 +127,7 @@ public class LocalBlockVectorSet implements Set { return new Iterator() { int index = set.nextSetBit(0); int previous = -1; - MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); + MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); @Override public void remove() { @@ -151,7 +151,7 @@ public class LocalBlockVectorSet implements Set { mutable.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21)); previous = index; index = set.nextSetBit(index + 1); - return mutable.toBlockVector3(); + return mutable; } return null; } @@ -280,7 +280,7 @@ public class LocalBlockVectorSet implements Set { boolean result = false; int size = size(); int index = -1; - MutableBlockVector mVec = MutableBlockVector.get(0, 0, 0); + MutableBlockVector3 mVec = MutableBlockVector3.get(0, 0, 0); for (int i = 0; i < size; i++) { index = set.nextSetBit(index + 1); int b1 = (index & 0xFF); @@ -310,7 +310,7 @@ public class LocalBlockVectorSet implements Set { public void forEach(BlockVectorSetVisitor visitor) { int size = size(); int index = -1; - BlockVector3 mVec = MutableBlockVector.get(0, 0, 0).toBlockVector3(); + BlockVector3 mVec = MutableBlockVector3.get(0, 0, 0); for (int i = 0; i < size; i++) { index = set.nextSetBit(index + 1); int b1 = (index & 0xFF); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java index beab0ec14..268bdf211 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java @@ -7,14 +7,13 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.biome.BaseBiome; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; public class BlockTranslateExtent extends AbstractDelegateExtent { private final int dx, dy, dz; - private MutableBlockVector mutable = new MutableBlockVector(); + private MutableBlockVector3 mutable = new MutableBlockVector3(); public BlockTranslateExtent(Extent extent, int dx, int dy, int dz) { super(extent); @@ -28,7 +27,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent { mutable.mutX((location.getX() + dx)); mutable.mutY((location.getY() + dy)); mutable.mutZ((location.getZ() + dz)); - return getExtent().setBlock(mutable.toBlockVector3(), block); + return getExtent().setBlock(mutable, block); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java index c09183376..c8d05b9d7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java @@ -1,17 +1,16 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BlockStateHolder; public class OffsetExtent extends ResettableExtent { private final int dx, dy, dz; - private transient MutableBlockVector2D mutable = new MutableBlockVector2D(); + private transient MutableBlockVector2 mutable = new MutableBlockVector2(); public OffsetExtent(Extent parent, int dx, int dy, int dz) { super(parent); @@ -22,7 +21,7 @@ public class OffsetExtent extends ResettableExtent { @Override public boolean setBiome(BlockVector2 position, BaseBiome biome) { - return getExtent().setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz).toBlockVector2(), biome); + return getExtent().setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz), biome); } @Override @@ -42,7 +41,7 @@ public class OffsetExtent extends ResettableExtent { @Override public ResettableExtent setExtent(Extent extent) { - mutable = new MutableBlockVector2D(); + mutable = new MutableBlockVector2(); return super.setExtent(extent); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java index e2f311fe2..93616d458 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java @@ -6,16 +6,15 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.math.MutableVector; -import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.math.MutableBlockVector3; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BlockStateHolder; public class PositionTransformExtent extends ResettableExtent { - private transient MutableBlockVector mutable = new MutableBlockVector(); + private transient MutableBlockVector3 mutable = new MutableBlockVector3(); private transient BlockVector3 min; private Transform transform; @@ -26,7 +25,7 @@ public class PositionTransformExtent extends ResettableExtent { @Override public ResettableExtent setExtent(Extent extent) { - mutable = new MutableBlockVector(); + mutable = new MutableBlockVector3(); min = null; return super.setExtent(extent); } @@ -42,7 +41,7 @@ public class PositionTransformExtent extends ResettableExtent { mutable.mutX(((pos.getX() - min.getX()))); mutable.mutY(((pos.getY() - min.getY()))); mutable.mutZ(((pos.getZ() - min.getZ()))); - MutableVector tmp = new MutableVector(transform.apply(mutable.toVector3())); + MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3())); BlockVector3 result = min.add(tmp.toBlockPoint()); return result; } @@ -72,7 +71,7 @@ public class PositionTransformExtent extends ResettableExtent { mutable.mutX(position.getBlockX()); mutable.mutZ(position.getBlockZ()); mutable.mutY(0); - return super.getBiome(getPos(mutable.toBlockVector3()).toBlockVector2()); + return super.getBiome(getPos(mutable).toBlockVector2()); } @Override @@ -91,7 +90,7 @@ public class PositionTransformExtent extends ResettableExtent { mutable.mutX(position.getBlockX()); mutable.mutZ(position.getBlockZ()); mutable.mutY(0); - return super.setBiome(getPos(mutable.toBlockVector3()).toBlockVector2(), biome); + return super.setBiome(getPos(mutable).toBlockVector2(), biome); } public void setTransform(Transform transform) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java index 518bba198..b57b73acd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java @@ -2,11 +2,10 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -14,7 +13,7 @@ import java.util.SplittableRandom; public class RandomOffsetTransform extends ResettableExtent { private transient SplittableRandom random; - private transient MutableBlockVector2D mutable = new MutableBlockVector2D(); + private transient MutableBlockVector2 mutable = new MutableBlockVector2(); private final int dx, dy, dz; @@ -30,7 +29,7 @@ public class RandomOffsetTransform extends ResettableExtent { public boolean setBiome(BlockVector2 pos, BaseBiome biome) { int x = pos.getBlockX() + random.nextInt(1 + (dx << 1)) - dx; int z = pos.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz; - return getExtent().setBiome(mutable.setComponents(x, z).toBlockVector2(), biome); + return getExtent().setBiome(mutable.setComponents(x, z), biome); } @Override @@ -52,7 +51,7 @@ public class RandomOffsetTransform extends ResettableExtent { @Override public ResettableExtent setExtent(Extent extent) { random = new SplittableRandom(); - mutable = new MutableBlockVector2D(); + mutable = new MutableBlockVector2(); return super.setExtent(extent); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java index 9e5eb2179..3cd8ec8a7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java @@ -2,13 +2,12 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -16,7 +15,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import javax.annotation.Nullable; public class ScaleTransform extends ResettableExtent { - private transient MutableBlockVector mutable = new MutableBlockVector(); + private transient MutableBlockVector3 mutable = new MutableBlockVector3(); private transient int maxy; private transient BlockVector3 min; @@ -35,7 +34,7 @@ public class ScaleTransform extends ResettableExtent { public ResettableExtent setExtent(Extent extent) { min = null; maxy = extent.getMaximumPoint().getBlockY(); - mutable = new MutableBlockVector(); + mutable = new MutableBlockVector3(); return super.setExtent(extent); } @@ -46,7 +45,7 @@ public class ScaleTransform extends ResettableExtent { 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.toBlockVector3(); + return mutable; } private BlockVector3 getPos(int x, int y, int z) { @@ -56,14 +55,14 @@ public class ScaleTransform extends ResettableExtent { 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.toBlockVector3(); + return mutable; } @Override public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { boolean result = false; - MutableBlockVector pos = new MutableBlockVector(getPos(location)); + MutableBlockVector3 pos = new MutableBlockVector3(getPos(location)); double sx = pos.getX(); double sy = pos.getY(); double sz = pos.getZ(); @@ -73,7 +72,7 @@ public class ScaleTransform extends ResettableExtent { 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.toBlockVector3(), block); + result |= super.setBlock(pos, block); } } } @@ -83,7 +82,7 @@ public class ScaleTransform extends ResettableExtent { @Override public boolean setBiome(BlockVector2 position, BaseBiome biome) { boolean result = false; - MutableBlockVector pos = new MutableBlockVector(getPos(position.getBlockX(), 0, position.getBlockZ())); + MutableBlockVector3 pos = new MutableBlockVector3(getPos(position.getBlockX(), 0, position.getBlockZ())); double sx = pos.getX(); double sz = pos.getZ(); double ex = pos.getX() + dx; @@ -99,7 +98,7 @@ public class ScaleTransform extends ResettableExtent { @Override public boolean setBlock(int x1, int y1, int z1, BlockStateHolder block) throws WorldEditException { boolean result = false; - MutableBlockVector pos = new MutableBlockVector(getPos(x1, y1, z1)); + MutableBlockVector3 pos = new MutableBlockVector3(getPos(x1, y1, z1)); double sx = pos.getX(); double sy = pos.getY(); double sz = pos.getZ(); @@ -109,7 +108,7 @@ public class ScaleTransform extends ResettableExtent { 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.toBlockVector3(), block); + result |= super.setBlock(pos, block); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java index cd5b5ae5a..d706294f0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java @@ -2,11 +2,10 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -14,7 +13,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class SourceMaskExtent extends TemporalExtent { private Mask mask; - private MutableBlockVector mutable = new MutableBlockVector(); + private MutableBlockVector3 mutable = new MutableBlockVector3(); /** @@ -54,6 +53,6 @@ public class SourceMaskExtent extends TemporalExtent { mutable.mutX(x); mutable.mutY(y); mutable.mutZ(z); - return mask.test(mutable.toBlockVector3()) && super.setBlock(x, y, z, block); + return mask.test(mutable) && super.setBlock(x, y, z, block); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java index 3b5d50902..128577f74 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java @@ -7,16 +7,14 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.MutableBlockVector3; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.world.biome.BaseBiome; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.registry.BlockRegistry; public class TransformExtent extends BlockTransformExtent { - private final MutableBlockVector mutable = new MutableBlockVector(); + private final MutableBlockVector3 mutable = new MutableBlockVector3(); private BlockVector3 min; private int maxy; @@ -58,7 +56,7 @@ public class TransformExtent extends BlockTransformExtent { mutable.mutX(((pos.getX() - min.getX()))); mutable.mutY(((pos.getY() - min.getY()))); mutable.mutZ(((pos.getZ() - min.getZ()))); - MutableVector tmp = new MutableVector(getTransform().apply(mutable.toVector3())); + MutableVector3 tmp = new MutableVector3(getTransform().apply(mutable.toVector3())); tmp.mutX((tmp.getX() + min.getX())); tmp.mutY((tmp.getY() + min.getY())); tmp.mutZ((tmp.getZ() + min.getZ())); @@ -72,7 +70,7 @@ public class TransformExtent extends BlockTransformExtent { mutable.mutX(((x - min.getX()))); mutable.mutY(((y - min.getY()))); mutable.mutZ(((z - min.getZ()))); - MutableVector tmp = new MutableVector(getTransform().apply(mutable.toVector3())); + MutableVector3 tmp = new MutableVector3(getTransform().apply(mutable.toVector3())); tmp.mutX((tmp.getX() + min.getX())); tmp.mutY((tmp.getY() + min.getY())); tmp.mutZ((tmp.getZ() + min.getZ())); @@ -104,7 +102,7 @@ public class TransformExtent extends BlockTransformExtent { mutable.mutX(position.getBlockX()); mutable.mutZ(position.getBlockZ()); mutable.mutY(0); - return super.getBiome(getPos(mutable.toBlockVector3()).toBlockVector2()); + return super.getBiome(getPos(mutable).toBlockVector2()); } @Override @@ -123,6 +121,6 @@ public class TransformExtent extends BlockTransformExtent { mutable.mutX(position.getBlockX()); mutable.mutZ(position.getBlockZ()); mutable.mutY(0); - return super.setBiome(getPos(mutable.toBlockVector3()).toBlockVector2(), biome); + return super.setBiome(getPos(mutable).toBlockVector2(), biome); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/function/SurfaceRegionFunction.java b/worldedit-core/src/main/java/com/boydti/fawe/object/function/SurfaceRegionFunction.java index c2bfc4825..7b6aea4be 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/function/SurfaceRegionFunction.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/function/SurfaceRegionFunction.java @@ -5,7 +5,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; public class SurfaceRegionFunction implements FlatRegionFunction { private final Extent extent; @@ -13,7 +13,7 @@ public class SurfaceRegionFunction implements FlatRegionFunction { private final int minY; private final int maxY; private int lastY; - private MutableBlockVector mutable = new MutableBlockVector(); + private MutableBlockVector3 mutable = new MutableBlockVector3(); public SurfaceRegionFunction(Extent extent, RegionFunction function, int minY, int maxY) { this.extent = extent; @@ -30,7 +30,7 @@ public class SurfaceRegionFunction implements FlatRegionFunction { int layer = extent.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY, false); if (layer != -1) { lastY = layer; - return function.apply(mutable.setComponents(x, layer, z).toBlockVector3()); + return function.apply(mutable.setComponents(x, layer, z)); } return false; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/BiomeCopy.java b/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/BiomeCopy.java index 582ce0e19..87f533798 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/BiomeCopy.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/BiomeCopy.java @@ -5,17 +5,17 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; public class BiomeCopy implements RegionFunction { protected final Extent source; protected final Extent destination; - private final MutableBlockVector2D mPos2d; + private final MutableBlockVector2 mPos2d; public BiomeCopy(Extent source, Extent destination) { this.source = source; this.destination = destination; - this.mPos2d = new MutableBlockVector2D(); + this.mPos2d = new MutableBlockVector2(); this.mPos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE); } @@ -25,7 +25,7 @@ public class BiomeCopy implements RegionFunction { int z = position.getBlockZ(); if (x != mPos2d.getBlockX() || z != mPos2d.getBlockZ()) { mPos2d.setComponents(x, z); - BlockVector2 bv = mPos2d.toBlockVector2(); + BlockVector2 bv = mPos2d; return destination.setBiome( bv, source.getBiome(bv)); } return false; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java index 76ae10ad6..b5f384f88 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java @@ -3,7 +3,7 @@ package com.boydti.fawe.object.mask; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; /** * Just an optimized version of the Adjacent Mask for single adjacency @@ -11,16 +11,16 @@ import com.sk89q.worldedit.math.MutableBlockVector; public class AdjacentAnyMask extends AbstractMask implements ResettableMask { private final CachedMask mask; - private transient MutableBlockVector mutable = new MutableBlockVector(); + private transient MutableBlockVector3 mutable = new MutableBlockVector3(); public AdjacentAnyMask(Mask mask) { this.mask = CachedMask.cache(mask); - mutable = new MutableBlockVector(); + mutable = new MutableBlockVector3(); } @Override public void reset() { - mutable = new MutableBlockVector(); + mutable = new MutableBlockVector3(); } public CachedMask getParentMask() { @@ -75,6 +75,6 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask { if (y > 0 && mask.test(x, y - 1, z)) { mutable.setComponents(0, -1, 0); } - return (mutable.getX() == 0 && mutable.getY() == 0 && mutable.getZ() == 0) ? null : mutable.toBlockVector3(); + return (mutable.getX() == 0 && mutable.getY() == 0 && mutable.getZ() == 0) ? null : mutable; } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java index 4607bbb66..9fa0259b3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java @@ -3,18 +3,18 @@ package com.boydti.fawe.object.mask; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; public class AdjacentMask extends AbstractMask { private final int min, max; private final Mask mask; - private MutableBlockVector v; + private MutableBlockVector3 v; public AdjacentMask(Mask mask, int requiredMin, int requiredMax) { this.mask = mask; this.min = requiredMin; this.max = requiredMax; - this.v = new MutableBlockVector(); + this.v = new MutableBlockVector3(); } @Override @@ -25,34 +25,34 @@ public class AdjacentMask extends AbstractMask { double y = bv.getY(); double z = bv.getZ(); v.mutX(x + 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x - 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x); v.mutY(y + 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutY(y); return true; } v.mutY(y - 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutY(y); return true; } v.mutY(y); v.mutZ(z + 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } v.mutZ(z - 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java index adc768cd5..b1f00b91c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java @@ -4,7 +4,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import java.util.Arrays; import javax.annotation.Nullable; @@ -21,7 +21,7 @@ public class AngleMask extends SolidBlockMask implements ResettableMask { protected final int maxY; protected final int distance; - protected transient MutableBlockVector mutable = new MutableBlockVector(); + protected transient MutableBlockVector3 mutable = new MutableBlockVector3(); public AngleMask(Extent extent, double min, double max, boolean overlay, int distance) { super(extent); @@ -36,7 +36,7 @@ public class AngleMask extends SolidBlockMask implements ResettableMask { @Override public void reset() { - mutable = new MutableBlockVector(); + mutable = new MutableBlockVector3(); cacheBotX = Integer.MIN_VALUE; cacheBotZ = Integer.MIN_VALUE; lastX = Integer.MIN_VALUE; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/BiomeMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/BiomeMask.java index 13d4444d4..71aac1181 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/BiomeMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/BiomeMask.java @@ -4,12 +4,12 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.biome.BaseBiome; public class BiomeMask extends AbstractExtentMask implements ResettableMask { private final BaseBiome biome; - private transient MutableBlockVector2D mutable = new MutableBlockVector2D(); + private transient MutableBlockVector2 mutable = new MutableBlockVector2(); public BiomeMask(Extent extent, BaseBiome biome) { super(extent); @@ -18,12 +18,12 @@ public class BiomeMask extends AbstractExtentMask implements ResettableMask { @Override public void reset() { - mutable = new MutableBlockVector2D(); + mutable = new MutableBlockVector2(); } @Override public boolean test(BlockVector3 vector) { - BlockVector2 pos = mutable.setComponents(vector.getBlockX(), vector.getBlockZ()).toBlockVector2(); + BlockVector2 pos = mutable.setComponents(vector.getBlockX(), vector.getBlockZ()); return getExtent().getBiome(pos).getId() == biome.getId(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java index 0e08d7ee0..9c2160604 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java @@ -4,11 +4,11 @@ import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.function.mask.AbstractDelegateMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; public class CachedMask extends AbstractDelegateMask implements ResettableMask { - private transient MutableBlockVector mutable = new MutableBlockVector(); + private transient MutableBlockVector3 mutable = new MutableBlockVector3(); private transient LocalBlockVectorSet cache_checked = new LocalBlockVectorSet(); private transient LocalBlockVectorSet cache_results = new LocalBlockVectorSet(); @@ -27,7 +27,7 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask { @Override public void reset() { - mutable = new MutableBlockVector(); + mutable = new MutableBlockVector3(); cache_checked = new LocalBlockVectorSet(); cache_results = new LocalBlockVectorSet(); resetCache(); @@ -51,11 +51,11 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask { if (!check) { return cache_results.contains(x, y, z); } - boolean result = getMask().test(mutable.setComponents(x, y, z).toBlockVector3()); + boolean result = getMask().test(mutable.setComponents(x, y, z)); if (result) cache_results.add(x, y, z); return result; } catch (UnsupportedOperationException ignore) { - boolean result = getMask().test(mutable.setComponents(x, y, z).toBlockVector3()); + boolean result = getMask().test(mutable.setComponents(x, y, z)); if (y < 0 || y > 255) return result; resetCache(); cache_checked.setOffset(x, z); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/MaskedTargetBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/MaskedTargetBlock.java index ed9210eca..8735343fd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/MaskedTargetBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/MaskedTargetBlock.java @@ -21,7 +21,7 @@ public class MaskedTargetBlock extends TargetBlock { Location lastBlock = null; while (getNextBlock() != null) { Location current = getCurrentBlock(); - if (!mask.test(current.toVector().toBlockPoint())) { + if (!mask.test(current.toBlockPoint())) { if (searchForLastBlock) { lastBlock = current; if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java index 824ca358d..04baace03 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java @@ -4,7 +4,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import javax.annotation.Nullable; @@ -14,7 +14,7 @@ import javax.annotation.Nullable; public class SolidPlaneMask extends SolidBlockMask implements ResettableMask { private transient int mode = -1; - private transient MutableBlockVector mutable = new MutableBlockVector(); + private transient MutableBlockVector3 mutable = new MutableBlockVector3(); private int originX = Integer.MAX_VALUE, originY = Integer.MAX_VALUE, originZ = Integer.MAX_VALUE; @@ -34,13 +34,13 @@ public class SolidPlaneMask extends SolidBlockMask implements ResettableMask { originZ = vector.getBlockZ(); mode = 0; Extent extent = getExtent(); - if (!extent.getBlockType(mutable.setComponents(originX - 1, originY, originZ).toBlockVector3()).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX + 1, originY, originZ).toBlockVector3()).getMaterial().isAir()) { + if (!extent.getBlockType(mutable.setComponents(originX - 1, originY, originZ)).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX + 1, originY, originZ)).getMaterial().isAir()) { mode &= 1; } - if (!extent.getBlockType(mutable.setComponents(originX, originY, originZ - 1).toBlockVector3()).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY, originZ + 1).toBlockVector3()).getMaterial().isAir()) { + if (!extent.getBlockType(mutable.setComponents(originX, originY, originZ - 1)).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY, originZ + 1)).getMaterial().isAir()) { mode &= 4; } - if (!extent.getBlockType(mutable.setComponents(originX, originY - 1, originZ + 1).toBlockVector3()).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY + 1, originZ + 1).toBlockVector3()).getMaterial().isAir()) { + if (!extent.getBlockType(mutable.setComponents(originX, originY - 1, originZ + 1)).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY + 1, originZ + 1)).getMaterial().isAir()) { mode &= 2; } if (Integer.bitCount(mode) >= 3) { @@ -85,7 +85,7 @@ public class SolidPlaneMask extends SolidBlockMask implements ResettableMask { @Override public void reset() { mode = -1; - mutable = new MutableBlockVector(); + mutable = new MutableBlockVector3(); } @Nullable diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java index 85f3bbce0..7e5d84f03 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java @@ -3,18 +3,18 @@ package com.boydti.fawe.object.mask; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; public class WallMask extends AbstractMask { private final int min, max; private final Mask mask; - private MutableBlockVector v; + private MutableBlockVector3 v; public WallMask(Mask mask, int requiredMin, int requiredMax) { this.mask = mask; this.min = requiredMin; this.max = requiredMax; - this.v = new MutableBlockVector(); + this.v = new MutableBlockVector3(); } @Override @@ -25,23 +25,23 @@ public class WallMask extends AbstractMask { double y = v.getY(); double z = v.getZ(); v.mutX(x + 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x - 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x); v.mutZ(z + 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } v.mutZ(z - 1); - if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { + if (mask.test(v) && ++count == min && max >= 8) { v.mutZ(z); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BiomePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BiomePattern.java index bba2c4f33..f62926afc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BiomePattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BiomePattern.java @@ -5,12 +5,12 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.biome.BaseBiome; import java.io.IOException; public class BiomePattern extends ExistingPattern { - private transient MutableBlockVector2D mutable = new MutableBlockVector2D(); + private transient MutableBlockVector2 mutable = new MutableBlockVector2(); private final BaseBiome biome; public BiomePattern(Extent extent, BaseBiome biome) { @@ -48,6 +48,6 @@ public class BiomePattern extends ExistingPattern { private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); - mutable = new MutableBlockVector2D(); + mutable = new MutableBlockVector2(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java index 43c0923c3..015eb990d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/FullClipboardPattern.java @@ -9,7 +9,7 @@ import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.Region; import java.io.IOException; import java.io.NotSerializableException; @@ -22,7 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class FullClipboardPattern extends AbstractExtentPattern { private final Clipboard clipboard; - private final MutableBlockVector mutable = new MutableBlockVector(); + private final MutableBlockVector3 mutable = new MutableBlockVector3(); /** * Create a new clipboard pattern. diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java index a6ada3742..3accfc1e9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java @@ -7,7 +7,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.io.IOException; @@ -15,7 +15,7 @@ import java.io.IOException; public class NoXPattern extends AbstractPattern { private final Pattern pattern; -// private transient MutableBlockVector mutable = new MutableBlockVector(); +// private transient MutableBlockVector3 mutable = new MutableBlockVector3(); public NoXPattern(Pattern pattern) { this.pattern = pattern; @@ -25,7 +25,7 @@ public class NoXPattern extends AbstractPattern { public BaseBlock apply(BlockVector3 pos) { // mutable.mutY((pos.getY())); // mutable.mutZ((pos.getZ())); -// return pattern.apply(mutable.toBlockVector3()); +// return pattern.apply(mutable); return pattern.apply(pos); } @@ -38,6 +38,6 @@ public class NoXPattern extends AbstractPattern { private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); -// mutable = new MutableBlockVector(); +// mutable = new MutableBlockVector3(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java index fd81a3c07..6c8303cff 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java @@ -7,7 +7,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.io.IOException; @@ -20,7 +20,7 @@ public class NoYPattern extends AbstractPattern { this.pattern = pattern; } -// private transient MutableBlockVector mutable = new MutableBlockVector(); +// private transient MutableBlockVector3 mutable = new MutableBlockVector3(); @Override public BaseBlock apply(BlockVector3 pos) { @@ -38,6 +38,6 @@ public class NoYPattern extends AbstractPattern { private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); -// mutable = new MutableBlockVector(); +// mutable = new MutableBlockVector3(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java index 11b5f3486..2a4e3f362 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java @@ -7,7 +7,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.io.IOException; @@ -20,7 +20,7 @@ public class NoZPattern extends AbstractPattern { this.pattern = pattern; } -// private transient MutableBlockVector mutable = new MutableBlockVector(); +// private transient MutableBlockVector3 mutable = new MutableBlockVector3(); @Override public BaseBlock apply(BlockVector3 pos) { @@ -38,6 +38,6 @@ public class NoZPattern extends AbstractPattern { private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); -// mutable = new MutableBlockVector(); +// mutable = new MutableBlockVector3(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java index 3802922f9..fd34ba1eb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java @@ -7,7 +7,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.io.IOException; @@ -15,7 +15,7 @@ import java.io.IOException; public class OffsetPattern extends AbstractPattern { private final int dx, dy, dz; -// private transient MutableBlockVector mutable = new MutableBlockVector(); +// private transient MutableBlockVector3 mutable = new MutableBlockVector3(); private final Pattern pattern; public OffsetPattern(Pattern pattern, int dx, int dy, int dz) { @@ -45,6 +45,6 @@ public class OffsetPattern extends AbstractPattern { private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); -// mutable = new MutableBlockVector(); +// mutable = new MutableBlockVector3(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java index 5da2c10c8..36c3eb08c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java @@ -9,7 +9,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; @@ -23,7 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class RandomFullClipboardPattern extends AbstractPattern { private final Extent extent; - private final MutableBlockVector mutable = new MutableBlockVector(); + private final MutableBlockVector3 mutable = new MutableBlockVector3(); private final List clipboards; private boolean randomRotate; private boolean randomFlip; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java index 258c424e0..904364739 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java @@ -2,13 +2,11 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.math.MutableBlockVector3; import java.io.IOException; import java.util.SplittableRandom; @@ -18,7 +16,7 @@ public class RandomOffsetPattern extends AbstractPattern { private final Pattern pattern; private transient int dx2, dy2, dz2; - private transient MutableBlockVector mutable = new MutableBlockVector(); + private transient MutableBlockVector3 mutable = new MutableBlockVector3(); private transient SplittableRandom r; public RandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) { @@ -38,7 +36,7 @@ public class RandomOffsetPattern extends AbstractPattern { 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.toBlockVector3()); + return pattern.apply(mutable); } @Override @@ -46,7 +44,7 @@ public class RandomOffsetPattern extends AbstractPattern { mutable.mutX((get.getX() + r.nextInt(dx2) - dx)); mutable.mutY((get.getY() + r.nextInt(dy2) - dy)); mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz)); - return pattern.apply(extent, set, mutable.toBlockVector3()); + return pattern.apply(extent, set, mutable); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { @@ -55,6 +53,6 @@ public class RandomOffsetPattern extends AbstractPattern { this.dy2 = dy * 2 + 1; this.dz2 = dz * 2 + 1; this.r = new SplittableRandom(); - this.mutable = new MutableBlockVector(); + this.mutable = new MutableBlockVector3(); } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java index 4020ecb17..e8f3f56ea 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java @@ -2,13 +2,11 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.math.MutableBlockVector3; import java.io.IOException; @@ -16,7 +14,7 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter private final Pattern pattern; private transient BlockVector3 origin; - private transient MutableBlockVector mutable = new MutableBlockVector(); + private transient MutableBlockVector3 mutable = new MutableBlockVector3(); public RelativePattern(Pattern pattern) { this.pattern = pattern; @@ -30,7 +28,7 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter mutable.mutX((pos.getX() - origin.getX())); mutable.mutY((pos.getY() - origin.getY())); mutable.mutZ((pos.getZ() - origin.getZ())); - return pattern.apply(mutable.toBlockVector3()); + return pattern.apply(mutable); } @Override @@ -41,12 +39,12 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter mutable.mutX((get.getX() - origin.getX())); mutable.mutY((get.getY() - origin.getY())); mutable.mutZ((get.getZ() - origin.getZ())); - return pattern.apply(extent, set, mutable.toBlockVector3()); + return pattern.apply(extent, set, mutable); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); - mutable = new MutableBlockVector(); + mutable = new MutableBlockVector3(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java index d77181e69..3ac516bc7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java @@ -1,15 +1,13 @@ package com.boydti.fawe.object.pattern; -import com.boydti.fawe.FaweCache; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.io.IOException; @@ -20,7 +18,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern { private final Pattern pattern; private transient int dx2, dy2, dz2; - private transient MutableBlockVector mutable; + private transient MutableBlockVector3 mutable; private transient boolean[] solid; private SplittableRandom r; @@ -39,7 +37,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern { this.dz2 = dz * 2 + 1; solid = SolidBlockMask.getTypes(); this.r = new SplittableRandom(); - this.mutable = new MutableBlockVector(); + this.mutable = new MutableBlockVector3(); } @Override @@ -47,7 +45,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern { 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.toBlockVector3()); + BaseBlock block = pattern.apply(mutable); if (solid[block.getInternalBlockTypeId()]) { return block; } else { @@ -60,9 +58,9 @@ public class SolidRandomOffsetPattern extends AbstractPattern { mutable.mutX((get.getX() + r.nextInt(dx2) - dx)); mutable.mutY((get.getY() + r.nextInt(dy2) - dy)); mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz)); - BlockStateHolder block = pattern.apply(mutable.toBlockVector3()); + BlockStateHolder block = pattern.apply(mutable); if (solid[block.getInternalBlockTypeId()]) { - return pattern.apply(extent, set, mutable.toBlockVector3()); + return pattern.apply(extent, set, mutable); } else { return pattern.apply(extent, set, get); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java index 94f9d35fc..92020ef76 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java @@ -5,7 +5,7 @@ import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.BreadthFirstSearch; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.io.IOException; @@ -15,10 +15,10 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { private final Pattern pattern; private int moves; - private transient MutableBlockVector cur; - private transient MutableBlockVector[] buffer; - private transient MutableBlockVector[] allowed; - private transient MutableBlockVector next; + private transient MutableBlockVector3 cur; + private transient MutableBlockVector3[] buffer; + private transient MutableBlockVector3[] allowed; + private transient MutableBlockVector3 next; public SurfaceRandomOffsetPattern(Pattern pattern, int distance) { this.pattern = pattern; @@ -27,12 +27,12 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { } private void init() { - cur = new MutableBlockVector(); - this.buffer = new MutableBlockVector[BreadthFirstSearch.DIAGONAL_DIRECTIONS.length]; + cur = new MutableBlockVector3(); + this.buffer = new MutableBlockVector3[BreadthFirstSearch.DIAGONAL_DIRECTIONS.length]; for (int i = 0; i < buffer.length; i++) { - buffer[i] = new MutableBlockVector(); + buffer[i] = new MutableBlockVector3(); } - allowed = new MutableBlockVector[buffer.length]; + allowed = new MutableBlockVector3[buffer.length]; } @Override @@ -48,21 +48,21 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { next = buffer[i]; BlockVector3 dir = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i]; next.setComponents(cur.getBlockX() + dir.getBlockX(), cur.getBlockY() + dir.getBlockY(), cur.getBlockZ() + dir.getBlockZ()); - if (allowed(next.toBlockVector3())) { + if (allowed(next)) { allowed[index++] = next; } } if (index == 0) { - return cur.toBlockVector3(); + return cur; } next = allowed[ThreadLocalRandom.current().nextInt(index)]; cur.setComponents(next.getBlockX(), next.getBlockY(), next.getBlockZ()); } - return cur.toBlockVector3(); + return cur; } private boolean allowed(BlockVector3 bv) { - MutableBlockVector v = new MutableBlockVector(bv); + MutableBlockVector3 v = new MutableBlockVector3(bv); BlockStateHolder block = pattern.apply(bv); if (!block.getBlockType().getMaterial().isMovementBlocker()) { return false; @@ -71,34 +71,34 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { int y = v.getBlockY(); int z = v.getBlockZ(); v.mutY(y + 1); - if (canPassthrough(v.toBlockVector3())) { + if (canPassthrough(v)) { v.mutY(y); return true; } v.mutY(y - 1); - if (canPassthrough(v.toBlockVector3())) { + if (canPassthrough(v)) { v.mutY(y); return true; } v.mutY(y); v.mutX(x + 1); - if (canPassthrough(v.toBlockVector3())) { + if (canPassthrough(v)) { v.mutX(x); return true; } v.mutX(x - 1); - if (canPassthrough(v.toBlockVector3())) { + if (canPassthrough(v)) { v.mutX(x); return true; } v.mutX(x); v.mutZ(z + 1); - if (canPassthrough(v.toBlockVector3())) { + if (canPassthrough(v)) { v.mutZ(z); return true; } v.mutZ(z - 1); - if (canPassthrough(v.toBlockVector3())) { + if (canPassthrough(v)) { v.mutZ(z); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java index 9d9df1f07..36e8535f8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java @@ -8,7 +8,7 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class FaweQueueDelegateExtent extends DelegateFaweQueue { private final FaweQueue parentQueue; private final Extent parentExtent; -// private final MutableBlockVector2D mutable2d = new MutableBlockVector2D(); +// private final MutableBlockVector2 mutable2d = new MutableBlockVector2(); public FaweQueueDelegateExtent(FaweQueue parentQueue, Extent parentExtent) { super(parentQueue); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java index a05e91ce9..28ec2681b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java @@ -20,8 +20,8 @@ package com.boydti.fawe.object.regions; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.MutableBlockVector3; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.RegionOperationException; @@ -143,8 +143,8 @@ public class PolyhedralRegion extends AbstractRegion { if (minimumPoint == null) { minimumPoint = maximumPoint = vertex; } else { -// minimumPoint = new MutableBlockVector(minimumPoint.getMinimum(vertex)); -// maximumPoint = new MutableBlockVector(maximumPoint.getMaximum(vertex)); +// minimumPoint = new MutableBlockVector3(minimumPoint.getMinimum(vertex)); +// maximumPoint = new MutableBlockVector3(maximumPoint.getMaximum(vertex)); minimumPoint = minimumPoint.getMinimum(vertex); maximumPoint = maximumPoint.getMaximum(vertex); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java index a1f89f488..c91531b8f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java @@ -5,7 +5,7 @@ import com.boydti.fawe.util.TextureUtil; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -68,8 +68,8 @@ public class PNGWriter implements ClipboardWriter { boolean fill = length * 4 < imageSize && width * 4 < imageSize; - MutableBlockVector mutable, mutableTop, mutableRight, mutableLeft; - mutable = mutableTop = mutableRight = mutableLeft = new MutableBlockVector(0, 0, 0); + MutableBlockVector3 mutable, mutableTop, mutableRight, mutableLeft; + mutable = mutableTop = mutableRight = mutableLeft = new MutableBlockVector3(0, 0, 0); // Vector mutableTop = new Vector(0, 0, 0); // Vector mutableRight = new Vector(0, 0, 0); // Vector mutableLeft = new Vector(0, 0, 0); @@ -96,16 +96,16 @@ public class PNGWriter implements ClipboardWriter { double cpy2 = cpy1 + dpyj[zz]; for (int y = y0; y < y0 + height; y++) { mutable.mutY(y); - BlockStateHolder block = clipboard.getBlock(mutable.toBlockVector3()); + BlockStateHolder block = clipboard.getBlock(mutable); if (block.getBlockType().getMaterial().isAir()) { continue; } mutableTop.mutY(y + 1); mutableRight.mutY(y); mutableLeft.mutY(y); - if (!clipboard.getBlock(mutableTop.toBlockVector3()).getBlockType().getMaterial().isAir() && - !clipboard.getBlock(mutableRight.toBlockVector3()).getBlockType().getMaterial().isAir() && - !clipboard.getBlock(mutableLeft.toBlockVector3()).getBlockType().getMaterial().isAir() ) { + if (!clipboard.getBlock(mutableTop).getBlockType().getMaterial().isAir() && + !clipboard.getBlock(mutableRight).getBlockType().getMaterial().isAir() && + !clipboard.getBlock(mutableLeft).getBlockType().getMaterial().isAir() ) { continue; } double cpy = cpy2 - dpxi[y - y0]; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java index 68282c90e..ba50e80b3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java @@ -8,8 +8,6 @@ import com.boydti.fawe.util.MaskTraverser; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; @@ -25,7 +23,7 @@ import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; @@ -211,7 +209,7 @@ public class Schematic { BlockArrayClipboard bac = (BlockArrayClipboard) clipboard; if (copyBiomes) { bac.IMP.forEach(new FaweClipboard.BlockReader() { - MutableBlockVector2D mpos2d = new MutableBlockVector2D(); + MutableBlockVector2 mpos2d = new MutableBlockVector2(); { mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE); } @@ -222,7 +220,7 @@ public class Schematic { int zz = z + relz; if (xx != mpos2d.getBlockX() || zz != mpos2d.getBlockZ()) { mpos2d.setComponents(xx, zz); - extent.setBiome(mpos2d.toBlockVector2(), bac.IMP.getBiome(x, z)); + extent.setBiome(mpos2d, bac.IMP.getBiome(x, z)); } if (!pasteAir && block.getBlockType().getMaterial().isAir()) { return; @@ -247,8 +245,8 @@ public class Schematic { final int rely = to.getBlockY() - origin.getBlockY(); final int relz = to.getBlockZ() - origin.getBlockZ(); RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() { -// MutableBlockVector2D mpos2d_2 = new MutableBlockVector2D(); - MutableBlockVector2D mpos2d = new MutableBlockVector2D(); +// MutableBlockVector2 mpos2d_2 = new MutableBlockVector2(); + MutableBlockVector2 mpos2d = new MutableBlockVector2(); { mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE); } @@ -260,7 +258,7 @@ public class Schematic { if (copyBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) { mpos2d.setComponents(xx, zz); // extent.setBiome(mpos2d, clipboard.getBiome(mpos2d_2.setComponents(mutable.getBlockX(), mutable.getBlockZ()))); - extent.setBiome(mpos2d.toBlockVector2(), clipboard.getBiome(BlockVector2.at(mutable.getBlockX(), mutable.getBlockZ()))); + extent.setBiome(mpos2d, clipboard.getBiome(BlockVector2.at(mutable.getBlockX(), mutable.getBlockZ()))); } if (!pasteAir && block.getBlockType().getMaterial().isAir()) { return false; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java index bdcf2b42c..120327d3f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java @@ -22,7 +22,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.registry.state.AbstractProperty; @@ -168,7 +168,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { } Map structure = FaweCache.asMap("version", 1, "author", owner); // ignored: version / owner - MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); + MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); Int2ObjectArrayMap indexes = new Int2ObjectArrayMap<>(); // Size structure.put("size", Arrays.asList(width, height, length)); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java index c6469ce39..808406b24 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java @@ -27,7 +27,7 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Location; @@ -56,7 +56,7 @@ public class SchemVis extends ImmutableVirtualWorld { private final Long2ObjectOpenHashMap> files; private final Long2ObjectOpenHashMap chunks; // TODO use soft references OR clear chunks outside view distance - private final MutableBlockVector2D lastPos = new MutableBlockVector2D(); + private final MutableBlockVector2 lastPos = new MutableBlockVector2(); private final FawePlayer player; private final Location origin; private final BlockVector2 chunkOffset; @@ -322,10 +322,10 @@ public class SchemVis extends ImmutableVirtualWorld { private BlockVector2 registerAndGetChunkOffset(BlockVector2 schemDimensions, File file) { int chunkX = schemDimensions.getBlockX() >> 4; int chunkZ = schemDimensions.getBlockZ() >> 4; - MutableBlockVector2D pos2 = new MutableBlockVector2D(); - MutableBlockVector2D curPos = lastPos; + MutableBlockVector2 pos2 = new MutableBlockVector2(); + MutableBlockVector2 curPos = lastPos; // Find next free position - while (!isAreaFree(curPos.toBlockVector2(), pos2.setComponents(curPos.getBlockX() + chunkX, curPos.getBlockZ() + chunkZ).toBlockVector2())) { + while (!isAreaFree(curPos, pos2.setComponents(curPos.getBlockX() + chunkX, curPos.getBlockZ() + chunkZ))) { // if (curPos == lastPos && !files.containsKey(MathMan.pairInt(curPos.getBlockX(), curPos.getBlockZ()))) { // curPos = new MutableBlockVector2(); // curPos.setComponents(lastPos.getBlockX(), lastPos.getBlockZ()); @@ -345,7 +345,7 @@ public class SchemVis extends ImmutableVirtualWorld { } } for (int i = 0; i < Math.min(chunkX, chunkZ); i++) curPos.nextPosition(); - return curPos.toBlockVector2(); + return curPos; } private boolean isAreaFree(BlockVector2 chunkPos1, BlockVector2 chunkPos2 /* inclusive */) { @@ -599,7 +599,7 @@ public class SchemVis extends ImmutableVirtualWorld { clear(); chunks.clear(); files.clear(); - player.getPlayer().setPosition(origin.toVector(), origin.getPitch(), origin.getYaw()); + player.getPlayer().setPosition(origin, origin.getPitch(), origin.getYaw()); if (update) { FaweQueue packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java index 82af1c1fc..dd9acaefd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java @@ -7,7 +7,7 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import java.util.ArrayDeque; import java.util.ArrayList; @@ -77,8 +77,8 @@ public abstract class DFSVisitor implements Operation { NodePair current; Node from; Node adjacent; -// MutableBlockVector mutable = new MutableBlockVector(); -// MutableBlockVector mutable2 = new MutableBlockVector(); +// MutableBlockVector3 mutable = new MutableBlockVector3(); +// MutableBlockVector3 mutable2 = new MutableBlockVector3(); int countAdd, countAttempt; IntegerTrio[] dirs = getIntDirections(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java index 8b8fb9ab6..793f18b51 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java @@ -67,20 +67,6 @@ public abstract class TaskManager { * @param runnables */ public void parallel(Collection runnables) { -// if (!Fawe.get().isJava8()) { -// ExecutorCompletionService c = new ExecutorCompletionService(pool); -// for (Runnable run : runnables) { -// c.submit(run, null); -// } -// try { -// for (int i = 0; i < runnables.size(); i++) { -// c.take(); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// return; -// } for (Runnable run : runnables) { pool.submit(run); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index a445423a0..cb04267d4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -136,8 +136,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, private FawePlayer player; private FaweChangeSet changeTask; - private MutableBlockVector mutablebv = new MutableBlockVector(); - private MutableVector mutablev = new MutableVector(); + private MutableBlockVector3 mutablebv = new MutableBlockVector3(); private int changes = 0; private BlockBag blockBag; @@ -1080,7 +1079,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, public boolean setBlock(int x, int y, int z, Pattern pattern) { this.changes++; try { - BlockVector3 bv = mutablebv.setComponents(x, y, z).toBlockVector3(); + BlockVector3 bv = mutablebv.setComponents(x, y, z); return pattern.apply(extent, bv, bv); } catch (WorldEditException e) { throw new RuntimeException("Unexpected exception", e); @@ -2147,7 +2146,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, private int makeCylinder(BlockVector3 pos, final Pattern block, double radiusX, double radiusZ, int height, double thickness, final boolean filled) { radiusX += 0.5; radiusZ += 0.5; - MutableBlockVector posv = new MutableBlockVector(pos); + MutableBlockVector3 posv = new MutableBlockVector3(pos); if (height == 0) { return this.changes; } else if (height < 0) { @@ -2167,7 +2166,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, int px = posv.getBlockX(); int py = posv.getBlockY(); int pz = posv.getBlockZ(); - MutableBlockVector mutable = new MutableBlockVector(); + MutableBlockVector3 mutable = new MutableBlockVector3(); final int ceilRadiusX = (int) Math.ceil(radiusX); final int ceilRadiusZ = (int) Math.ceil(radiusZ); @@ -2207,10 +2206,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } for (int y = 0; y < height; ++y) { - this.setBlock(mutable.setComponents(px + x, py + y, pz + z).toBlockVector3(), block); - this.setBlock(mutable.setComponents(px - x, py + y, pz + z).toBlockVector3(), block); - this.setBlock(mutable.setComponents(px + x, py + y, pz - z).toBlockVector3(), block); - this.setBlock(mutable.setComponents(px - x, py + y, pz - z).toBlockVector3(), block); + this.setBlock(mutable.setComponents(px + x, py + y, pz + z), block); + this.setBlock(mutable.setComponents(px - x, py + y, pz + z), block); + this.setBlock(mutable.setComponents(px + x, py + y, pz - z), block); + this.setBlock(mutable.setComponents(px - x, py + y, pz - z), block); } } } @@ -2241,10 +2240,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } for (int y = 0; y < height; ++y) { - this.setBlock(mutable.setComponents(px + x, py + y, pz + z).toBlockVector3(), block); - this.setBlock(mutable.setComponents(px - x, py + y, pz + z).toBlockVector3(), block); - this.setBlock(mutable.setComponents(px + x, py + y, pz - z).toBlockVector3(), block); - this.setBlock(mutable.setComponents(px - x, py + y, pz - z).toBlockVector3(), block); + this.setBlock(mutable.setComponents(px + x, py + y, pz + z), block); + this.setBlock(mutable.setComponents(px - x, py + y, pz + z), block); + this.setBlock(mutable.setComponents(px + x, py + y, pz - z), block); + this.setBlock(mutable.setComponents(px - x, py + y, pz - z), block); } } } @@ -2271,7 +2270,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, int px = pos.getBlockX(); int py = pos.getBlockY(); int pz = pos.getBlockZ(); - MutableBlockVector mutable = new MutableBlockVector(); + MutableBlockVector3 mutable = new MutableBlockVector3(); final int ceilRadiusX = (int) Math.ceil(radiusX); final int ceilRadiusY = (int) Math.ceil(radiusY); @@ -2318,21 +2317,21 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } if (Math.abs((x) * nx + (y) * ny + (z) * nz) < threshold) - setBlock(mutable.setComponents(px + x, py + y, pz + z).toBlockVector3(), block); + setBlock(mutable.setComponents(px + x, py + y, pz + z), block); if (Math.abs((-x) * nx + (y) * ny + (z) * nz) < threshold) - setBlock(mutable.setComponents(px - x, py + y, pz + z).toBlockVector3(), block); + setBlock(mutable.setComponents(px - x, py + y, pz + z), block); if (Math.abs((x) * nx + (-y) * ny + (z) * nz) < threshold) - setBlock(mutable.setComponents(px + x, py - y, pz + z).toBlockVector3(), block); + setBlock(mutable.setComponents(px + x, py - y, pz + z), block); if (Math.abs((x) * nx + (y) * ny + (-z) * nz) < threshold) - setBlock(mutable.setComponents(px + x, py + y, pz - z).toBlockVector3(), block); + setBlock(mutable.setComponents(px + x, py + y, pz - z), block); if (Math.abs((-x) * nx + (-y) * ny + (z) * nz) < threshold) - setBlock(mutable.setComponents(px - x, py - y, pz + z).toBlockVector3(), block); + setBlock(mutable.setComponents(px - x, py - y, pz + z), block); if (Math.abs((x) * nx + (-y) * ny + (-z) * nz) < threshold) - setBlock(mutable.setComponents(px + x, py - y, pz - z).toBlockVector3(), block); + setBlock(mutable.setComponents(px + x, py - y, pz - z), block); if (Math.abs((-x) * nx + (y) * ny + (-z) * nz) < threshold) - setBlock(mutable.setComponents(px - x, py + y, pz - z).toBlockVector3(), block); + setBlock(mutable.setComponents(px - x, py + y, pz - z), block); if (Math.abs((-x) * nx + (-y) * ny + (-z) * nz) < threshold) - setBlock(mutable.setComponents(px - x, py - y, pz - z).toBlockVector3(), block); + setBlock(mutable.setComponents(px - x, py - y, pz - z), block); } } } @@ -2791,7 +2790,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, final int maxY = max.getBlockY(); final int maxZ = max.getBlockZ(); - MutableBlockVector mutable = new MutableBlockVector(minX, minY, minZ); + MutableBlockVector3 mutable = new MutableBlockVector3(minX, minY, minZ); for (int x = minX; x <= maxX; ++x) { for (int y = minY; y <= maxY; ++y) { for (int z = minZ; z <= maxZ; ++z) { @@ -2938,14 +2937,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // // for (BlockVector3 position : region) { // // offset, scale -// final Vector3 scaled = position.toVector3().subtract(zero).divide(unit); +// final Vector3 scaled = position.subtract(zero).divide(unit); // // // transform // expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ()); // // final BlockVector3 sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue()); - private MutableBlockVector mutable = new MutableBlockVector(); + private MutableBlockVector3 mutable = new MutableBlockVector3(); @Override public boolean apply(BlockVector3 position) throws WorldEditException { @@ -3297,12 +3296,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) { @Override protected BaseBiome getBiome(final int x, final int z, final BaseBiome defaultBiomeType) { - final Vector2 current = Vector2.at(x, z); - environment.setCurrentBlock(current.toVector3(0)); - final Vector2 scaled = current.subtract(zero2D).divide(unit2D); + environment.setCurrentBlock(x, 0, z); + double scaledX = (x - zero2D.getX()) / unit2D.getX(); + double scaledZ = (z - zero2D.getZ()) / unit2D.getZ(); try { - if (expression.evaluate(scaled.getX(), scaled.getZ()) <= 0) { + if (expression.evaluate(scaledX, scaledZ) <= 0) { return null; } @@ -3397,8 +3396,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } } final Set chunks = region.getChunks(); - MutableBlockVector mutable = new MutableBlockVector(); - MutableBlockVector2D mutable2D = new MutableBlockVector2D(); + MutableBlockVector3 mutable = new MutableBlockVector3(); + MutableBlockVector2 mutable2D = new MutableBlockVector2(); for (BlockVector2 chunk : chunks) { final int cx = chunk.getBlockX(); final int cz = chunk.getBlockZ(); @@ -3418,7 +3417,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, boolean containsAny = false; if (cuboid && containsBot1 && containsBot2 && containsTop1 && containsTop2 && conNextX && conNextZ) { containsAny = true; - BlockVector3 mbv = mutable.toBlockVector3(); + BlockVector3 mbv = mutable; if (fcs != null) { for (int x = 0; x < 16; x++) { int xx = x + bx; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index c4331d27d..a4cefa188 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit; import com.boydti.fawe.Fawe; -import com.boydti.fawe.FaweCache; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweLimit; @@ -43,7 +42,6 @@ import com.sk89q.jchronic.utils.Time; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.command.tool.*; @@ -51,7 +49,6 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.operation.ChangeSetExecutor; import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.internal.cui.CUIEvent; @@ -67,7 +64,6 @@ import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.snapshot.Snapshot; @@ -878,7 +874,7 @@ public class LocalSession implements TextureHolder { public BlockVector3 getPlacementPosition(Player player) throws IncompleteRegionException { checkNotNull(player); if (!placeAtPos1) { - return player.getBlockIn().toVector().toBlockPoint(); + return player.getBlockIn().toBlockPoint(); } return selector.getPrimaryPosition(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java index 9e952c00b..8c14f4614 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java @@ -150,11 +150,11 @@ public class BiomeCommands extends MethodCommands { return; } - BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2()); + BaseBiome biome = player.getWorld().getBiome(blockPosition.toBlockPoint().toBlockVector2()); biomes[biome.getId()]++; size = 1; } else if (args.hasFlag('p')) { - BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2()); + BaseBiome biome = player.getWorld().getBiome(player.getLocation().toBlockPoint().toBlockVector2()); biomes[biome.getId()]++; size = 1; } else { @@ -219,7 +219,7 @@ public class BiomeCommands extends MethodCommands { Mask2D mask2d = mask != null ? mask.toMask2D() : null; if (atPosition) { - region = new CuboidRegion(player.getLocation().toVector().toBlockPoint(), player.getLocation().toVector().toBlockPoint()); + region = new CuboidRegion(player.getLocation().toBlockPoint(), player.getLocation().toBlockPoint()); } else { region = session.getSelection(world); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java index 8595e1c3a..01784ee81 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java @@ -27,7 +27,7 @@ import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.CombinedTransform; @@ -94,11 +94,11 @@ public class FlattenedClipboardTransform { corners[i] = transformAround.apply(corners[i]); } - MutableVector newMinimum = new MutableVector(corners[0]); - MutableVector newMaximum = new MutableVector(corners[0]); -// MutableVector cbv = new MutableVector(); + MutableVector3 newMinimum = new MutableVector3(corners[0]); + MutableVector3 newMaximum = new MutableVector3(corners[0]); +// MutableVector3 cbv = new MutableVector3(); for (int i = 1; i < corners.length; i++) { - MutableVector cbv = new MutableVector(corners[i]); + MutableVector3 cbv = new MutableVector3(corners[i]); newMinimum = newMinimum.setComponents(newMinimum.getMinimum(cbv)); newMaximum = newMaximum.setComponents(newMaximum.getMaximum(cbv)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index a51216540..3e76b61c4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -31,9 +31,7 @@ import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Logging; -import com.sk89q.worldedit.*; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -49,10 +47,8 @@ import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.command.binding.Range; import com.sk89q.worldedit.util.command.binding.Switch; @@ -142,9 +138,9 @@ public class GenerationCommands extends MethodCommands { image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(), RenderingHints.VALUE_INTERPOLATION_BILINEAR, false); } -// MutableBlockVector pos1 = new MutableBlockVector(player.getLocation().toVector().toBlockPoint()); -// MutableBlockVector pos2 = new MutableBlockVector(pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1)); - BlockVector3 pos1 = player.getLocation().toVector().toBlockPoint(); +// MutableBlockVector3 pos1 = new MutableBlockVector3(player.getLocation().toBlockPoint()); +// MutableBlockVector3 pos2 = new MutableBlockVector3(pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1)); + BlockVector3 pos1 = player.getLocation().toBlockPoint(); BlockVector3 pos2 = pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1); CuboidRegion region = new CuboidRegion(pos1, pos2); int[] count = new int[1]; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java index 2bb5e5d5d..af5716eb4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java @@ -40,7 +40,6 @@ import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.worldedit.*; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.command.binding.Range; @@ -167,10 +166,10 @@ public class HistoryCommands extends MethodCommands { radius = Math.max(Math.min(500, radius), 0); final World world = player.getWorld(); Location origin = player.getLocation(); - BlockVector3 bot = origin.toVector().toBlockPoint().subtract(radius, radius, radius); + BlockVector3 bot = origin.toBlockPoint().subtract(radius, radius, radius); bot = bot.withY(Math.max(0, bot.getY())); // bot.mutY(Math.max(0, bot.getY())); - BlockVector3 top = origin.toVector().toBlockPoint().add(radius, radius, radius); + BlockVector3 top = origin.toBlockPoint().add(radius, radius, radius); bot = bot.withY(Math.min(255, top.getY())); // top.mutY(Math.min(255, top.getY())); RollbackDatabase database = DBHandler.IMP.getDatabase(world); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java index 4e2a225d7..af2d20284 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java @@ -190,7 +190,7 @@ public class NavigationCommands { pos = player.getSolidBlockTrace(300); } if (pos != null) { - if(args.hasFlag('f')) player.setPosition(pos.toVector()); else player.findFreePosition(pos); + if(args.hasFlag('f')) player.setPosition(pos); else player.findFreePosition(pos); BBC.POOF.send(player); } else { BBC.NO_BLOCK.send(player); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 671704d3d..64d3f250c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -34,9 +34,7 @@ import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Logging; -import com.sk89q.worldedit.*; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -64,7 +62,6 @@ import com.sk89q.worldedit.math.convolution.HeightMapFilter; import com.sk89q.worldedit.math.noise.RandomNoise; import com.sk89q.worldedit.regions.*; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.command.binding.Range; import com.sk89q.worldedit.util.command.binding.Switch; @@ -172,7 +169,7 @@ public class RegionCommands extends MethodCommands { BBC.NO_BLOCK.send(player); return; } - CompoundTag nbt = editSession.getFullBlock(pos.toVector().toBlockPoint()).getNbtData(); + CompoundTag nbt = editSession.getFullBlock(pos.toBlockPoint()).getNbtData(); if (nbt != null) { player.print(nbt.getValue().toString()); } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index ae620d6e4..c00ac21f0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -35,7 +35,6 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.ParserContext; @@ -45,7 +44,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.regions.RegionSelector; @@ -65,18 +63,13 @@ import com.sk89q.worldedit.util.formatting.Style; import com.sk89q.worldedit.util.formatting.StyledFragment; import com.sk89q.worldedit.util.formatting.component.CommandListBox; import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.storage.ChunkStore; import java.io.File; -import java.net.MalformedURLException; import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.Set; import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION; @@ -115,7 +108,7 @@ public class SelectionCommands { return; } } else { - pos = player.getBlockIn().toVector().toBlockPoint(); + pos = player.getBlockIn().toBlockPoint(); } pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY()); if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) { @@ -148,7 +141,7 @@ public class SelectionCommands { return; } } else { - pos = player.getBlockIn().toVector().toBlockPoint(); + pos = player.getBlockIn().toBlockPoint(); } pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY()); if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) { @@ -169,7 +162,7 @@ public class SelectionCommands { ) @CommandPermissions("worldedit.selection.hpos") public void hpos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - BlockVector3 pos = player.getBlockTrace(300).toVector().toBlockPoint(); + BlockVector3 pos = player.getBlockTrace(300).toBlockPoint(); if (pos != null) { if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) { @@ -193,7 +186,7 @@ public class SelectionCommands { ) @CommandPermissions("worldedit.selection.hpos") public void hpos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - BlockVector3 pos = player.getBlockTrace(300).toVector().toBlockPoint(); + BlockVector3 pos = player.getBlockTrace(300).toBlockPoint(); if (pos != null) { if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) { @@ -254,7 +247,7 @@ public class SelectionCommands { min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toBlockVector3()); } else { // use player loc - min2D = ChunkStore.toChunk(player.getBlockIn().toVector().toBlockPoint()); + min2D = ChunkStore.toChunk(player.getBlockIn().toBlockPoint()); } min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java index b69157a70..58abbcd0d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java @@ -6,9 +6,6 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; -import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -33,7 +30,7 @@ public class AreaPickaxe implements BlockTool { int ox = clicked.getBlockX(); int oy = clicked.getBlockY(); int oz = clicked.getBlockZ(); - BlockType initialType = clicked.getExtent().getBlock(clicked.toVector().toBlockPoint()).getBlockType(); + BlockType initialType = clicked.getExtent().getBlock(clicked.toBlockPoint()).getBlockType(); if (initialType.getMaterial().isAir()) { return true; @@ -63,7 +60,7 @@ public class AreaPickaxe implements BlockTool { // continue; // } // -// ((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().toBlockPoint().distanceSq(pos)); +// ((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toBlockPoint().distanceSq(pos)); // // editSession.setBlock(pos, BlockTypes.AIR.getDefaultState()); // } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java index f79f60a0e..004dc5bb2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java @@ -37,7 +37,6 @@ import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockStateHolder; /** * A mode that cycles the data values of supported blocks. @@ -56,8 +55,8 @@ public class BlockDataCyler implements DoubleActionBlockTool { World world = (World) clicked.getExtent(); -// BlockStateHolder block = world.getBlock(clicked.toVector()); - BlockVector3 blockPoint = clicked.toVector().toBlockPoint(); +// BlockStateHolder block = world.getBlock(clicked); + BlockVector3 blockPoint = clicked.toBlockPoint(); BlockState block = world.getBlock(blockPoint); if (!config.allowedDataCycleBlocks.isEmpty() diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java index 986eb16bd..0a7b63e6c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java @@ -19,24 +19,16 @@ package com.sk89q.worldedit.command.tool; -import com.boydti.fawe.object.extent.PatternTransform; -import com.sk89q.worldedit.*; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.inventory.BlockBag; -import com.sk89q.worldedit.function.pattern.BlockPattern; -import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BlockState; /** * A mode that replaces one block. @@ -61,7 +53,7 @@ public class BlockReplacer implements DoubleActionBlockTool { EditSession editSession = session.createEditSession(player); try { - editSession.setBlock(clicked.toVector().toBlockPoint(), pattern); + editSession.setBlock(clicked.toBlockPoint(), pattern); } finally { if (bag != null) { bag.flushChanges(); @@ -76,7 +68,7 @@ public class BlockReplacer implements DoubleActionBlockTool { @Override public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { EditSession editSession = session.createEditSession(player); - BlockStateHolder targetBlock = (editSession).getBlock(clicked.toVector().toBlockPoint()); + BlockStateHolder targetBlock = (editSession).getBlock(clicked.toBlockPoint()); BlockType type = targetBlock.getBlockType(); if (type != null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 78b7e1b70..221d71eb5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -1,7 +1,6 @@ package com.sk89q.worldedit.command.tool; import com.boydti.fawe.Fawe; -import com.boydti.fawe.FaweCache; import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RunnableVal; @@ -26,7 +25,6 @@ import com.sk89q.worldedit.*; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.entity.Player; @@ -40,7 +38,6 @@ import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import java.io.IOException; @@ -53,7 +50,6 @@ import java.util.concurrent.locks.ReentrantLock; import javax.annotation.Nullable; -import static com.boydti.fawe.object.brush.TargetMode.TARGET_FACE_RANGE; import static com.google.common.base.Preconditions.checkNotNull; public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool, ResettableTool, Serializable { @@ -385,7 +381,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool Location loc = player.getLocation(); switch (targetMode) { case TARGET_BLOCK_RANGE: - return offset(trace(editSession, player, getRange(), true), loc.toVector()).toBlockPoint(); + return offset(trace(editSession, player, getRange(), true), loc).toBlockPoint(); case FOWARD_POINT_PITCH: { int d = 0; float pitch = loc.getPitch(); @@ -393,7 +389,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool d += (int) (Math.sin(Math.toRadians(pitch)) * 50); final Vector3 vector = loc.getDirection().withY(0).normalize().multiply(d).add(loc.getX(), loc.getY(), loc.getZ()); // vector = vector.add(loc.getX(), loc.getY(), loc.getZ()); - return offset(vector, loc.toVector()).toBlockPoint(); + return offset(vector, loc).toBlockPoint(); } case TARGET_POINT_HEIGHT: { final int height = loc.getBlockY(); @@ -407,10 +403,10 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool } } final int distance = (height - y) + 8; - return offset(trace(editSession, player, distance, true), loc.toVector()).toBlockPoint(); + return offset(trace(editSession, player, distance, true), loc).toBlockPoint(); } case TARGET_FACE_RANGE: - return offset(trace(editSession, player, getRange(), true), loc.toVector()).toBlockPoint(); + return offset(trace(editSession, player, getRange(), true), loc).toBlockPoint(); default: return null; } @@ -429,7 +425,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool @Override public void run(Vector3 value) { Location result = tb.getMaskedTargetBlock(useLastBlock); - this.value = result.toVector(); + this.value = result; } }); } @@ -478,7 +474,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool editSession.setMask(newMask); //======= // try { -// brush.build(editSession, target.toVector().toBlockPoint(), material, size); +// brush.build(editSession, target.toBlockPoint(), material, size); // } catch (MaxChangedBlocksException e) { // player.printError("Max blocks change limit reached."); // } finally { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java index 5fa95d04b..b78f81f15 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java @@ -50,7 +50,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool { if (target == null) return true; RegionSelector selector = session.getRegionSelector(player.getWorld()); - BlockVector3 blockPoint = target.toVector().toBlockPoint(); + BlockVector3 blockPoint = target.toBlockPoint(); if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) { selector.explainPrimarySelection(player, session, blockPoint); } @@ -68,7 +68,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool { if (target == null) return true; RegionSelector selector = session.getRegionSelector(player.getWorld()); - BlockVector3 blockPoint = target.toVector().toBlockPoint(); + BlockVector3 blockPoint = target.toBlockPoint(); if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) { selector.explainSecondarySelection(player, session, blockPoint); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java index 591bbe158..aa3d91b7f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java @@ -69,7 +69,7 @@ public class FloatingTreeRemover implements BlockTool { Player player, LocalSession session, Location clicked) { final World world = (World) clicked.getExtent(); - final BlockState state = world.getBlock(clicked.toVector().toBlockPoint()); + final BlockState state = world.getBlock(clicked.toBlockPoint()); if (!isTreeBlock(state.getBlockType())) { player.printError("That's not a tree."); @@ -77,7 +77,7 @@ public class FloatingTreeRemover implements BlockTool { } final EditSession editSession = session.createEditSession(player); try /*(EditSession editSession = session.createEditSession(player))*/ { - final Set blockSet = bfs(world, clicked.toVector().toBlockPoint()); + final Set blockSet = bfs(world, clicked.toBlockPoint()); if (blockSet == null) { player.printError("That's not a floating tree."); return true; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java index 07f31c289..ee08812ad 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.command.tool; -import com.sk89q.worldedit.*; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -59,7 +58,7 @@ public class FloodFillTool implements BlockTool { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { World world = (World) clicked.getExtent(); - BlockVector3 origin = clicked.toVector().toBlockPoint(); + BlockVector3 origin = clicked.toBlockPoint(); BlockType initialType = world.getBlock(origin).getBlockType(); if (initialType.getMaterial().isAir()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java index c20bec34f..4137e1efd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java @@ -58,12 +58,12 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo EditSession eS = session.createEditSession(player); try { // eS.disableBuffering(); - BlockVector3 blockPoint = pos.toVector().toBlockPoint(); + BlockVector3 blockPoint = pos.toBlockPoint(); BaseBlock applied = secondary.apply(blockPoint); if (applied.getBlockType().getMaterial().isAir()) { eS.setBlock(blockPoint, secondary); } else { - eS.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), secondary); + eS.setBlock(pos.subtract(pos.getDirection()).toBlockPoint(), secondary); } return true; } catch (MaxChangedBlocksException e) { @@ -80,12 +80,12 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo try { // eS.disableBuffering(); - BlockVector3 blockPoint = pos.toVector().toBlockPoint(); + BlockVector3 blockPoint = pos.toBlockPoint(); BaseBlock applied = primary.apply(blockPoint); if (applied.getBlockType().getMaterial().isAir()) { eS.setBlock(blockPoint, primary); } else { - eS.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), primary); + eS.setBlock(pos.subtract(pos.getDirection()).toBlockPoint(), primary); } return true; } catch (MaxChangedBlocksException e) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java index ef71569f4..29d655d08 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java @@ -45,10 +45,10 @@ public class QueryTool implements BlockTool { World world = (World) clicked.getExtent(); EditSession editSession = session.createEditSession(player); - BlockVector3 blockPoint = clicked.toVector().toBlockPoint(); + BlockVector3 blockPoint = clicked.toBlockPoint(); BaseBlock block = editSession.getFullBlock(blockPoint); - player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e" + player.print("\u00A79@" + clicked + ": " + "\u00A7e" + block.getBlockType().getName() + "\u00A77" + " (" + block.toString() + ") " + "\u00A7f" diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java index 50f2d41ba..f794882d7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java @@ -1,7 +1,5 @@ package com.sk89q.worldedit.command.tool; -import java.util.Set; - import com.boydti.fawe.object.mask.IdMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; @@ -13,13 +11,6 @@ import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.LocalConfiguration; -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -45,10 +36,10 @@ public class RecursivePickaxe implements BlockTool { @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { World world = (World) clicked.getExtent(); - final BlockVector3 pos = clicked.toVector().toBlockPoint(); + final BlockVector3 pos = clicked.toBlockPoint(); EditSession editSession = session.createEditSession(player); - BlockVector3 origin = clicked.toVector().toBlockPoint(); + BlockVector3 origin = clicked.toBlockPoint(); BlockType initialType = world.getBlock(origin).getBlockType(); BlockStateHolder block = editSession.getBlock(pos); @@ -74,8 +65,8 @@ public class RecursivePickaxe implements BlockTool { session.remember(editSession); //======= // try { -// recurse(server, editSession, world, clicked.toVector().toBlockPoint(), -// clicked.toVector().toBlockPoint(), range, initialType, new HashSet<>()); +// recurse(server, editSession, world, clicked.toBlockPoint(), +// clicked.toBlockPoint(), range, initialType, new HashSet<>()); // } catch (MaxChangedBlocksException e) { // player.printError("Max blocks change limit reached."); // } finally { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java index c37369352..9ac871ad3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java @@ -44,7 +44,7 @@ public class SinglePickaxe implements BlockTool { @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { World world = (World) clicked.getExtent(); - BlockVector3 blockPoint = clicked.toVector().toBlockPoint(); + BlockVector3 blockPoint = clicked.toBlockPoint(); final BlockType blockType = world.getBlock(blockPoint).getBlockType(); if (blockType == BlockTypes.BEDROCK && !player.canDestroyBedrock()) { @@ -61,7 +61,7 @@ public class SinglePickaxe implements BlockTool { try { if (editSession.setBlock(clicked.getBlockX(), clicked.getBlockY(), clicked.getBlockZ(), EditSession.nullBlock)) { // TODO FIXME play effect -// world.playEffect(clicked.toVector(), 2001, blockType); +// world.playEffect(clicked, 2001, blockType); } } finally { editSession.flushQueue(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java index d15ce9a20..41353b0ad 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java @@ -53,7 +53,7 @@ public class TreePlanter implements BlockTool { try { boolean successful = false; for (int i = 0; i < 10; i++) { - if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0).toBlockPoint())) { + if (treeType.generate(editSession, clicked.add(0, 1, 0).toBlockPoint())) { successful = true; break; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java index 843fd105d..a2c2750b6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java @@ -44,7 +44,7 @@ public class SmoothBrush implements Brush { Vector3 posDouble = position.toVector3(); Location min = new Location(editSession.getWorld(), posDouble.subtract(size, size, size)); BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint(); - Region region = new CuboidRegion(editSession.getWorld(), min.toVector().toBlockPoint(), max); + Region region = new CuboidRegion(editSession.getWorld(), min.toBlockPoint(), max); HeightMap heightMap = new HeightMap(editSession, region); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); heightMap.applyFilter(filter, iterations); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 64d44a334..66fb43d85 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.extension.platform; -import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.entity.Player; @@ -36,20 +35,12 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypeUtil; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; -import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.internal.cui.CUIEvent; -import com.sk89q.worldedit.util.HandSide; -import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.util.TargetBlock; -import com.sk89q.worldedit.util.auth.AuthorizationException; import java.io.File; @@ -345,12 +336,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public Location getBlockIn() { - return getLocation().setPosition(getLocation().toVector().floor()); + return getLocation().setPosition(getLocation().floor()); } @Override public Location getBlockOn() { - return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor()); + return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).floor()); } @Override @@ -425,7 +416,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { boolean inFree = false; while ((block = hitBlox.getNextBlock()) != null) { - boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType().getMaterial().isMovementBlocker(); + boolean free = !world.getBlock(block.toBlockPoint()).getBlockType().getMaterial().isMovementBlocker(); if (firstBlock) { firstBlock = false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 3387a107a..38f4654cd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -28,7 +28,6 @@ import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; import com.boydti.fawe.wrappers.PlayerWrapper; import com.boydti.fawe.wrappers.WorldWrapper; -import com.sk89q.worldedit.*; import com.sk89q.worldedit.command.tool.*; import static com.google.common.base.Preconditions.checkNotNull; @@ -44,7 +43,6 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.*; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.HandSide; @@ -310,7 +308,7 @@ public class PlatformManager { final Actor actor = createProxyActor(event.getCause()); try { final Location location = event.getLocation(); - final BlockVector3 vector = location.toVector().toBlockPoint(); + final BlockVector3 vector = location.toBlockPoint(); // At this time, only handle interaction from players if (actor instanceof Player) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java index 448e655b4..61aebf909 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.extension.platform; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import static com.google.common.base.Preconditions.checkNotNull; @@ -112,7 +111,7 @@ public class PlayerProxy extends AbstractPlayerActor { @Override public Location getLocation() { Location loc = this.basePlayer.getLocation(); - return new Location(loc.getExtent(), loc.toVector().add(offset), loc.getDirection()); + return new Location(loc.getExtent(), loc.add(offset), loc.getDirection()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index 5229c3ac9..1aa31fdd8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -35,7 +35,7 @@ import com.sk89q.worldedit.function.operation.OperationQueue; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BaseBiome; @@ -51,7 +51,7 @@ import javax.annotation.Nullable; public class AbstractDelegateExtent implements LightingExtent { private transient final Extent extent; -// private MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); +// private MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); /** * Create a new instance. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java index 2944a0150..787073d21 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java @@ -39,7 +39,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class MaskingExtent extends AbstractDelegateExtent { private Mask mask; -// private MutableBlockVector mutable = new MutableBlockVector(); +// private MutableBlockVector3 mutable = new MutableBlockVector3(); /** * Create a new instance. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index 14cbc1170..3c1ffa4f5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -32,7 +32,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockState; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -42,9 +41,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BaseBiome; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockState; + import java.io.Closeable; import java.util.ArrayList; import java.util.Collections; @@ -177,7 +175,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable public List getEntities(Region region) { List filtered = new ArrayList<>(); for (Entity entity : getEntities()) { - if (region.contains(entity.getLocation().toVector().toBlockPoint())) { + if (region.contains(entity.getLocation().toBlockPoint())) { filtered.add(entity); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index 7ead8f224..93a526377 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -141,6 +141,8 @@ public class BlockTransformExtent extends ResettableExtent { private static final Set directionNames = Sets.newHashSet("north", "south", "east", "west"); + + /** * Transform the given block using the given transform. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index bf06d0a03..fca42f721 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -26,7 +26,6 @@ import com.sk89q.jnbt.FloatTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.Tag; -import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -104,7 +103,7 @@ public class ExtentEntityCopy implements EntityFunction { //<<<<<<< HEAD // Vector pivot = from.round().add(0.5, 0.5, 0.5); -// Vector newPosition = transform.apply(location.toVector().subtract(pivot)); +// Vector newPosition = transform.apply(location.subtract(pivot)); // Vector newDirection; // if (transform.isIdentity()) { // newDirection = entity.getLocation().getDirection(); @@ -116,7 +115,7 @@ public class ExtentEntityCopy implements EntityFunction { // } //======= Vector3 pivot = from.round().add(0.5, 0.5, 0.5); - Vector3 newPosition = transform.apply(location.toVector().subtract(pivot)); + Vector3 newPosition = transform.apply(location.subtract(pivot)); Vector3 newDirection; newDirection = transform.isIdentity() ? diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java index 81d344b16..464c892ba 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java @@ -18,7 +18,7 @@ public class BackwardsExtentBlockCopy implements Operation { private final RegionFunction function; private final BlockVector3 origin; -// private Vector mutable = new MutableBlockVector(); +// private Vector mutable = new MutableBlockVector3(); public BackwardsExtentBlockCopy(Extent source, Region region, Extent destination, BlockVector3 origin, Transform transform, RegionFunction function) { this.source = source; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java index a44c52ffa..2205a4937 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java @@ -369,7 +369,7 @@ public class ForwardExtentCopy implements Operation { if (!entities.isEmpty()) { ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), destination, to.toVector3(), currentTransform); // if (copyingEntities) { -// ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), destination, to.toVector3(), currentTransform); +// ExtentEntityCopy entityCopy = new ExtentEntityCopy(from, destination, to, currentTransform); entityCopy.setRemoving(removingEntities); EntityVisitor entityVisitor = new EntityVisitor(entities.iterator(), entityCopy); Operations.completeBlindly(entityVisitor); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java index e3978d8d3..8a797f5cd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java @@ -29,5 +29,4 @@ public interface FawePattern extends Pattern { */ @Override boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException; -} - +} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index 8e1359b27..b31ea0d85 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -14,7 +14,7 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector3; import java.util.ArrayDeque; @@ -217,8 +217,8 @@ public abstract class BreadthFirstSearch implements Operation { @Override public Operation resume(RunContext run) throws WorldEditException { - MutableBlockVector mutable = new MutableBlockVector(); -// MutableBlockVector mutable2 = new MutableBlockVector(); + MutableBlockVector3 mutable = new MutableBlockVector3(); +// MutableBlockVector3 mutable2 = new MutableBlockVector3(); boolean shouldTrim = false; IntegerTrio[] dirs = getIntDirections(); BlockVectorSet tempQueue = new BlockVectorSet(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DirectionalVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DirectionalVisitor.java index 069aaff4a..8a9542e32 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DirectionalVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DirectionalVisitor.java @@ -20,7 +20,7 @@ package com.sk89q.worldedit.function.visitor; import com.boydti.fawe.object.HasFaweQueue; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java index c1c24925f..256f891ec 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java @@ -102,7 +102,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv } if (logMode != null && sender.isPlayer()) { - Vector3 position = player.getLocation().toVector(); + Vector3 position = player.getLocation(); LocalSession session = worldEdit.getSessionManager().get(player); switch (logMode) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java index 26de9ff3d..c2e6cf904 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java @@ -60,22 +60,12 @@ public class BlockVector2 { } public static BlockVector2 at(int x, int z) { - switch (x) { - case 0: - if (z == 0) { - return ZERO; - } - break; - case 1: - if (z == 1) { - return ONE; - } - break; - } return new BlockVector2(x, z); } - private final int x, z; + protected int x, z; + + protected BlockVector2(){} /** * Construct an instance. @@ -83,11 +73,31 @@ public class BlockVector2 { * @param x the X coordinate * @param z the Z coordinate */ - private BlockVector2(int x, int z) { + protected BlockVector2(int x, int z) { this.x = x; this.z = z; } + public MutableBlockVector2 setComponents(int x, int z) { + return new MutableBlockVector2(x, z); + } + + public MutableBlockVector2 mutX(double x) { + return new MutableBlockVector2((int) x, z); + } + + public MutableBlockVector2 mutZ(double z) { + return new MutableBlockVector2(x, (int) z); + } + + public MutableBlockVector2 mutX(int x) { + return new MutableBlockVector2(x, z); + } + + public MutableBlockVector2 mutZ(int z) { + return new MutableBlockVector2(x, z); + } + /** * Get the X coordinate. * @@ -144,6 +154,35 @@ public class BlockVector2 { return BlockVector2.at(x, z); } + public MutableBlockVector2 nextPosition() { + int absX = Math.abs(x); + int absY = Math.abs(z); + if (absX > absY) { + if (x > 0) { + return setComponents(x, z + 1); + } else { + return setComponents(x, z - 1); + } + } else if (absY > absX) { + if (z > 0) { + return setComponents(x - 1, z); + } else { + return setComponents(x + 1, z); + } + } else { + if (x == z && x > 0) { + return setComponents(x, z + 1); + } + if (x == absX) { + return setComponents(x, z + 1); + } + if (z == absY) { + return setComponents(x, z - 1); + } + return setComponents(x + 1, z); + } + } + /** * Add another vector to this vector and return the result as a new vector. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java index cda4e5414..367efdb69 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java @@ -42,20 +42,6 @@ public class BlockVector3 { } public static BlockVector3 at(int x, int y, int z) { - // switch for efficiency on typical cases - // in MC y is rarely 0/1 on selections - switch (y) { - case 0: - if (x == 0 && z == 0) { - return ZERO; - } - break; - case 1: - if (x == 1 && z == 1) { - return ONE; - } - break; - } return new BlockVector3(x, y, z); } @@ -80,7 +66,9 @@ public class BlockVector3 { return YzxOrderComparator.YZX_ORDER; } - private final int x, y, z; + protected int x, y, z; + + protected BlockVector3(){} /** * Construct an instance. @@ -89,12 +77,44 @@ public class BlockVector3 { * @param y the Y coordinate * @param z the Z coordinate */ - private BlockVector3(int x, int y, int z) { + protected BlockVector3(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } + public MutableBlockVector3 setComponents(double x, double y, double z) { + return new MutableBlockVector3((int) x, (int) y, (int) z); + } + + public MutableBlockVector3 setComponents(int x, int y, int z) { + return new MutableBlockVector3(x, y, z); + } + + public MutableBlockVector3 mutX(double x) { + return new MutableBlockVector3((int) x, y, z); + } + + public MutableBlockVector3 mutY(double y) { + return new MutableBlockVector3(x, (int) y, z); + } + + public MutableBlockVector3 mutZ(double z) { + return new MutableBlockVector3(x, y, (int) z); + } + + public MutableBlockVector3 mutX(int x) { + return new MutableBlockVector3(x, y, z); + } + + public MutableBlockVector3 mutY(int y) { + return new MutableBlockVector3(x, y, z); + } + + public MutableBlockVector3 mutZ(int z) { + return new MutableBlockVector3(x, y, z); + } + /** * Get the X coordinate. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector.java deleted file mode 100644 index 8fda11c05..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector.java +++ /dev/null @@ -1,629 +0,0 @@ -package com.sk89q.worldedit.math; - -import com.boydti.fawe.util.MathMan; -import com.google.common.collect.ComparisonChain; -import com.sk89q.worldedit.math.transform.AffineTransform; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Comparator; - -/** - * A mutable rendition of WorldEdit's BlockVector3 class. - * This class should ONLY be used locally for efficient vector manipulation. - */ - -public class MutableBlockVector implements Serializable { - private transient int x, y, z; - - private static ThreadLocal MUTABLE_CACHE = new ThreadLocal() { - @Override - protected MutableBlockVector initialValue() { - return new MutableBlockVector(); - } - }; - - public static MutableBlockVector get(int x, int y, int z) { - return MUTABLE_CACHE.get().setComponents(x, y, z); - } - - public MutableBlockVector(BlockVector3 v) { - this(v.getBlockX(), v.getBlockY(), v.getBlockZ()); - } - - public MutableBlockVector(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public MutableBlockVector() { - this(0, 0, 0); - } - - public static final MutableBlockVector ZERO = new MutableBlockVector(0, 0, 0); - public static final MutableBlockVector UNIT_X = new MutableBlockVector(1, 0, 0); - public static final MutableBlockVector UNIT_Y = new MutableBlockVector(0, 1, 0); - public static final MutableBlockVector UNIT_Z = new MutableBlockVector(0, 0, 1); - public static final MutableBlockVector ONE = new MutableBlockVector(1, 1, 1); - - // thread-safe initialization idiom - private static final class YzxOrderComparator { - private static final Comparator YZX_ORDER = (a, b) -> { - return ComparisonChain.start() - .compare(a.y, b.y) - .compare(a.z, b.z) - .compare(a.x, b.x) - .result(); - }; - } - - /** - * Returns a comparator that sorts vectors first by Y, then Z, then X. - * - *

- * Useful for sorting by chunk block storage order. - */ - public static Comparator sortByCoordsYzx() { - return YzxOrderComparator.YZX_ORDER; - } - - public MutableBlockVector setComponents(BlockVector3 other) { - return setComponents(other.getBlockX(), other.getBlockY(), other.getBlockZ()); - } - - public MutableBlockVector setComponents(double x, double y, double z) { - return this.setComponents((int) x, (int) y, (int) z); - } - - public MutableBlockVector setComponents(int x, int y, int z) { - this.mutX(x); - this.mutY(y); - this.mutZ(z); - return this; - } - - public final void mutX(double x) { - this.x = MathMan.roundInt(x); - } - - public final void mutY(double y) { - this.y = MathMan.roundInt(y); - } - - public final void mutZ(double z) { - this.z = MathMan.roundInt(z); - } - - public final void mutX(int x) { - this.x = x; - } - - public final void mutY(int y) { - this.y = y; - } - - public final void mutZ(int z) { - this.z = z; - } - - /** - * Get the X coordinate. - * - * @return the x coordinate - */ - public int getX() { - return x; - } - - /** - * Get the X coordinate. - * - * @return the x coordinate - */ - public int getBlockX() { - return x; - } - - /** - * Get the Y coordinate. - * - * @return the y coordinate - */ - public int getY() { - return y; - } - - /** - * Get the Y coordinate. - * - * @return the y coordinate - */ - public int getBlockY() { - return y; - } - - /** - * Get the Z coordinate. - * - * @return the z coordinate - */ - public int getZ() { - return z; - } - - /** - * Get the Z coordinate. - * - * @return the z coordinate - */ - public int getBlockZ() { - return z; - } - - /** - * Add another vector to this vector. - * - * @param other the other vector - * @return a new vector - */ - public MutableBlockVector add(MutableBlockVector other) { - return add(other.x, other.y, other.z); - } - - /** - * Add another vector to this vector. - * - * @param x the value to add - * @param y the value to add - * @param z the value to add - * @return a new vector - */ - public MutableBlockVector add(int x, int y, int z) { - this.x += x; - this.y += y; - this.z += z; - return this; - } - - /** - * Add a list of vectors to this vector and return the - * result as a new vector. - * - * @param others an array of vectors - * @return a new vector - */ - public MutableBlockVector add(MutableBlockVector... others) { - - for (MutableBlockVector other : others) { - x += other.x; - y += other.y; - z += other.z; - } - - return this; - } - - /** - * Subtract another vector from this vector and return the result - * as a new vector. - * - * @param other the other vector - * @return a new vector - */ - public MutableBlockVector subtract(MutableBlockVector other) { - return subtract(other.x, other.y, other.z); - } - - /** - * Subtract another vector from this vector and return the result - * as a new vector. - * - * @param x the value to subtract - * @param y the value to subtract - * @param z the value to subtract - * @return a new vector - */ - public MutableBlockVector subtract(int x, int y, int z) { - this.x -= x; - this.y -= y; - this.z -= z; - return this; - } - - /** - * Subtract a list of vectors from this vector and return the result - * as a new vector. - * - * @param others an array of vectors - * @return a new vector - */ - public MutableBlockVector subtract(MutableBlockVector... others) { - - for (MutableBlockVector other : others) { - x -= other.x; - y -= other.y; - z -= other.z; - } - - return this; - } - - /** - * Multiply this vector by another vector on each component. - * - * @param other the other vector - * @return a new vector - */ - public MutableBlockVector multiply(MutableBlockVector other) { - return multiply(other.x, other.y, other.z); - } - - /** - * Multiply this vector by another vector on each component. - * - * @param x the value to multiply - * @param y the value to multiply - * @param z the value to multiply - * @return a new vector - */ - public MutableBlockVector multiply(int x, int y, int z) { - this.x *= x; - this.y *= y; - this.z *= z; - return this; - } - - /** - * Multiply this vector by zero or more vectors on each component. - * - * @param others an array of vectors - * @return a new vector - */ - public MutableBlockVector multiply(MutableBlockVector... others) { - - for (MutableBlockVector other : others) { - x *= other.x; - y *= other.y; - z *= other.z; - } - - return this; - } - - /** - * Perform scalar multiplication and return a new vector. - * - * @param n the value to multiply - * @return a new vector - */ - public MutableBlockVector multiply(int n) { - return multiply(n, n, n); - } - - /** - * Divide this vector by another vector on each component. - * - * @param other the other vector - * @return a new vector - */ - public MutableBlockVector divide(MutableBlockVector other) { - return divide(other.x, other.y, other.z); - } - - /** - * Divide this vector by another vector on each component. - * - * @param x the value to divide by - * @param y the value to divide by - * @param z the value to divide by - * @return a new vector - */ - public MutableBlockVector divide(int x, int y, int z) { - this.x /= x; - this.y /= y; - this.z /= z; - return this; - } - - /** - * Perform scalar division and return a new vector. - * - * @param n the value to divide by - * @return a new vector - */ - public MutableBlockVector divide(int n) { - return divide(n, n, n); - } - - /** - * Get the length of the vector. - * - * @return length - */ - public double length() { - return Math.sqrt(lengthSq()); - } - - /** - * Get the length, squared, of the vector. - * - * @return length, squared - */ - public int lengthSq() { - return x * x + y * y + z * z; - } - - /** - * Get the distance between this vector and another vector. - * - * @param other the other vector - * @return distance - */ - public double distance(MutableBlockVector other) { - return Math.sqrt(distanceSq(other)); - } - - /** - * Get the distance between this vector and another vector, squared. - * - * @param other the other vector - * @return distance - */ - public int distanceSq(MutableBlockVector other) { - int dx = other.x - x; - int dy = other.y - y; - int dz = other.z - z; - return dx * dx + dy * dy + dz * dz; - } - - /** - * Get the normalized vector, which is the vector divided by its - * length, as a new vector. - * - * @return a new vector - */ - public MutableBlockVector normalize() { - double len = length(); - x /= len; - y /= len; - z /= len; - return this; - } - - /** - * Gets the dot product of this and another vector. - * - * @param other the other vector - * @return the dot product of this and the other vector - */ - public double dot(MutableBlockVector other) { - return x * other.x + y * other.y + z * other.z; - } - - /** - * Gets the cross product of this and another vector. - * - * @param other the other vector - * @return the cross product of this and the other vector - */ - public MutableBlockVector cross(MutableBlockVector other) { - x = y * other.z - z * other.y; - y = z * other.x - x * other.z; - z = x * other.y - y * other.x; - return this; - } - - /** - * Checks to see if a vector is contained with another. - * - * @param min the minimum point (X, Y, and Z are the lowest) - * @param max the maximum point (X, Y, and Z are the lowest) - * @return true if the vector is contained - */ - public boolean containedWithin(MutableBlockVector min, MutableBlockVector max) { - return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z; - } - - /** - * Clamp the Y component. - * - * @param min the minimum value - * @param max the maximum value - * @return a new vector - */ - public MutableBlockVector clampY(int min, int max) { - checkArgument(min <= max, "minimum cannot be greater than maximum"); - if (y < min) { - y = min; - } - if (y > max) { - y = max; - } - return this; - } - - /** - * Floors the values of all components. - * - * @return a new vector - */ - public MutableBlockVector floor() { - // already floored, kept for feature parity with Vector3 - return this; - } - - /** - * Rounds all components up. - * - * @return a new vector - */ - public MutableBlockVector ceil() { - // already raised, kept for feature parity with Vector3 - return this; - } - - /** - * Rounds all components to the closest integer. - * - *

Components < 0.5 are rounded down, otherwise up.

- * - * @return a new vector - */ - public MutableBlockVector round() { - // already rounded, kept for feature parity with Vector3 - return this; - } - - /** - * Returns a vector with the absolute values of the components of - * this vector. - * - * @return a new vector - */ - public MutableBlockVector abs() { - x = Math.abs(x); - y = Math.abs(y); - z = Math.abs(z); - return this; - } - - /** - * Perform a 2D transformation on this vector and return a new one. - * - * @param angle in degrees - * @param aboutX about which x coordinate to rotate - * @param aboutZ about which z coordinate to rotate - * @param translateX what to add after rotation - * @param translateZ what to add after rotation - * @return a new vector - * @see AffineTransform another method to transform vectors - */ - public MutableBlockVector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { - angle = Math.toRadians(angle); - double x = this.x - aboutX; - double z = this.z - aboutZ; - double cos = Math.cos(angle); - double sin = Math.sin(angle); - double x2 = x * cos - z * sin; - double z2 = x * sin + z * cos; - this.x = (int) Math.floor(x2 + aboutX + translateX); - this.z = (int) Math.floor(z2 + aboutZ + translateZ); - return this; - } - - /** - * Get this vector's pitch as used within the game. - * - * @return pitch in radians - */ - public double toPitch() { - double x = getX(); - double z = getZ(); - - if (x == 0 && z == 0) { - return getY() > 0 ? -90 : 90; - } else { - double x2 = x * x; - double z2 = z * z; - double xz = Math.sqrt(x2 + z2); - return Math.toDegrees(Math.atan(-getY() / xz)); - } - } - - /** - * Get this vector's yaw as used within the game. - * - * @return yaw in radians - */ - public double toYaw() { - double x = getX(); - double z = getZ(); - - double t = Math.atan2(-x, z); - double tau = 2 * Math.PI; - - return Math.toDegrees(((t + tau) % tau)); - } - - /** - * Gets the minimum components of two vectors. - * - * @param v2 the second vector - * @return minimum - */ - public MutableBlockVector getMinimum(MutableBlockVector v2) { - x = Math.min(x, v2.x); - y = Math.min(y, v2.y); - z = Math.min(z, v2.z); - return this; - } - - /** - * Gets the maximum components of two vectors. - * - * @param v2 the second vector - * @return maximum - */ - public MutableBlockVector getMaximum(MutableBlockVector v2) { - x = Math.max(x, v2.x); - y = Math.max(y, v2.y); - z = Math.max(z, v2.z); - return this; - } - - /** - * Creates a 2D vector by dropping the Y component from this vector. - * - * @return a new {@link BlockVector2} - */ - public BlockVector2 toBlockVector2() { - return BlockVector2.at(x, z); - } - - public Vector3 toVector3() { - return Vector3.at(x, y, z); - } - - public BlockVector3 toBlockVector3() { - return BlockVector3.at(x, y, z); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof MutableBlockVector)) { - return false; - } - - MutableBlockVector other = (MutableBlockVector) obj; - return other.x == this.x && other.y == this.y && other.z == this.z; - } - - @Override - public int hashCode() { - int hash = 17; - hash = 31 * hash + Integer.hashCode(x); - hash = 31 * hash + Integer.hashCode(y); - hash = 31 * hash + Integer.hashCode(z); - return hash; - } - - @Override - public String toString() { - return "Mutable (" + x + ", " + y + ", " + z + ")"; - } - - private void writeObject(java.io.ObjectOutputStream stream) throws IOException { - stream.writeInt(x); - stream.writeByte((byte) y); - stream.writeInt(z); - } - - private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { - this.x = stream.readInt(); - this.y = stream.readByte() & 0xFF; - this.z = stream.readInt(); - } -} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java new file mode 100644 index 000000000..13bcb5cd4 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java @@ -0,0 +1,52 @@ +package com.sk89q.worldedit.math; + +public class MutableBlockVector2 extends BlockVector2 { + + private static ThreadLocal MUTABLE_CACHE = new ThreadLocal() { + @Override + protected MutableBlockVector2 initialValue() { + return new MutableBlockVector2(); + } + }; + + public static MutableBlockVector2 get(int x, int z) { + return MUTABLE_CACHE.get().setComponents(x, z); + } + + public MutableBlockVector2() {} + + public MutableBlockVector2(int x, int z) { + super(x, z); + } + + @Override + public MutableBlockVector2 setComponents(int x, int z) { + this.x = x; + this.z = z; + return this; + } + + @Override + public MutableBlockVector2 mutX(double x) { + this.x = (int) x; + return this; + } + + @Override + public MutableBlockVector2 mutZ(double z) { + this.z = (int) z; + return this; + } + + @Override + public MutableBlockVector2 mutX(int x) { + this.x = x; + return this; + } + + @Override + public MutableBlockVector2 mutZ(int z) { + this.z = z; + return this; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2D.java deleted file mode 100644 index 09c3c4435..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2D.java +++ /dev/null @@ -1,594 +0,0 @@ -package com.sk89q.worldedit.math; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Comparator; - -import com.google.common.collect.ComparisonChain; -import com.sk89q.worldedit.math.transform.AffineTransform; - -/** - * A mutable rendition of WorldEdit's BlockVector2 class. - * This class should ONLY be used locally for efficient vector manipulation. - */ -public final class MutableBlockVector2D implements Serializable { - private static ThreadLocal MUTABLE_CACHE = new ThreadLocal() { - @Override - protected MutableBlockVector2D initialValue() { - return new MutableBlockVector2D(); - } - }; - - public static MutableBlockVector2D get(int x, int z) { - return MUTABLE_CACHE.get().setComponents(x, z); - } - - private transient int x, z; - - public MutableBlockVector2D() { - this(0, 0); - } - public static final MutableBlockVector2D ZERO = new MutableBlockVector2D(0, 0); - public static final MutableBlockVector2D UNIT_X = new MutableBlockVector2D(1, 0); - public static final MutableBlockVector2D UNIT_Z = new MutableBlockVector2D(0, 1); - public static final MutableBlockVector2D ONE = new MutableBlockVector2D(1, 1); - - /** - * A comparator for MutableBlockVector2Ds that orders the vectors by rows, with x as the - * column and z as the row. - * - * For example, if x is the horizontal axis and z is the vertical axis, it - * sorts like so: - * - *
-     * 0123
-     * 4567
-     * 90ab
-     * cdef
-     * 
- */ - public static final Comparator COMPARING_GRID_ARRANGEMENT = (a, b) -> { - return ComparisonChain.start() - .compare(a.getBlockZ(), b.getBlockZ()) - .compare(a.getBlockX(), b.getBlockX()) - .result(); - }; - - /** - * Construct an instance. - * - * @param vector - */ - public MutableBlockVector2D(BlockVector2 vector) { - this(vector.getBlockX(), vector.getBlockZ()); - } - - /** - * Construct an instance. - * - * @param x the X coordinate - * @param z the Z coordinate - */ - public MutableBlockVector2D(double x, double z) { - this((int) Math.floor(x), (int) Math.floor(z)); - } - - /** - * Construct an instance. - * - * @param x the X coordinate - * @param z the Z coordinate - */ - public MutableBlockVector2D(int x, int z) { - this.x = x; - this.z = z; - } - - /** - * Get the X coordinate. - * - * @return the x coordinate - */ - public int getX() { - return x; - } - - /** - * Get the X coordinate. - * - * @return the x coordinate - */ - public int getBlockX() { - return x; - } - - /** - * Get the Z coordinate. - * - * @return the z coordinate - */ - public int getZ() { - return z; - } - - /** - * Get the Z coordinate. - * - * @return the z coordinate - */ - public int getBlockZ() { - return z; - } - - /** - * Add another vector to this vector. - * - * @param other the other vector - * @return a new vector - */ - public MutableBlockVector2D add(MutableBlockVector2D other) { - return add(other.x, other.z); - } - - /** - * Add another vector to this vector. - * - * @param x the value to add - * @param z the value to add - * @return a new vector - */ - public MutableBlockVector2D add(int x, int z) { - this.x += x; - this.z += z; - return this; - } - - /** - * Add a list of vectors to this vector. - * - * @param others an array of vectors - * @return a new vector - */ - public MutableBlockVector2D add(MutableBlockVector2D... others) { - - for (MutableBlockVector2D other : others) { - x += other.x; - x += other.z; - } - - return this; - } - - /** - * Subtract another vector from this vector. - * - * @param other the other vector - * @return a new vector - */ - public MutableBlockVector2D subtract(MutableBlockVector2D other) { - return subtract(other.x, other.z); - } - - /** - * Subtract another vector from this vector. - * - * @param x the value to subtract - * @param z the value to subtract - * @return a new vector - */ - public MutableBlockVector2D subtract(int x, int z) { - this.x -= x; - this.z -= z; - return this; - } - - /** - * Subtract a list of vectors from this vector. - * - * @param others an array of vectors - * @return a new vector - */ - public MutableBlockVector2D subtract(MutableBlockVector2D... others) { - - for (MutableBlockVector2D other : others) { - x -= other.x; - z -= other.z; - } - - return this; - } - - /** - * Multiply this vector by another vector on each component. - * - * @param other the other vector - * @return a new vector - */ - public MutableBlockVector2D multiply(MutableBlockVector2D other) { - return multiply(other.x, other.z); - } - - /** - * Multiply this vector by another vector on each component. - * - * @param x the value to multiply - * @param z the value to multiply - * @return a new vector - */ - public MutableBlockVector2D multiply(int x, int z) { - this.x *= x; - this.z *= z; - return this; - } - - /** - * Multiply this vector by zero or more vectors on each component. - * - * @param others an array of vectors - * @return a new vector - */ - public MutableBlockVector2D multiply(MutableBlockVector2D... others) { - - for (MutableBlockVector2D other : others) { - x *= other.x; - z *= other.z; - } - - return this; - } - - /** - * Perform scalar multiplication. - * - * @param n the value to multiply - * @return a new vector - */ - public MutableBlockVector2D multiply(int n) { - return multiply(n, n); - } - - /** - * Divide this vector by another vector on each component. - * - * @param other the other vector - * @return a new vector - */ - public MutableBlockVector2D divide(MutableBlockVector2D other) { - return divide(other.x, other.z); - } - - /** - * Divide this vector by another vector on each component. - * - * @param x the value to divide by - * @param z the value to divide by - * @return a new vector - */ - public MutableBlockVector2D divide(int x, int z) { - this.x /= x; - this.z /= z; - return this; - } - - /** - * Perform scalar division. - * - * @param n the value to divide by - * @return a new vector - */ - public MutableBlockVector2D divide(int n) { - return divide(n, n); - } - - /** - * Get the length of the vector. - * - * @return length - */ - public double length() { - return Math.sqrt(lengthSq()); - } - - /** - * Get the length, squared, of the vector. - * - * @return length, squared - */ - public int lengthSq() { - return x * x + z * z; - } - - /** - * Get the distance between this vector and another vector. - * - * @param other the other vector - * @return distance - */ - public double distance(MutableBlockVector2D other) { - return Math.sqrt(distanceSq(other)); - } - - /** - * Get the distance between this vector and another vector, squared. - * - * @param other the other vector - * @return distance - */ - public int distanceSq(MutableBlockVector2D other) { - int dx = other.x - x; - int dz = other.z - z; - return dx * dx + dz * dz; - } - - /** - * Get the normalized vector, which is the vector divided by its - * length. - * - * @return a new vector - */ - public MutableBlockVector2D normalize() { - double len = length(); - this.x /= len; - this.z /= len; - return this; - } - - /** - * Gets the dot product of this and another vector. - * - * @param other the other vector - * @return the dot product of this and the other vector - */ - public int dot(MutableBlockVector2D other) { - return x * other.x + z * other.z; - } - - /** - * Checks to see if a vector is contained with another. - * - * @param min the minimum point (X, Y, and Z are the lowest) - * @param max the maximum point (X, Y, and Z are the lowest) - * @return true if the vector is contained - */ - public boolean containedWithin(MutableBlockVector2D min, MutableBlockVector2D max) { - return x >= min.x && x <= max.x - && z >= min.z && z <= max.z; - } - - /** - * Floors the values of all components. - * - * @return a new vector - */ - public MutableBlockVector2D floor() { - // already floored, kept for feature parity with Vector2 - return this; - } - - /** - * Rounds all components up. - * - * @return a new vector - */ - public MutableBlockVector2D ceil() { - // already raised, kept for feature parity with Vector2 - return this; - } - - /** - * Rounds all components to the closest integer. - * - *

Components < 0.5 are rounded down, otherwise up.

- * - * @return a new vector - */ - public MutableBlockVector2D round() { - // already rounded, kept for feature parity with Vector2 - return this; - } - - /** - * Returns a vector with the absolute values of the components of - * this vector. - * - * @return a new vector - */ - public MutableBlockVector2D abs() { - x = Math.abs(x); - z = Math.abs(z); - return this; - } - - /** - * Perform a 2D transformation on this vector. - * - * @param angle in degrees - * @param aboutX about which x coordinate to rotate - * @param aboutZ about which z coordinate to rotate - * @param translateX what to add after rotation - * @param translateZ what to add after rotation - * @return a new vector - * @see AffineTransform another method to transform vectors - */ - public MutableBlockVector2D transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { - angle = Math.toRadians(angle); - double x = this.x - aboutX; - double z = this.z - aboutZ; - double cos = Math.cos(angle); - double sin = Math.sin(angle); - double x2 = x * cos - z * sin; - double z2 = x * sin + z * cos; - this.x = (int) Math.floor(x2 + aboutX + translateX); - this.z = (int) Math.floor(z2 + aboutZ + translateZ); - return this; - } - - /** - * Gets the minimum components of two vectors. - * - * @param v2 the second vector - * @return minimum - */ - public MutableBlockVector2D getMinimum(MutableBlockVector2D v2) { - x = Math.min(x, v2.x); - z = Math.min(z, v2.z); - return this; - } - - /** - * Gets the maximum components of two vectors. - * - * @param v2 the second vector - * @return maximum - */ - public MutableBlockVector2D getMaximum(MutableBlockVector2D v2) { - x = Math.max(x, v2.x); - z = Math.max(z, v2.z); - return this; - } - - /** - * Creates a 2D vector from this vector. - * - * @return a new vector - */ - public Vector2 toVector2() { - return Vector2.at(x, z); - } - - /** - * Creates a 3D vector by adding a zero Y component to this vector. - * - * @return a new vector - */ - public Vector3 toVector3() { - return toVector3(0); - } - - /** - * Creates a 3D vector by adding the specified Y component to this vector. - * - * @param y the Y component - * @return a new vector - */ - public Vector3 toVector3(double y) { - return Vector3.at(x, y, z); - } - - /** - * Creates a 3D vector by adding a zero Y component to this vector. - * - * @return a new vector - */ - public BlockVector3 toBlockVector3() { - return toBlockVector3(0); - } - - /** - * Creates a 3D vector by adding the specified Y component to this vector. - * - * @param y the Y component - * @return a new vector - */ - public BlockVector3 toBlockVector3(int y) { - return BlockVector3.at(x, y, z); - } - - /** - * Creates a 2D vector from this vector. - * - * @return a new vector - */ - public BlockVector2 toBlockVector2() { - return BlockVector2.at(x, z); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof MutableBlockVector2D)) { - return false; - } - - MutableBlockVector2D other = (MutableBlockVector2D) obj; - return other.x == this.x && other.z == this.z; - - } - - @Override - public int hashCode() { - int hash = 17; - hash = 31 * hash + Integer.hashCode(x); - hash = 31 * hash + Integer.hashCode(z); - return hash; - } - - @Override - public String toString() { - return "Mutable (" + x + ", " + z + ")"; - } - - public MutableBlockVector2D setComponents(int x, int z) { - this.x = x; - this.z = z; - return this; - } - - public MutableBlockVector2D setComponents(double x, double z) { - return setComponents((int) x, (int) z); - } - - public final void mutX(int x) { - this.x = x; - } - - public void mutZ(int z) { - this.z = z; - } - - public final void mutX(double x) { - this.x = (int) x; - } - - public void mutZ(double z) { - this.z = (int) z; - } - - private void writeObject(java.io.ObjectOutputStream stream) throws IOException { - stream.writeInt(x); - stream.writeInt(z); - } - - private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { - this.x = stream.readInt(); - this.z = stream.readInt(); - } - - public MutableBlockVector2D nextPosition() { - int absX = Math.abs(x); - int absY = Math.abs(z); - if (absX > absY) { - if (x > 0) { - return setComponents(x, z + 1); - } else { - return setComponents(x, z - 1); - } - } else if (absY > absX) { - if (z > 0) { - return setComponents(x - 1, z); - } else { - return setComponents(x + 1, z); - } - } else { - if (x == z && x > 0) { - return setComponents(x, z + 1); - } - if (x == absX) { - return setComponents(x, z + 1); - } - if (z == absY) { - return setComponents(x, z - 1); - } - return setComponents(x + 1, z); - } - } -} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java new file mode 100644 index 000000000..89ee154f5 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java @@ -0,0 +1,73 @@ +package com.sk89q.worldedit.math; + +public class MutableBlockVector3 extends BlockVector3 { + + private static ThreadLocal MUTABLE_CACHE = new ThreadLocal() { + @Override + protected MutableBlockVector3 initialValue() { + return new MutableBlockVector3(); + } + }; + + public static MutableBlockVector3 get(int x, int y, int z) { + return MUTABLE_CACHE.get().setComponents(x, y, z); + } + + public MutableBlockVector3() {} + + public MutableBlockVector3(BlockVector3 other) { + super(other.getX(), other.getY(), other.getZ()); + } + + public MutableBlockVector3 setComponents(BlockVector3 other) { + return setComponents(other.getBlockX(), other.getBlockY(), other.getBlockZ()); + } + + public MutableBlockVector3(int x, int y, int z) { + super(x, y, z); + } + + @Override + public MutableBlockVector3 setComponents(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + return this; + } + + @Override + public MutableBlockVector3 mutX(double x) { + this.x = (int) x; + return this; + } + + @Override + public MutableBlockVector3 mutY(double y) { + this.y = (int) y; + return this; + } + + @Override + public MutableBlockVector3 mutZ(double z) { + this.z = (int) z; + return this; + } + + @Override + public final MutableBlockVector3 mutX(int x) { + this.x = x; + return this; + } + + @Override + public final MutableBlockVector3 mutY(int y) { + this.y = y; + return this; + } + + @Override + public final MutableBlockVector3 mutZ(int z) { + this.z = z; + return this; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector.java deleted file mode 100644 index fd4874de9..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector.java +++ /dev/null @@ -1,581 +0,0 @@ -package com.sk89q.worldedit.math; - -import com.sk89q.worldedit.math.transform.AffineTransform; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.io.IOException; -import java.io.Serializable; - -/** - * A mutable rendition of WorldEdit's Vector3 class. - * This class should ONLY be used locally for efficient vector manipulation. - */ - -public class MutableVector implements Serializable { - private transient double x, y, z; - - private static ThreadLocal MUTABLE_CACHE = new ThreadLocal() { - @Override - protected MutableVector initialValue() { - return new MutableVector(); - } - }; - - public static MutableVector get(double x, double y, double z) { - return MUTABLE_CACHE.get().setComponents(x, y, z); - } - - public MutableVector(Vector3 v) { - this(v.getX(), v.getY(), v.getZ()); - } - - public MutableVector(double x, double y, double z) { - this.x = x; - this.y = y; - this.z = z; - } - - public MutableVector() { - this(0, 0, 0); - } - - public MutableVector setComponents(Vector3 other) { - return setComponents(other.getX(), other.getY(), other.getZ()); - } - - public MutableVector setComponents(MutableVector mutable) { - return setComponents(mutable.getX(), mutable.getY(), mutable.getZ()); - } - - public MutableVector setComponents(int x, int y, int z) { - return this.setComponents((double) x, (double) y, (double) z); - } - - public MutableVector setComponents(double x, double y, double z) { - this.mutX(x); - this.mutY(y); - this.mutZ(z); - return this; - } - - public final void mutX(double x) { - this.x = y; - } - - public final void mutY(double y) { - this.y = y; - } - - public final void mutZ(double z) { - this.z = y; - } - - public final void mutX(int x) { - this.x = (double)x; - } - - public final void mutY(int y) { - this.y = (double)y; - } - - public final void mutZ(int z) { - this.z = (double)z; - } - - public final double getX() { - return x; - } - - public final double getY() { - return y; - } - - public final double getZ() { - return z; - } - - /** - * Add another vector to this vector and return the result as a new vector. - * - * @param other the other vector - * @return a new vector - */ - public MutableVector add(MutableVector other) { - return add(other.x, other.y, other.z); - } - - /** - * Add another vector to this vector and return the result as a new vector. - * - * @param x the value to add - * @param y the value to add - * @param z the value to add - * @return a new vector - */ - public MutableVector add(double x, double y, double z) { - this.x += x; - this.y += y; - this.z += z; - return this; - } - - /** - * Add a list of vectors to this vector and return the - * result as a new vector. - * - * @param others an array of vectors - * @return a new vector - */ - public MutableVector add(MutableVector... others) { - - for (MutableVector other : others) { - x += other.x; - y += other.y; - z += other.z; - } - - return this; - } - - /** - * Subtract another vector from this vector and return the result - * as a new vector. - * - * @param other the other vector - * @return a new vector - */ - public MutableVector subtract(MutableVector other) { - return subtract(other.x, other.y, other.z); - } - - /** - * Subtract another vector from this vector and return the result - * as a new vector. - * - * @param x the value to subtract - * @param y the value to subtract - * @param z the value to subtract - * @return a new vector - */ - public MutableVector subtract(double x, double y, double z) { - this.x -= x; - this.y -= y; - this.z -= z; - return this; - } - - /** - * Subtract a list of vectors from this vector and return the result - * as a new vector. - * - * @param others an array of vectors - * @return a new vector - */ - public MutableVector subtract(MutableVector... others) { - - for (MutableVector other : others) { - x -= other.x; - y -= other.y; - z -= other.z; - } - - return this; - } - - /** - * Multiply this vector by another vector on each component. - * - * @param other the other vector - * @return a new vector - */ - public MutableVector multiply(MutableVector other) { - return multiply(other.x, other.y, other.z); - } - - /** - * Multiply this vector by another vector on each component. - * - * @param x the value to multiply - * @param y the value to multiply - * @param z the value to multiply - * @return a new vector - */ - public MutableVector multiply(double x, double y, double z) { - this.x *= x; - this.y *= y; - this.z *= z; - return this; - } - - /** - * Multiply this vector by zero or more vectors on each component. - * - * @param others an array of vectors - * @return a new vector - */ - public MutableVector multiply(MutableVector... others) { - - for (MutableVector other : others) { - x *= other.x; - y *= other.y; - z *= other.z; - } - - return this; - } - - /** - * Perform scalar multiplication and return a new vector. - * - * @param n the value to multiply - * @return a new vector - */ - public MutableVector multiply(double n) { - return multiply(n, n, n); - } - - /** - * Divide this vector by another vector on each component. - * - * @param other the other vector - * @return a new vector - */ - public MutableVector divide(MutableVector other) { - return divide(other.x, other.y, other.z); - } - - /** - * Divide this vector by another vector on each component. - * - * @param x the value to divide by - * @param y the value to divide by - * @param z the value to divide by - * @return a new vector - */ - public MutableVector divide(double x, double y, double z) { - this.x /= x; - this.y /= y; - this.z /= z; - return this; - } - - /** - * Perform scalar division and return a new vector. - * - * @param n the value to divide by - * @return a new vector - */ - public MutableVector divide(double n) { - return divide(n, n, n); - } - - /** - * Get the length of the vector. - * - * @return length - */ - public double length() { - return Math.sqrt(lengthSq()); - } - - /** - * Get the length, squared, of the vector. - * - * @return length, squared - */ - public double lengthSq() { - return x * x + y * y + z * z; - } - - /** - * Get the distance between this vector and another vector. - * - * @param other the other vector - * @return distance - */ - public double distance(Vector3 other) { - return Math.sqrt(distanceSq(other)); - } - - /** - * Get the distance between this vector and another vector, squared. - * - * @param other the other vector - * @return distance - */ - public double distanceSq(Vector3 other) { - double dx = other.getX() - x; - double dy = other.getY() - y; - double dz = other.getZ() - z; - return dx * dx + dy * dy + dz * dz; - } - - /** - * Get the normalized vector, which is the vector divided by its - * length, as a new vector. - * - * @return a new vector - */ - public MutableVector normalize() { - return divide(length()); - } - - /** - * Gets the dot product of this and another vector. - * - * @param other the other vector - * @return the dot product of this and the other vector - */ - public double dot(MutableVector other) { - return x * other.x + y * other.y + z * other.z; - } - - /** - * Gets the cross product of this and another vector. - * - * @param other the other vector - * @return the cross product of this and the other vector - */ - public Vector3 cross(MutableVector other) { - return Vector3.at( - y * other.z - z * other.y, - z * other.x - x * other.z, - x * other.y - y * other.x - ); - } - - /** - * Checks to see if a vector is contained with another. - * - * @param min the minimum point (X, Y, and Z are the lowest) - * @param max the maximum point (X, Y, and Z are the lowest) - * @return true if the vector is contained - */ - public boolean containedWithin(MutableVector min, MutableVector max) { - return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z; - } - - /** - * Clamp the Y component. - * - * @param min the minimum value - * @param max the maximum value - * @return a new vector - */ - public MutableVector clampY(int min, int max) { - checkArgument(min <= max, "minimum cannot be greater than maximum"); - if (y < min) { - y = min; - } - if (y > max) { - y = max; - } - return this; - } - - /** - * Floors the values of all components. - * - * @return a new vector - */ - public MutableVector floor() { - x = Math.floor(x); - y = Math.floor(y); - z = Math.floor(z); - return this; - } - - /** - * Rounds all components up. - * - * @return a new vector - */ - public MutableVector ceil() { - x = Math.ceil(x); - y = Math.ceil(y); - z = Math.ceil(z); - return this; - } - - /** - * Rounds all components to the closest integer. - * - *

Components < 0.5 are rounded down, otherwise up.

- * - * @return a new vector - */ - public MutableVector round() { - x = Math.floor(x + 0.5); - y = Math.floor(y + 0.5); - z = Math.floor(z + 0.5); - return this; - } - - /** - * Returns a vector with the absolute values of the components of - * this vector. - * - * @return a new vector - */ - public MutableVector abs() { - x = Math.abs(x); - y = Math.abs(y); - z = Math.abs(z); - return this; - } - - /** - * Perform a 2D transformation on this vector and return a new one. - * - * @param angle in degrees - * @param aboutX about which x coordinate to rotate - * @param aboutZ about which z coordinate to rotate - * @param translateX what to add after rotation - * @param translateZ what to add after rotation - * @return a new vector - * @see AffineTransform another method to transform vectors - */ - public MutableVector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { - angle = Math.toRadians(angle); - double x = this.x - aboutX; - double z = this.z - aboutZ; - double cos = Math.cos(angle); - double sin = Math.sin(angle); - double x2 = x * cos - z * sin; - double z2 = x * sin + z * cos; - this.x = x2 + aboutX + translateX; - this.z = z2 + aboutZ + translateZ; - return this; - } - - /** - * Get this vector's pitch as used within the game. - * - * @return pitch in radians - */ - public double toPitch() { - double x = getX(); - double z = getZ(); - - if (x == 0 && z == 0) { - return getY() > 0 ? -90 : 90; - } else { - double x2 = x * x; - double z2 = z * z; - double xz = Math.sqrt(x2 + z2); - return Math.toDegrees(Math.atan(-getY() / xz)); - } - } - - /** - * Get this vector's yaw as used within the game. - * - * @return yaw in radians - */ - public double toYaw() { - double x = getX(); - double z = getZ(); - - double t = Math.atan2(-x, z); - double tau = 2 * Math.PI; - - return Math.toDegrees(((t + tau) % tau)); - } - - /** - * Gets the minimum components of two vectors. - * - * @param v2 the second vector - * @return minimum - */ - public MutableVector getMinimum(MutableVector v2) { - x = Math.min(x, v2.x); - y = Math.min(y, v2.y); - z = Math.min(z, v2.z); - return this; - } - - /** - * Gets the maximum components of two vectors. - * - * @param v2 the second vector - * @return maximum - */ - public MutableVector getMaximum(MutableVector v2) { - x = Math.max(x, v2.x); - y = Math.max(y, v2.y); - z = Math.max(z, v2.z); - return this; - } - - /** - * Create a new {@code BlockVector} using the given components. - * - * @param x the X coordinate - * @param y the Y coordinate - * @param z the Z coordinate - * @return a new {@code BlockVector} - */ - public static BlockVector3 toBlockPoint(double x, double y, double z) { - return BlockVector3.at(x, y, z); - } - - /** - * Create a new {@code BlockVector} from this vector. - * - * @return a new {@code BlockVector} - */ - public BlockVector3 toBlockPoint() { - return toBlockPoint(x, y, z); - } - - /** - * Creates a 2D vector by dropping the Y component from this vector. - * - * @return a new {@link Vector2} - */ - public Vector2 toVector2() { - return Vector2.at(x, z); - } - - public Vector3 toVector3() { - return Vector3.at(x, y, z); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof MutableVector)) { - return false; - } - - MutableVector other = (MutableVector) obj; - return other.x == this.x && other.y == this.y && other.z == this.z; - } - - @Override - public int hashCode() { - int hash = 17; - hash = 31 * hash + Double.hashCode(x); - hash = 31 * hash + Double.hashCode(y); - hash = 31 * hash + Double.hashCode(z); - return hash; - } - - @Override - public String toString() { - return "Mutable (" + x + ", " + y + ", " + z + ")"; - } - - private void writeObject(java.io.ObjectOutputStream stream) throws IOException { - stream.writeDouble(x); - stream.writeByte((byte) y); - stream.writeDouble(z); - } - - private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { - this.x = stream.readDouble(); - this.y = stream.readByte() & 0xFF; - this.z = stream.readDouble(); - } -} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector2.java new file mode 100644 index 000000000..4b4133d5c --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector2.java @@ -0,0 +1,70 @@ +package com.sk89q.worldedit.math; + +import java.io.Serializable; + +public class MutableVector2 extends Vector2 { + public MutableVector2() {} + + /** + * Construct an instance. + * + * @param x the X coordinate + * @param z the Z coordinate + */ + public MutableVector2(double x, double z) { + super(x, z); + } + + /** + * Construct an instance. + * + * @param x the X coordinate + * @param z the Z coordinate + */ + public MutableVector2(float x, float z) { + super(x, z); + } + + /** + * Copy another vector. + * + * @param other the other vector + */ + public MutableVector2(Vector2 other) { + super(other); + } + + @Override + public MutableVector2 setComponents(int x, int z) { + this.x = x; + this.z = z; + return this; + } + + @Override + public MutableVector2 setComponents(double x, double z) { + this.x = x; + this.z = z; + return this; + } + @Override + public MutableVector2 mutX(int x) { + this.x = x; + return this; + } + @Override + public MutableVector2 mutZ(int z) { + this.z = z; + return this; + } + @Override + public MutableVector2 mutX(double x) { + this.x = x; + return this; + } + @Override + public MutableVector2 mutZ(double z) { + this.z = z; + return this; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java new file mode 100644 index 000000000..e1810a4b6 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java @@ -0,0 +1,82 @@ +package com.sk89q.worldedit.math; + +import javax.annotation.Nullable; + +public class MutableVector3 extends Vector3 { + + public MutableVector3() {} + + public MutableVector3(double x, double y, double z) { + super(x, y, z); + } + + public MutableVector3(float x, float y, float z) { + super(x, y, z); + } + + public MutableVector3(Vector3 other) { + super(other); + } + + @Override + public MutableVector3 setComponents(Vector3 other) { + this.x = other.x; + this.y = other.y; + this.z = other.z; + return this; + } + + @Override + public MutableVector3 setComponents(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + return this; + } + + @Override + public MutableVector3 setComponents(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + return this; + } + + @Override + public MutableVector3 mutX(int x) { + this.x = x; + return this; + } + @Override + public MutableVector3 mutZ(int z) { + this.z = z; + return this; + } + @Override + public MutableVector3 mutX(double x) { + this.x = x; + return this; + } + + @Override + public MutableVector3 mutZ(double z) { + this.z = z; + return this; + } + + @Override + public MutableVector3 mutY(int y) { + this.y = y; + return this; + } + + @Override + public MutableVector3 mutY(double y) { + this.y = y; + return this; + } + + public double getY() { + return y; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java index 5960e74f7..1950ff9e2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java @@ -19,12 +19,13 @@ package com.sk89q.worldedit.math; +import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.math.transform.AffineTransform; /** * An immutable 2-dimensional vector. */ -public final class Vector2 { +public class Vector2 { public static final Vector2 ZERO = new Vector2(0, 0); public static final Vector2 UNIT_X = new Vector2(1, 0); @@ -32,23 +33,12 @@ public final class Vector2 { public static final Vector2 ONE = new Vector2(1, 1); public static Vector2 at(double x, double z) { - int xTrunc = (int) x; - switch (xTrunc) { - case 0: - if (x == 0 && z == 0) { - return ZERO; - } - break; - case 1: - if (x == 1 && z == 1) { - return ONE; - } - break; - } return new Vector2(x, z); } - private final double x, z; + protected double x, z; + + protected Vector2(){} /** * Construct an instance. @@ -56,11 +46,48 @@ public final class Vector2 { * @param x the X coordinate * @param z the Z coordinate */ - private Vector2(double x, double z) { + protected Vector2(double x, double z) { this.x = x; this.z = z; } + protected Vector2(Vector2 other) { + this.x = other.x; + this.z = other.z; + } + + public int getBlockX() { + return MathMan.roundInt(getX()); + } + + public int getBlockZ() { + return MathMan.roundInt(getZ()); + } + + public MutableVector2 setComponents(int x, int z) { + return new MutableVector2(x, z); + } + + public MutableVector2 setComponents(double x, double z) { + return new MutableVector2(x, z); + } + + public MutableVector2 mutX(int x) { + return new MutableVector2(x, z); + } + + public MutableVector2 mutZ(int z) { + return new MutableVector2(x, z); + } + + public MutableVector2 mutX(double x) { + return new MutableVector2(x, z); + } + + public MutableVector2 mutZ(double z) { + return new MutableVector2(x, z); + } + /** * Get the X coordinate. * @@ -458,21 +485,18 @@ public final class Vector2 { } Vector2 other = (Vector2) obj; - return other.x == this.x && other.z == this.z; + return other.getX() == this.getX() && other.getZ() == this.getZ(); } @Override public int hashCode() { - int hash = 17; - hash = 31 * hash + Double.hashCode(x); - hash = 31 * hash + Double.hashCode(z); - return hash; + return ((int) getX() ^ ((int) getZ() << 16)); } @Override public String toString() { - return "(" + x + ", " + z + ")"; + return "(" + getX() + ", " + getZ() + ")"; } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java index 392478aa3..172a75687 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java @@ -21,9 +21,11 @@ package com.sk89q.worldedit.math; import static com.google.common.base.Preconditions.checkArgument; +import com.boydti.fawe.util.MathMan; import com.google.common.collect.ComparisonChain; import com.sk89q.worldedit.math.transform.AffineTransform; +import javax.annotation.Nullable; import java.util.Comparator; /** @@ -38,21 +40,6 @@ public class Vector3 { public static final Vector3 ONE = new Vector3(1, 1, 1); public static Vector3 at(double x, double y, double z) { - // switch for efficiency on typical cases - // in MC y is rarely 0/1 on selections - int yTrunc = (int) y; - switch (yTrunc) { - case 0: - if (x == 0 && y == 0 && z == 0) { - return ZERO; - } - break; - case 1: - if (x == 1 && y == 1 && z == 1) { - return ONE; - } - break; - } return new Vector3(x, y, z); } @@ -77,7 +64,7 @@ public class Vector3 { return YzxOrderComparator.YZX_ORDER; } - private final double x, y, z; + protected double x, y, z; /** * Construct an instance. @@ -86,12 +73,68 @@ public class Vector3 { * @param y the Y coordinate * @param z the Z coordinate */ - private Vector3(double x, double y, double z) { + protected Vector3(double x, double y, double z) { this.x = x; this.y = y; this.z = z; } + protected Vector3() {} + + protected Vector3(Vector3 other) { + this.x = other.x; + this.y = other.y; + this.z = other.z; + } + + public int getBlockX() { + return MathMan.roundInt(getX()); + } + + public int getBlockY() { + return MathMan.roundInt(getY()); + } + + public int getBlockZ() { + return MathMan.roundInt(getZ()); + } + + public MutableVector3 setComponents(Vector3 other) { + return new MutableVector3(other); + } + + public MutableVector3 setComponents(int x, int y, int z) { + return new MutableVector3(x, y, z); + } + + public MutableVector3 setComponents(double x, double y, double z) { + return new MutableVector3(x, y, z); + } + + public MutableVector3 mutX(int x) { + return new MutableVector3(x, y, getZ()); + } + + public MutableVector3 mutX(double x) { + return new MutableVector3(x, y, getZ()); + } + + public MutableVector3 mutY(int y) { + return new MutableVector3(getX(), y, getZ()); + } + + public MutableVector3 mutY(double y) { + return new MutableVector3(getX(), y, getZ()); + } + + public MutableVector3 mutZ(int z) { + return new MutableVector3(getX(), y, z); + } + + public MutableVector3 mutZ(double z) { + return new MutableVector3(getX(), y, z); + } + /** * Get the X coordinate. * @@ -579,25 +622,25 @@ public class Vector3 { @Override public boolean equals(Object obj) { + if (obj == this) return true; if (!(obj instanceof Vector3)) { return false; } Vector3 other = (Vector3) obj; - return other.x == this.x && other.y == this.y && other.z == this.z; + return other.getX() == this.getX() && other.getZ() == this.getZ() && other.getY() == this.getY(); } @Override public int hashCode() { - int hash = 17; - hash = 31 * hash + Double.hashCode(x); - hash = 31 * hash + Double.hashCode(y); - hash = 31 * hash + Double.hashCode(z); - return hash; + return ((int) getX() ^ ((int) getZ() << 16)) ^ ((int) getY() << 30); } @Override public String toString() { + String x = (getX() == getBlockX() ? "" + getBlockX() : "" + getX()); + String y = (getY() == getBlockY() ? "" + getBlockY() : "" + getY()); + String z = (getZ() == getBlockZ() ? "" + getBlockZ() : "" + getZ()); return "(" + x + ", " + y + ", " + z + ")"; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java index e8e79f676..b5447ed5e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java @@ -23,7 +23,7 @@ package com.sk89q.worldedit.math.interpolation; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector3; import java.util.Collections; @@ -139,7 +139,7 @@ public class KochanekBartelsInterpolation implements Interpolation { return nodes.get(index).getPosition(); } - private MutableBlockVector mutable = new MutableBlockVector(); + private MutableBlockVector3 mutable = new MutableBlockVector3(); @Override public Vector3 getPosition(double position) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java index ee7b973e3..5223ca718 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java @@ -5,7 +5,7 @@ import java.io.Serializable; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MathUtils; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector3; /** @@ -17,7 +17,7 @@ import com.sk89q.worldedit.math.Vector3; */ public class AffineTransform implements Transform, Serializable { - private transient MutableBlockVector mutable = new MutableBlockVector(); + private transient MutableBlockVector3 mutable = new MutableBlockVector3(); /** * coefficients for x coordinate. @@ -324,7 +324,7 @@ public class AffineTransform implements Transform, Serializable { private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); - mutable = new MutableBlockVector(); + mutable = new MutableBlockVector3(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java index 8ae246ccd..7ba7abb25 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java @@ -5,7 +5,7 @@ import com.sk89q.worldedit.math.Vector3; public class RoundedTransform implements Transform{ private final Transform transform; -// private MutableBlockVector mutable = new MutableBlockVector(); +// private MutableBlockVector3 mutable = new MutableBlockVector3(); public RoundedTransform(Transform transform) { this.transform = transform; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java index 5d0412259..828f8b7ea 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java @@ -43,7 +43,7 @@ public final class Transforms { public static Location transform(Location location, Transform transform) { checkNotNull(location); checkNotNull(transform); - return new Location(location.getExtent(), transform.apply(location.toVector()), location.getDirection()); + return new Location(location.getExtent(), transform.apply(location), location.getDirection()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 50f737032..5ead3a841 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -20,17 +20,14 @@ package com.sk89q.worldedit.regions; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.collection.LocalBlockVectorSet; -import com.sk89q.worldedit.*; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.util.Location; + import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector; -import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.MutableBlockVector3; +import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.ChunkStore; @@ -320,7 +317,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public Iterator iterator() { return new Iterator() { - private MutableBlockVector2D pos = new MutableBlockVector2D().setComponents(maxX + 1, maxZ); + private MutableBlockVector2 pos = new MutableBlockVector2().setComponents(maxX + 1, maxZ); @Override public boolean hasNext() { @@ -329,7 +326,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public BlockVector2 next() { - MutableBlockVector2D result = pos; + MutableBlockVector2 result = pos; // calc next pos.setComponents(pos.getX() - 1, pos.getZ()); if (pos.getX() <= minX) { @@ -339,7 +336,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { pos.setComponents(maxX, pos.getZ() - 1); } } - return result.toBlockVector2(); + return result; } @Override @@ -437,7 +434,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return iterator_old(); } return new Iterator() { - final MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); + final MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); private BlockVector3 min = getMinimumPoint(); private BlockVector3 max = getMaximumPoint(); @@ -492,7 +489,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { x = tx; y = ty; hasNext = false; - return mutable.toBlockVector3(); + return mutable; } } else { z = cbz; @@ -521,13 +518,13 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { x = cbx; } } - return mutable.toBlockVector3(); + return mutable; } }; } public Iterator iterator_old() { - final MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); + final MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); return new Iterator() { private BlockVector3 min = getMinimumPoint(); private BlockVector3 max = getMaximumPoint(); @@ -573,7 +570,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } } } - return mutable.toBlockVector3(); + return mutable; } }; } @@ -583,7 +580,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return new Iterable() { @Override public Iterator iterator() { - MutableBlockVector2D mutable = new MutableBlockVector2D(); + MutableBlockVector2 mutable = new MutableBlockVector2(); return new Iterator() { private BlockVector3 min = getMinimumPoint(); private BlockVector3 max = getMaximumPoint(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java index 66b6241e6..9524874f2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java @@ -306,7 +306,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { double dz = Math.abs(pz - center.getBlockZ()) * radiusInverse.getZ(); return dx * dx + dz * dz <= 1; -// return position.toBlockVector2().subtract(center).toVector2().divide(radius).lengthSq() <= 1; +// return position.subtract(center).toVector2().divide(radius).lengthSq() <= 1; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index d61b5bf53..f7c209a14 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -20,7 +20,7 @@ package com.sk89q.worldedit.regions; -import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java index 1d1416f67..ed3d1f6af 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java @@ -23,12 +23,13 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; public class WorldEditExpressionEnvironment implements ExpressionEnvironment { private final Vector3 unit; private final Vector3 zero2; - private Vector3 current = Vector3.ZERO; + private Vector3 current = new MutableVector3(Vector3.ZERO); private EditSession editSession; private Extent extent; @@ -81,6 +82,10 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment { return extent.getBlock(toWorld(x, y, z)).getBlockType().getLegacyCombinedId() & 0xF; } + public void setCurrentBlock(int x, int y, int z) { + current.setComponents(x, y, z); + } + public void setCurrentBlock(Vector3 current) { this.current = current; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java index 9fffc98a9..c63a6b6bb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java @@ -34,10 +34,9 @@ import com.sk89q.worldedit.math.Vector3; * {@link #equals(Object)} are subject to minor differences caused by * floating point errors.

*/ -public class Location{ +public class Location extends Vector3 { private final Extent extent; - private final Vector3 position; private final float pitch; private final float yaw; @@ -127,10 +126,10 @@ public class Location{ */ public Location(Extent extent, Vector3 position, float yaw, float pitch) { + super(position); checkNotNull(extent); checkNotNull(position); this.extent = extent; - this.position = position; this.pitch = pitch; this.yaw = yaw; } @@ -151,7 +150,7 @@ public class Location{ * @return the new instance */ public Location setExtent(Extent extent) { - return new Location(extent, position, getDirection()); + return new Location(extent, this, getDirection()); } /** @@ -170,7 +169,7 @@ public class Location{ * @return the new instance */ public Location setYaw(float yaw) { - return new Location(extent, position, yaw, pitch); + return new Location(extent, this, yaw, pitch); } /** @@ -189,7 +188,7 @@ public class Location{ * @return the new instance */ public Location setPitch(float pitch) { - return new Location(extent, position, yaw, pitch); + return new Location(extent, this, yaw, pitch); } /** @@ -200,7 +199,7 @@ public class Location{ * @return the new instance */ public Location setDirection(float yaw, float pitch) { - return new Location(extent, position, yaw, pitch); + return new Location(extent, this, yaw, pitch); } /** @@ -234,7 +233,7 @@ public class Location{ * @return the new instance */ public Location setDirection(Vector3 direction) { - return new Location(extent, position, (float) direction.toYaw(), (float) direction.toPitch()); + return new Location(extent, this, (float) direction.toYaw(), (float) direction.toPitch()); } /** @@ -242,8 +241,8 @@ public class Location{ * * @return a vector */ - public Vector3 toVector() { - return position; + public Vector3 vector() { + return this; } /** @@ -252,7 +251,7 @@ public class Location{ * @return the X component */ public double getX() { - return position.getX(); + return this.getX(); } /** @@ -261,7 +260,7 @@ public class Location{ * @return the rounded X component */ public int getBlockX() { - return (int) Math.floor(position.getX()); + return (int) Math.floor(this.getX()); } /** @@ -272,7 +271,7 @@ public class Location{ * @return a new immutable instance */ public Location setX(double x) { - return new Location(extent, position.withX(x), yaw, pitch); + return new Location(extent, this.withX(x), yaw, pitch); } /** @@ -281,7 +280,7 @@ public class Location{ * @return the Y component */ public double getY() { - return position.getY(); + return this.getY(); } /** @@ -290,7 +289,7 @@ public class Location{ * @return the rounded Y component */ public int getBlockY() { - return (int) Math.floor(position.getY()); + return (int) Math.floor(this.getY()); } /** @@ -301,7 +300,7 @@ public class Location{ * @return a new immutable instance */ public Location setY(double y) { - return new Location(extent, position.withY(y), yaw, pitch); + return new Location(extent, this.withY(y), yaw, pitch); } /** @@ -310,7 +309,7 @@ public class Location{ * @return the Z component */ public double getZ() { - return position.getZ(); + return this.getZ(); } /** @@ -319,7 +318,7 @@ public class Location{ * @return the rounded Z component */ public int getBlockZ() { - return (int) Math.floor(position.getZ()); + return (int) Math.floor(this.getZ()); } /** @@ -330,7 +329,7 @@ public class Location{ * @return a new immutable instance */ public Location setZ(double z) { - return new Location(extent, position.withZ(z), yaw, pitch); + return new Location(extent, this.withZ(z), yaw, pitch); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java index 715eb68dd..3de20a41e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.util; -import com.sk89q.worldedit.*; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; @@ -49,7 +48,7 @@ public class TargetBlock { */ public TargetBlock(Player player) { this.world = player.getWorld(); - this.setValues(player.getLocation().toVector(), player.getLocation().getYaw(), player.getLocation().getPitch(), 300, 1.65, 0.2); + this.setValues(player.getLocation(), player.getLocation().getYaw(), player.getLocation().getPitch(), 300, 1.65, 0.2); } /** @@ -61,7 +60,7 @@ public class TargetBlock { */ public TargetBlock(Player player, int maxDistance, double checkDistance) { this.world = player.getWorld(); - this.setValues(player.getLocation().toVector(), player.getLocation().getYaw(), player.getLocation().getPitch(), maxDistance, 1.65, checkDistance); + this.setValues(player.getLocation(), player.getLocation().getYaw(), player.getLocation().getPitch(), maxDistance, 1.65, checkDistance); } /** @@ -189,12 +188,12 @@ public class TargetBlock { public Location getAnyTargetBlockFace() { getAnyTargetBlock(); - return getCurrentBlock().setDirection(getCurrentBlock().toVector().subtract(getPreviousBlock().toVector())); + return getCurrentBlock().setDirection(getCurrentBlock().subtract(getPreviousBlock())); } public Location getTargetBlockFace() { getAnyTargetBlock(); - return getCurrentBlock().setDirection(getCurrentBlock().toVector().subtract(getPreviousBlock().toVector())); + return getCurrentBlock().setDirection(getCurrentBlock().subtract(getPreviousBlock())); } } diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/util/LocationTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/util/LocationTest.java index 50dfa649e..0dfd618df 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/util/LocationTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/util/LocationTest.java @@ -56,7 +56,7 @@ public class LocationTest { World world = mock(World.class); Vector3 position = Vector3.at(1, 1, 1); Location location = new Location(world, position); - assertEquals(position, location.toVector()); + assertEquals(position, location); } @Test