From 4d6045813c6bce1fc5265211b1eedd69e3633fc7 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Fri, 19 Oct 2018 13:13:32 -0700 Subject: [PATCH] Move vectors to static creators, for caching --- build.gradle | 2 +- .../bukkit/filter/GriefPreventionFilter.java | 4 +- .../fawe/bukkit/filter/WorldGuardFilter.java | 8 +- .../bukkit/listener/BukkitImageListener.java | 2 +- .../bukkit/listener/CFIPacketListener.java | 12 +-- .../fawe/bukkit/regions/BukkitMask.java | 2 +- .../fawe/bukkit/regions/FreeBuildRegion.java | 2 +- .../bukkit/regions/PreciousStonesFeature.java | 4 +- .../fawe/bukkit/regions/Worldguard.java | 2 +- .../fawe/bukkit/util/cui/StructureCUI.java | 4 +- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 2 +- .../sk89q/worldedit/bukkit/BukkitWorld.java | 2 +- .../EditSessionBlockChangeDelegate.java | 6 +- .../bukkit/adapter/IBukkitAdapter.java | 4 +- .../fawe/command/FawePrimitiveBinding.java | 4 +- .../fawe/jnbt/CorruptSchematicStreamer.java | 12 +-- .../boydti/fawe/jnbt/SchematicStreamer.java | 16 ++-- .../jnbt/anvil/HeightMapMCAGenerator.java | 16 ++-- .../com/boydti/fawe/object/FaweQueue.java | 4 +- .../com/boydti/fawe/object/HistoryExtent.java | 2 +- .../com/boydti/fawe/object/RegionWrapper.java | 2 +- .../boydti/fawe/object/brush/CircleBrush.java | 2 +- .../boydti/fawe/object/brush/ErodeBrush.java | 2 +- .../boydti/fawe/object/brush/HeightBrush.java | 8 +- .../boydti/fawe/object/brush/SplineBrush.java | 8 +- .../fawe/object/brush/SurfaceSpline.java | 2 +- .../fawe/object/brush/sweep/Spline.java | 4 +- .../clipboard/CPUOptimizedClipboard.java | 2 +- .../clipboard/DiskOptimizedClipboard.java | 6 +- .../clipboard/MemoryOptimizedClipboard.java | 2 +- .../clipboard/ResizableClipboardBuilder.java | 4 +- .../collection/LocalBlockVector2DSet.java | 2 +- .../collection/LocalBlockVectorSet.java | 2 +- .../boydti/fawe/object/extent/NullExtent.java | 4 +- .../extent/PositionTransformExtent.java | 2 +- .../fawe/object/extent/ScaleTransform.java | 2 +- .../fawe/object/extent/TransformExtent.java | 2 +- .../fawe/object/pattern/OffsetPattern.java | 4 +- .../fawe/object/pattern/PatternExtent.java | 8 +- .../pattern/RandomFullClipboardPattern.java | 2 +- .../object/queue/FaweQueueDelegateExtent.java | 2 +- .../fawe/object/regions/FuzzyRegion.java | 6 +- .../boydti/fawe/object/regions/Triangle.java | 6 +- .../fawe/object/schematic/Schematic.java | 2 +- .../object/schematic/StructureFormat.java | 2 +- .../object/schematic/visualizer/SchemVis.java | 16 ++-- .../fawe/object/visitor/AboveVisitor.java | 12 +-- .../fawe/object/visitor/DFSVisitor.java | 16 ++-- .../general/plot/FaweChunkManager.java | 10 +-- .../general/plot/FaweSchematicHandler.java | 2 +- .../general/plot/PlotRegionFilter.java | 2 +- .../regions/general/plot/PlotSetBiome.java | 2 +- .../general/plot/PlotSquaredFeature.java | 4 +- .../boydti/fawe/wrappers/PlayerWrapper.java | 12 +-- .../main/java/com/sk89q/jnbt/NBTUtils.java | 2 +- .../java/com/sk89q/util/yaml/YAMLNode.java | 10 +-- .../com/sk89q/worldedit/CuboidClipboard.java | 4 +- .../java/com/sk89q/worldedit/EditSession.java | 82 +++++++++---------- .../com/sk89q/worldedit/LocalSession.java | 2 +- .../com/sk89q/worldedit/PlayerDirection.java | 20 ++--- .../worldedit/command/ChunkCommands.java | 2 +- .../command/FlattenedClipboardTransform.java | 4 +- .../worldedit/command/HistoryCommands.java | 2 +- .../sk89q/worldedit/command/MaskCommands.java | 6 +- .../worldedit/command/RegionCommands.java | 6 +- .../worldedit/command/SelectionCommands.java | 28 +++---- .../extension/factory/DefaultMaskParser.java | 4 +- .../platform/AbstractPlayerActor.java | 34 ++++---- .../extent/AbstractDelegateExtent.java | 4 +- .../com/sk89q/worldedit/extent/Extent.java | 6 +- .../sk89q/worldedit/extent/MaskingExtent.java | 2 +- .../sk89q/worldedit/extent/NullExtent.java | 2 +- .../extent/buffer/ForgetfulExtentBuffer.java | 1 - .../extent/cache/LastAccessExtentCache.java | 1 - .../extent/clipboard/BlockArrayClipboard.java | 4 +- .../clipboard/io/MCEditSchematicReader.java | 8 +- .../clipboard/io/SpongeSchematicReader.java | 58 +++++++++++-- .../clipboard/io/SpongeSchematicWriter.java | 4 +- .../extent/reorder/ChunkBatchingExtent.java | 2 +- .../extent/world/FastModeExtent.java | 2 +- .../extent/world/SurvivalModeExtent.java | 2 +- .../function/entity/ExtentEntityCopy.java | 4 + .../operation/BackwardsExtentBlockCopy.java | 8 +- .../function/operation/ForwardExtentCopy.java | 5 +- .../function/pattern/ClipboardPattern.java | 2 +- .../worldedit/function/pattern/Pattern.java | 2 +- .../pattern/RepeatingExtentPattern.java | 6 +- .../function/visitor/BreadthFirstSearch.java | 58 ++++++++++--- .../function/visitor/DirectionalVisitor.java | 12 +-- .../function/visitor/DownwardVisitor.java | 10 +-- .../function/visitor/NonRisingVisitor.java | 10 +-- .../expression/runtime/Functions.java | 6 +- .../sk89q/worldedit/math/BlockVector2.java | 62 ++++++++------ .../sk89q/worldedit/math/BlockVector3.java | 69 +++++++++------- .../com/sk89q/worldedit/math/MathUtils.java | 4 +- .../worldedit/math/MutableBlockVector.java | 6 +- .../worldedit/math/MutableBlockVector2D.java | 8 +- .../sk89q/worldedit/math/MutableVector.java | 8 +- .../com/sk89q/worldedit/math/Vector2.java | 61 ++++++++------ .../com/sk89q/worldedit/math/Vector3.java | 68 ++++++++------- .../worldedit/math/convolution/HeightMap.java | 17 ++-- .../sk89q/worldedit/math/geom/Polygons.java | 2 +- .../worldedit/math/interpolation/Node.java | 2 +- .../math/transform/AffineTransform.java | 2 +- .../math/transform/RoundedTransform.java | 2 +- .../worldedit/regions/AbstractRegion.java | 16 ++-- .../sk89q/worldedit/regions/CuboidRegion.java | 28 ++++++- .../worldedit/regions/CylinderRegion.java | 4 +- .../worldedit/regions/EllipsoidRegion.java | 6 +- .../worldedit/regions/Polygonal2DRegion.java | 9 +- .../factory/CylinderRegionFactory.java | 2 +- .../regions/factory/SphereRegionFactory.java | 2 +- .../iterator/FlatRegion3DIterator.java | 2 +- .../regions/iterator/FlatRegionIterator.java | 4 +- .../regions/iterator/RegionIterator.java | 4 +- .../ExtendingCuboidRegionSelector.java | 4 +- .../selector/Polygonal2DRegionSelector.java | 4 +- .../selector/SphereRegionSelector.java | 6 +- .../worldedit/regions/shape/RegionShape.java | 2 +- .../shape/WorldEditExpressionEnvironment.java | 2 +- .../com/sk89q/worldedit/util/Direction.java | 38 ++++----- .../com/sk89q/worldedit/util/Location.java | 8 +- .../com/sk89q/worldedit/util/TargetBlock.java | 2 +- .../worldedit/util/gson/VectorAdapter.java | 2 +- .../sk89q/worldedit/world/AbstractWorld.java | 4 +- .../sk89q/worldedit/world/SimpleWorld.java | 4 +- .../worldedit/world/chunk/AnvilChunk.java | 2 +- .../worldedit/world/chunk/AnvilChunk13.java | 2 +- .../sk89q/worldedit/world/chunk/OldChunk.java | 2 +- .../world/snapshot/SnapshotRestore.java | 2 +- .../worldedit/world/storage/ChunkStore.java | 2 +- .../sk89q/worldedit/util/LocationTest.java | 14 ++-- .../sk89q/worldedit/forge/ForgeAdapter.java | 4 +- .../sk89q/worldedit/forge/ForgeEntity.java | 2 +- .../sk89q/worldedit/forge/ForgePlayer.java | 2 +- .../com/sk89q/worldedit/forge/ForgeWorld.java | 2 +- .../sk89q/worldedit/sponge/SpongeWorld.java | 2 +- .../sponge/adapter/SpongeImplAdapter.java | 2 +- 138 files changed, 670 insertions(+), 531 deletions(-) diff --git a/build.gradle b/build.gradle index d0a7d4a2d..cde21d5e3 100644 --- a/build.gradle +++ b/build.gradle @@ -69,7 +69,7 @@ subprojects { repositories { mavenCentral() - maven { url "http://ci.athion.net/job/FAWE-WorldGuard-1.13/ws/mvn/" } + //maven { url "http://ci.athion.net/job/FAWE-WorldGuard-1.13/ws/mvn/" } maven { url "http://repo.bukkit.org/content/groups/public" } maven { url "http://maven.sk89q.com/repo/" } maven { url "http://repo.maven.apache.org/maven2" } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java index 0b0ff34ef..3496933e9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java @@ -35,8 +35,8 @@ public class GriefPreventionFilter extends CuboidRegionFilter { org.bukkit.Location bot = claim.getGreaterBoundaryCorner(); if (world.equals(bot.getWorld())) { org.bukkit.Location top = claim.getGreaterBoundaryCorner(); - BlockVector2 pos1 = new BlockVector2(bot.getBlockX(), bot.getBlockZ()); - BlockVector2 pos2 = new BlockVector2(top.getBlockX(), top.getBlockZ()); + BlockVector2 pos1 = BlockVector2.at(bot.getBlockX(), bot.getBlockZ()); + BlockVector2 pos2 = BlockVector2.at(top.getBlockX(), top.getBlockZ()); add(pos1, pos2); } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java index 2925b4842..b195a9368 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java @@ -49,8 +49,8 @@ public class WorldGuardFilter extends CuboidRegionFilter { @Override public boolean containsChunk(int chunkX, int chunkZ) { if (!large) return super.containsChunk(chunkX, chunkZ); - BlockVector3 pos1 = new BlockVector3(chunkX << 4, 0, chunkZ << 4); - BlockVector3 pos2 = new BlockVector3(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15); + BlockVector3 pos1 = BlockVector3.at(chunkX << 4, 0, chunkZ << 4); + BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15); ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2); ApplicableRegionSet set = manager.getApplicableRegions(chunkRegion); return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__"); @@ -59,8 +59,8 @@ public class WorldGuardFilter extends CuboidRegionFilter { @Override public boolean containsRegion(int mcaX, int mcaZ) { if (!large) return super.containsRegion(mcaX, mcaZ); - BlockVector3 pos1 = new BlockVector3(mcaX << 9, 0, mcaZ << 9); - BlockVector3 pos2 = new BlockVector3(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511); + BlockVector3 pos1 = BlockVector3.at(mcaX << 9, 0, mcaZ << 9); + BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511); ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2); ApplicableRegionSet set = manager.getApplicableRegions(regionRegion); return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__"); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java index ebc9f77ad..00ed97f2d 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java @@ -253,7 +253,7 @@ public class BukkitImageListener implements Listener { fp.runAction(new Runnable() { @Override public void run() { - BlockVector3 wPos = new BlockVector3(worldX, 0, worldZ); + BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ); viewer.refresh(); int topY = generator.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255, 0, 255); wPos = wPos.withY(topY); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java index e7e73d2de..b9aefc6ca 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java @@ -139,7 +139,7 @@ public class CFIPacketListener implements Listener { int ocx = origin.getBlockX() >> 4; int ocz = origin.getBlockZ() >> 4; - if (gen.contains(new BlockVector3((cx - ocx) << 4, 0, (cz - ocz) << 4))) { + if (gen.contains(BlockVector3.at((cx - ocx) << 4, 0, (cz - ocz) << 4))) { event.setCancelled(true); Player plr = event.getPlayer(); @@ -166,7 +166,7 @@ public class CFIPacketListener implements Listener { VirtualWorld gen = getGenerator(event); if (gen != null) { BlockVector3 origin = gen.getOrigin().toBlockPoint(); - BlockVector3 pt = new BlockVector3(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); + BlockVector3 pt = BlockVector3.at(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); StructureModifier ints = event.getPacket().getIntegers(); int id = ints.read(0); @@ -191,11 +191,11 @@ public class CFIPacketListener implements Listener { VirtualWorld gen = getGenerator(event); if (gen != null) { BlockVector3 origin = gen.getOrigin().toBlockPoint(); - BlockVector3 from = new BlockVector3(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); + BlockVector3 from = BlockVector3.at(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); PacketContainer packet = event.getPacket(); StructureModifier doubles = packet.getDoubles(); - BlockVector3 to = new BlockVector3(doubles.read(0), doubles.read(1), doubles.read(2)); + BlockVector3 to = BlockVector3.at(doubles.read(0), doubles.read(1), doubles.read(2)); if (gen.contains(to.subtract(origin)) && from.distanceSq(to) < 8) { int id = packet.getIntegers().read(0); PacketContainer reply = new PacketContainer(PacketType.Play.Client.TELEPORT_ACCEPT); @@ -225,7 +225,7 @@ public class CFIPacketListener implements Listener { BlockVector3 origin = gen.getOrigin().toBlockPoint(); int cx = chunk.getChunkX() - (origin.getBlockX() >> 4); int cz = chunk.getChunkZ() - (origin.getBlockX() >> 4); - if (gen.contains(new BlockVector3(cx << 4, 0, cz << 4))) { + if (gen.contains(BlockVector3.at(cx << 4, 0, cz << 4))) { event.setCancelled(true); } } @@ -288,7 +288,7 @@ public class CFIPacketListener implements Listener { BlockPosition loc = position.readSafely(0); if (loc == null) return null; BlockVector3 origin = generator.getOrigin().toBlockPoint(); - BlockVector3 pt = new BlockVector3(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ()); + BlockVector3 pt = BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ()); return pt; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java index 97a3ccaf1..54e9f0bc9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java @@ -12,6 +12,6 @@ public class BukkitMask extends FaweMask { } public BukkitMask(Location pos1, Location pos2, String name) { - super(new BlockVector3(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), new BlockVector3(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name); + super(BlockVector3.at(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), BlockVector3.at(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name); } } \ No newline at end of file diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java index 541c023af..e1aa7bbc9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java @@ -55,7 +55,7 @@ public class FreeBuildRegion extends BukkitMaskManager { World bukkitWorld = player.parent.getWorld(); AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld); - BlockVector3 vec1 = new BlockVector3(0, 0, 0); + BlockVector3 vec1 = BlockVector3.at(0, 0, 0); BlockVector3 vec2 = vec1; Location pos1 = BukkitAdapter.adapt(bukkitWorld, vec1); Location pos2 = BukkitAdapter.adapt(bukkitWorld, vec2); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java index a751c7540..7b0af05b5 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java @@ -41,8 +41,8 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener boolean member = fp.hasPermission("fawe.preciousstones.member"); for (final Field myField : fields) { if (isAllowed(player, myField, type, member)) { - BlockVector3 pos1 = new BlockVector3(myField.getMinx(), myField.getMiny(), myField.getMinz()); - BlockVector3 pos2 = new BlockVector3(myField.getMaxx(), myField.getMaxy(), myField.getMaxz()); + BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz()); + BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz()); return new FaweMask(pos1, pos2, "FIELD: " + myField) { @Override public boolean isValid(FawePlayer player, MaskType type) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java index 8e1668915..cb7a91675 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java @@ -61,7 +61,7 @@ public class Worldguard extends BukkitMaskManager implements Listener { if (global != null && isAllowed(player, global)) { return global; } - final ApplicableRegionSet regions = manager.getApplicableRegions(new BlockVector3(loc.getX(), loc.getY(), loc.getZ())); + final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ())); for (final ProtectedRegion region : regions) { if (isAllowed(player, region)) { return region; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java index c4d16e9f9..b1e389cc6 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java @@ -57,7 +57,7 @@ public class StructureCUI extends CUI { int x = Integer.parseInt(param[1]); int y = Integer.parseInt(param[2]); int z = Integer.parseInt(param[3]); - BlockVector3 pos = new BlockVector3(x, y, z); + BlockVector3 pos = BlockVector3.at(x, y, z); if (id == 0) { pos1 = pos; } else { @@ -188,7 +188,7 @@ public class StructureCUI extends CUI { NbtCompound compound = constructStructureNbt(x, y, z, posX, posY, posZ, sizeX, sizeY, sizeZ); Block block = player.getWorld().getBlockAt(x, y, z); - remove = new BlockVector3(x, y, z); + remove = BlockVector3.at(x, y, z); state = BukkitAdapter.adapt(block.getBlockData()); removeTag = compound; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index f14f28ad4..7ebfd6790 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -211,7 +211,7 @@ public class BukkitPlayer extends AbstractPlayerActor { return; } - setPosition(new Vector3(x + 0.5, y, z + 0.5)); + setPosition(Vector3.at(x + 0.5, y, z + 0.5)); player.setFlying(true); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 0ceea15b0..c795006b0 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -200,7 +200,7 @@ public class BukkitWorld extends AbstractWorld { com.sk89q.worldedit.world.block.BlockStateHolder[] history = new com.sk89q.worldedit.world.block.BlockState[16 * 16 * (getMaxY() + 1)]; for (BlockVector2 chunk : region.getChunks()) { - BlockVector3 min = new BlockVector3(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16); + BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16); // First save all the blocks inside for (int x = 0; x < 16; ++x) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java index 35b3afe50..e0613cd97 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java @@ -40,7 +40,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { @Override public boolean setBlockData(int x, int y, int z, BlockData blockData) { try { - editSession.setBlock(new BlockVector3(x, y, z), BukkitAdapter.adapt(blockData)); + editSession.setBlock(BlockVector3.at(x, y, z), BukkitAdapter.adapt(blockData)); } catch (MaxChangedBlocksException e) { return false; } @@ -49,7 +49,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { @Override public BlockData getBlockData(int x, int y, int z) { - return BukkitAdapter.adapt(editSession.getBlock(new BlockVector3(x, y, z))); + return BukkitAdapter.adapt(editSession.getBlock(BlockVector3.at(x, y, z))); } @Override @@ -59,7 +59,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { @Override public boolean isEmpty(int x, int y, int z) { - return editSession.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir(); + return editSession.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir(); } } 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 95d5cde29..b273f47b4 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 @@ -165,7 +165,7 @@ public interface IBukkitAdapter { */ default Vector3 asVector(org.bukkit.Location location) { checkNotNull(location); - return new Vector3(location.getX(), location.getY(), location.getZ()); + return Vector3.at(location.getX(), location.getY(), location.getZ()); } /** @@ -176,7 +176,7 @@ public interface IBukkitAdapter { */ default BlockVector3 asBlockVector(org.bukkit.Location location) { checkNotNull(location); - return new BlockVector3(location.getX(), location.getY(), location.getZ()); + return BlockVector3.at(location.getX(), location.getY(), location.getZ()); } /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java b/worldedit-core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java index ec14c5ac5..3908e317c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java @@ -279,7 +279,7 @@ public class FawePrimitiveBinding extends BindingHelper { default: throw new ParameterException("You must either specify 1 or 3 radius values."); } - return new Vector3(radiusX, radiusY, radiusZ); + return Vector3.at(radiusX, radiusY, radiusZ); } @@ -311,7 +311,7 @@ public class FawePrimitiveBinding extends BindingHelper { default: throw new ParameterException("You must either specify 1 or 2 radius values."); } - return new Vector2(radiusX, radiusZ); + return Vector2.at(radiusX, radiusZ); } /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/CorruptSchematicStreamer.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/CorruptSchematicStreamer.java index c6bad5c59..c3e7c046c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/CorruptSchematicStreamer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/CorruptSchematicStreamer.java @@ -268,19 +268,19 @@ public class CorruptSchematicStreamer { private BlockVector3 guessDimensions(int volume, int width, int height, int length) { if (volume == 0) { - return new BlockVector3(width, height, length); + return BlockVector3.at(width, height, length); } if (volume == width * height * length) { - return new BlockVector3(width, height, length); + return BlockVector3.at(width, height, length); } if (width == 0 && height != 0 && length != 0 && volume % (height * length) == 0 && height * length <= volume) { - return new BlockVector3(volume / (height * length), height, length); + return BlockVector3.at(volume / (height * length), height, length); } if (height == 0 && width != 0 && length != 0 && volume % (width * length) == 0 && width * length <= volume) { - return new BlockVector3(width, volume / (width * length), length); + return BlockVector3.at(width, volume / (width * length), length); } if (length == 0 && height != 0 && width != 0 && volume % (height * width) == 0 && height * width <= volume) { - return new BlockVector3(width, height, volume / (width * height)); + return BlockVector3.at(width, height, volume / (width * height)); } List factors = new ArrayList<>(); for (int i = (int) Math.sqrt(volume); i > 0; i--) { @@ -308,7 +308,7 @@ public class CorruptSchematicStreamer { } } } - return new BlockVector3(vx, vz, vy); + return BlockVector3.at(vx, vz, vy); } public interface CorruptReader { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java index 628830d4f..0f687f7ea 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java @@ -49,7 +49,7 @@ public class SchematicStreamer extends NBTStreamer { public SchematicStreamer(NBTInputStream stream, UUID uuid) { super(stream); this.uuid = uuid; - clipboard = new BlockArrayClipboard(new CuboidRegion(new BlockVector3(0, 0, 0), new BlockVector3(0, 0, 0)), fc); + clipboard = new BlockArrayClipboard(new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(0, 0, 0)), fc); } public void addBlockReaders() throws IOException { @@ -419,7 +419,7 @@ public class SchematicStreamer extends NBTStreamer { private FaweClipboard setupClipboard(int size) { if (fc != null) { if (fc.getDimensions().getX() == 0) { - fc.setDimensions(new BlockVector3(size, 1, 1)); + fc.setDimensions(BlockVector3.at(size, 1, 1)); } return fc; } @@ -433,15 +433,15 @@ public class SchematicStreamer extends NBTStreamer { } public BlockVector3 getOrigin() { - return new BlockVector3(originX, originY, originZ); + return BlockVector3.at(originX, originY, originZ); } public BlockVector3 getOffset() { - return new BlockVector3(offsetX, offsetY, offsetZ); + return BlockVector3.at(offsetX, offsetY, offsetZ); } public BlockVector3 getDimensions() { - return new BlockVector3(width, height, length); + return BlockVector3.at(width, height, length); } public void setClipboard(FaweClipboard clipboard) { @@ -453,10 +453,10 @@ public class SchematicStreamer extends NBTStreamer { addDimensionReaders(); addBlockReaders(); readFully(); - BlockVector3 min = new BlockVector3(originX, originY, originZ); - BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ); + BlockVector3 min = BlockVector3.at(originX, originY, originZ); + BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ); BlockVector3 origin = min.subtract(offset); - BlockVector3 dimensions = new BlockVector3(width, height, length); + BlockVector3 dimensions = BlockVector3.at(width, height, length); fc.setDimensions(dimensions); fixStates(); CuboidRegion region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); 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 e91593c0c..3e5a0cdd4 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 @@ -234,7 +234,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr @Override public Vector3 getOrigin() { - return new Vector3(chunkOffset.getBlockX() << 4, 0, chunkOffset.getBlockZ() << 4); + return Vector3.at(chunkOffset.getBlockX() << 4, 0, chunkOffset.getBlockZ() << 4); } public boolean hasPacketViewer() { @@ -245,7 +245,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr this.player = player; if (player != null) { FaweLocation pos = player.getLocation(); - this.chunkOffset = new BlockVector2(1 + (pos.x >> 4), 1 + (pos.z >> 4)); + this.chunkOffset = BlockVector2.at(1 + (pos.x >> 4), 1 + (pos.z >> 4)); } } @@ -554,13 +554,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } public void addCaves() throws WorldEditException { - CuboidRegion region = new CuboidRegion(new BlockVector3(0, 0, 0), new BlockVector3(getWidth() -1, 255, getLength() -1)); + CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() -1, 255, getLength() -1)); addCaves(region); } @Deprecated public void addSchems(Mask mask, List clipboards, int rarity, boolean rotate) throws WorldEditException { - CuboidRegion region = new CuboidRegion(new BlockVector3(0, 0, 0), new BlockVector3(getWidth() -1, 255, getLength() -1)); + CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() -1, 255, getLength() -1)); addSchems(region, mask, clipboards, rarity, rotate); } @@ -665,17 +665,17 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } public void addOre(Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException { - CuboidRegion region = new CuboidRegion(new BlockVector3(0, 0, 0), new BlockVector3(getWidth() -1, 255, getLength() -1)); + CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() -1, 255, getLength() -1)); addOre(region, mask, material, size, frequency, rarity, minY, maxY); } public void addDefaultOres(Mask mask) throws WorldEditException { - addOres(new CuboidRegion(new BlockVector3(0, 0, 0), new BlockVector3(getWidth() -1, 255, getLength() -1)), mask); + addOres(new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() -1, 255, getLength() -1)), mask); } @Override public BlockVector3 getMinimumPoint() { - return new BlockVector3(0, 0, 0); + return BlockVector3.at(0, 0, 0); } @Override @@ -685,7 +685,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr @Override public BlockVector3 getMaximumPoint() { - return new BlockVector3(getWidth() - 1, 255, getLength() - 1); + return BlockVector3.at(getWidth() - 1, 255, getLength() - 1); } @Override 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 4e60fb01f..b46498caa 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 @@ -62,12 +62,12 @@ public interface FaweQueue extends HasFaweQueue, Extent { @Override default BlockVector3 getMinimumPoint() { - return new BlockVector3(-30000000, 0, -30000000); + return BlockVector3.at(-30000000, 0, -30000000); } @Override default BlockVector3 getMaximumPoint() { - return new BlockVector3(30000000, getMaxY(), 30000000); + return BlockVector3.at(30000000, getMaxY(), 30000000); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java index 8785fe3f4..accca3243 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java @@ -117,7 +117,7 @@ public class HistoryExtent extends AbstractDelegateExtent { @Override public boolean setBiome(int x, int y, int z, BaseBiome newBiome) { - BaseBiome oldBiome = this.getBiome(new BlockVector2(x, z)); + BaseBiome oldBiome = this.getBiome(BlockVector2.at(x, z)); if (oldBiome.getId() != newBiome.getId()) { this.changeSet.addBiomeChange(x, z, oldBiome, newBiome); return getExtent().setBiome(x, y, z, newBiome); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/RegionWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/object/RegionWrapper.java index 1179fa003..8547e081e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/RegionWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/RegionWrapper.java @@ -23,7 +23,7 @@ public class RegionWrapper extends CuboidRegion { } public RegionWrapper(final int minX, final int maxX, final int minY, final int maxY, final int minZ, final int maxZ) { - this(new BlockVector3(minX, 0, minZ), new BlockVector3(maxX, 255, maxZ)); + this(BlockVector3.at(minX, 0, minZ), BlockVector3.at(maxX, 255, maxZ)); } public RegionWrapper(final BlockVector3 pos1, final BlockVector3 pos2) { 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 704729876..e5228c347 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 @@ -26,7 +26,7 @@ public class CircleBrush implements Brush { private Vector3 any90Rotate(Vector3 normal) { normal = normal.normalize(); if (normal.getX() == 1 || normal.getY() == 1 || normal.getZ() == 1) { - return new Vector3(normal.getZ(), normal.getX(), normal.getY()); + return Vector3.at(normal.getZ(), normal.getX(), normal.getY()); } AffineTransform affine = new AffineTransform(); affine = affine.rotateX(90); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ErodeBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ErodeBrush.java index c05bce1f1..13f59825a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ErodeBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ErodeBrush.java @@ -23,7 +23,7 @@ public class ErodeBrush implements Brush { private PseudoRandom rand = new PseudoRandom(); - private static final BlockVector3[] FACES_TO_CHECK = {new BlockVector3(0, 0, 1), new BlockVector3(0, 0, -1), new BlockVector3(0, 1, 0), new BlockVector3(0, -1, 0), new BlockVector3(1, 0, 0), new BlockVector3(-1, 0, 0)}; + private static final BlockVector3[] FACES_TO_CHECK = {BlockVector3.at(0, 0, 1), BlockVector3.at(0, 0, -1), BlockVector3.at(0, 1, 0), BlockVector3.at(0, -1, 0), BlockVector3.at(1, 0, 0), BlockVector3.at(-1, 0, 0)}; @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java index a9b364736..c4ad475ab 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java @@ -133,14 +133,14 @@ public class HeightBrush implements Brush { } if (smooth) { - BlockVector2 min = new BlockVector2(Math.max(0, bx - size), Math.max(0, bz - size)); - BlockVector2 max = new BlockVector2(Math.min(hmmg.getWidth() - 1, bx + size), Math.min(hmmg.getLength() - 1, bz + size)); + BlockVector2 min = BlockVector2.at(Math.max(0, bx - size), Math.max(0, bz - size)); + BlockVector2 max = BlockVector2.at(Math.min(hmmg.getWidth() - 1, bx + size), Math.min(hmmg.getLength() - 1, bz + size)); hmmg.smooth(min, max, 8, 1); if (size > 20) { int smoothSize = size + 8; - min = new BlockVector2(Math.max(0, bx - smoothSize), Math.max(0, bz - smoothSize)); - max = new BlockVector2(Math.min(hmmg.getWidth() - 1, bx + smoothSize), Math.min(hmmg.getLength() - 1, bz + smoothSize)); + min = BlockVector2.at(Math.max(0, bx - smoothSize), Math.max(0, bz - smoothSize)); + max = BlockVector2.at(Math.min(hmmg.getWidth() - 1, bx + smoothSize), Math.min(hmmg.getLength() - 1, bz + smoothSize)); hmmg.smooth(min, max, 1, 1); } } 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 658fb88b2..7ea44b6da 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 @@ -84,7 +84,7 @@ public class SplineBrush implements Brush, ResettableTool { for (int y = -1; y <= 1; y++) { for (int z = -1; z <= 1; z++) { if (x != 0 || y != 0 || z != 0) { - BlockVector3 pos = new BlockVector3(x, y, z); + BlockVector3 pos = BlockVector3.at(x, y, z); if (!directions.contains(pos)) { directions.add(pos); } @@ -206,15 +206,15 @@ public class SplineBrush implements Brush, ResettableTool { if (det_max == det_x) { double a = (xz * yz - xy * zz) / det_x; double b = (xy * yz - xz * yy) / det_x; - dir = new BlockVector3(1.0, a, b); + dir = BlockVector3.at(1.0, a, b); } else if (det_max == det_y) { double a = (yz * xz - xy * zz) / det_y; double b = (xy * xz - yz * xx) / det_y; - dir = new BlockVector3(a, 1.0, b); + dir = BlockVector3.at(a, 1.0, b); } else { double a = (yz * xy - xz * yy) / det_z; double b = (xz * xy - yz * xx) / det_z; - dir = new BlockVector3(a, b, 1.0); + dir = BlockVector3.at(a, b, 1.0); } ; return dir.normalize(); 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 c3bf06e11..6cac08257 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 @@ -35,7 +35,7 @@ public class SurfaceSpline implements Brush { int max = editSession.getNearestSurfaceTerrainBlock(pos.getBlockX(), pos.getBlockZ(), pos.getBlockY(), 0, editSession.getMaxY()); if (max == -1) return; // pos.mutY(max); - path.add(new Vector3(pos.getBlockX(), max, pos.getBlockZ())); + path.add(Vector3.at(pos.getBlockX(), max, pos.getBlockZ())); editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_PRIMARY_2.s()); if (!vis) return; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/Spline.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/Spline.java index ee6851ec2..68a3cee85 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/Spline.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/Spline.java @@ -21,7 +21,7 @@ import java.util.List; */ public abstract class Spline { - private BlockVector2 direction = new BlockVector2(1, 0); + private BlockVector2 direction = BlockVector2.at(1, 0); private final int nodeCount; protected EditSession editSession; @@ -134,7 +134,7 @@ public abstract class Spline { // Calculate rotation from spline Vector3 deriv = interpolation.get1stDerivative(position); - Vector2 deriv2D = new Vector2(deriv.getX(), deriv.getZ()).normalize(); + Vector2 deriv2D = Vector2.at(deriv.getX(), deriv.getZ()).normalize(); double angle = Math.toDegrees( Math.atan2(direction.getZ(), direction.getX()) - Math.atan2(deriv2D.getZ(), deriv2D.getX()) ); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java index f708e96df..35f2d9e7a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java @@ -126,7 +126,7 @@ public class CPUOptimizedClipboard extends FaweClipboard { @Override public BlockVector3 getDimensions() { - return new BlockVector3(width, height, length); + return BlockVector3.at(width, height, length); } private int ylast; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java index bd7bdc4e0..f5082346f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java @@ -167,17 +167,17 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { @Override public BlockVector3 getDimensions() { - return new BlockVector3(width, height, length); + return BlockVector3.at(width, height, length); } public BlockArrayClipboard toClipboard() { try { - CuboidRegion region = new CuboidRegion(new BlockVector3(0, 0, 0), new BlockVector3(width - 1, height - 1, length - 1)); + CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(width - 1, height - 1, length - 1)); int ox = mbb.getShort(8); int oy = mbb.getShort(10); int oz = mbb.getShort(12); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, this); - clipboard.setOrigin(new BlockVector3(ox, oy, oz)); + clipboard.setOrigin(BlockVector3.at(ox, oy, oz)); return clipboard; } catch (Throwable e) { MainUtil.handleError(e); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java index 67efba2d8..7c6968a79 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java @@ -175,7 +175,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard { @Override public BlockVector3 getDimensions() { - return new BlockVector3(width, height, length); + return BlockVector3.at(width, height, length); } private int lastI; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java index 7e7412a56..6c7dfa4fc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java @@ -60,8 +60,8 @@ public class ResizableClipboardBuilder extends MemoryOptimizedHistory { } public Clipboard build() { - BlockVector3 pos1 = new BlockVector3(minX, minY, minZ); - BlockVector3 pos2 = new BlockVector3(maxX, maxY, maxZ); + BlockVector3 pos1 = BlockVector3.at(minX, minY, minZ); + BlockVector3 pos2 = BlockVector3.at(maxX, maxY, maxZ); CuboidRegion region = new CuboidRegion(pos1, pos2); BlockArrayClipboard clipboard = new BlockArrayClipboard(region); Iterator iter = getIterator(true); 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 bb06f78b9..afe99f1c7 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 @@ -154,7 +154,7 @@ public class LocalBlockVector2DSet implements Set { index = set.nextSetBit(index); int x = MathMan.unpairSearchCoordsX(index); int y = MathMan.unpairSearchCoordsY(index); - array[i] = (T) new BlockVector2(x, y); + array[i] = (T) BlockVector2.at(x, y); index++; } return array; 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 710c83682..12b03cee3 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 @@ -179,7 +179,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); - array[i] = (T) new BlockVector3(x, y, z); + array[i] = (T) BlockVector3.at(x, y, z); index++; } return array; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java index 3e4831c67..438c6c735 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java @@ -99,12 +99,12 @@ public class NullExtent extends FaweRegionExtent { @Override public BlockVector3 getMaximumPoint() { - return new BlockVector3(0, 0, 0); + return BlockVector3.at(0, 0, 0); } @Override public BlockVector3 getMinimumPoint() { - return new BlockVector3(0, 0, 0); + return BlockVector3.at(0, 0, 0); } @Override 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 4b8ed466b..81ba33b88 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 @@ -51,7 +51,7 @@ public class PositionTransformExtent extends ResettableExtent { private BlockVector3 getPos(int x, int y, int z) { if (min == null) { - min = new BlockVector3(x, y, z); + min = BlockVector3.at(x, y, z); } mutable.mutX(((x - min.getX()))); mutable.mutY(((y - min.getY()))); 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 e53ad52fc..172441ba3 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 @@ -51,7 +51,7 @@ public class ScaleTransform extends ResettableExtent { private BlockVector3 getPos(int x, int y, int z) { if (min == null) { - min = new BlockVector3(x, y, z); + min = BlockVector3.at(x, y, z); } mutable.mutX((min.getX() + (x - min.getX()) * dx)); mutable.mutY((min.getY() + (y - min.getY()) * dy)); 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 f39d98d93..82176595c 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 @@ -67,7 +67,7 @@ public class TransformExtent extends BlockTransformExtent { public BlockVector3 getPos(int x, int y, int z) { if (min == null) { - min = new BlockVector3(x, y, z); + min = BlockVector3.at(x, y, z); } mutable.mutX(((x - min.getX()))); mutable.mutY(((y - min.getY()))); 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 5c0ae033c..2f833590c 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 @@ -31,7 +31,7 @@ public class OffsetPattern extends AbstractPattern { // mutable.mutY((position.getY() + dy)); // mutable.mutZ((position.getZ() + dz)); // return pattern.apply(mutable); - return pattern.apply(new BlockVector3(position.getX() + dx, position.getY() + dy, position.getZ() + dz)); + return pattern.apply(BlockVector3.at(position.getX() + dx, position.getY() + dy, position.getZ() + dz)); } @Override @@ -40,7 +40,7 @@ public class OffsetPattern extends AbstractPattern { // mutable.mutY((get.getY() + dy)); // mutable.mutZ((get.getZ() + dz)); // return pattern.apply(extent, set, mutable); - return pattern.apply(extent, set, new BlockVector3(get.getX() + dx, get.getY() + dy, get.getZ() + dz)); + return pattern.apply(extent, set, BlockVector3.at(get.getX() + dx, get.getY() + dy, get.getZ() + dz)); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java index bf1036e1b..c05349016 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java @@ -24,7 +24,7 @@ import javax.annotation.Nullable; public class PatternExtent extends AbstractPattern implements Extent { private final Pattern pattern; private transient BlockStateHolder block; - private transient BlockVector3 target = new BlockVector3(0, 0, 0); + private transient BlockVector3 target = BlockVector3.at(0, 0, 0); public PatternExtent(Pattern pattern) { this.pattern = pattern; @@ -32,17 +32,17 @@ public class PatternExtent extends AbstractPattern implements Extent { private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); - target = new BlockVector3(0, 0, 0); + target = BlockVector3.at(0, 0, 0); } @Override public BlockVector3 getMinimumPoint() { - return new BlockVector3(Integer.MIN_VALUE, 0, Integer.MIN_VALUE); + return BlockVector3.at(Integer.MIN_VALUE, 0, Integer.MIN_VALUE); } @Override public BlockVector3 getMaximumPoint() { - return new BlockVector3(Integer.MAX_VALUE, 255, Integer.MAX_VALUE); + return BlockVector3.at(Integer.MAX_VALUE, 255, Integer.MAX_VALUE); } @Override 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 f1505bff7..2579f8843 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 @@ -44,7 +44,7 @@ public class RandomFullClipboardPattern extends AbstractPattern { holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90)); } if (randomFlip) { - transform = transform.scale(new Vector3(1, 0, 0).multiply(-2).add(1, 1, 1)); + transform = transform.scale(Vector3.at(1, 0, 0).multiply(-2).add(1, 1, 1)); } if (!transform.isIdentity()) { holder.setTransform(transform); 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 3951e8728..8e809eb9d 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 @@ -58,7 +58,7 @@ public class FaweQueueDelegateExtent extends DelegateFaweQueue { @Override public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException { - return parentExtent.getBiome(new BlockVector2(x, z)).getId(); + return parentExtent.getBiome(BlockVector2.at(x, z)).getId(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java index f79627448..3abaa65cf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java @@ -53,7 +53,7 @@ public class FuzzyRegion extends AbstractRegion { } }, 256, extent instanceof HasFaweQueue ? (HasFaweQueue) extent : null); search.setVisited(set); - search.visit(new BlockVector3(x, y, z)); + search.visit(BlockVector3.at(x, y, z)); Operations.completeBlindly(search); } @@ -94,12 +94,12 @@ public class FuzzyRegion extends AbstractRegion { @Override public BlockVector3 getMinimumPoint() { - return new BlockVector3(minX, minY, minZ); + return BlockVector3.at(minX, minY, minZ); } @Override public BlockVector3 getMaximumPoint() { - return new BlockVector3(maxX, maxY, maxZ); + return BlockVector3.at(maxX, maxY, maxZ); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/Triangle.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/Triangle.java index b6e15531e..8cea2bfe3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/Triangle.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/Triangle.java @@ -45,9 +45,9 @@ public class Triangle { public Edge getEdge(int index) { if (index == this.verts.length - 1) { - return new Edge(new Vector3(this.verts[index][0], this.verts[index][1],this.verts[index][2]), new Vector3(this.verts[0][0], this.verts[0][1], this.verts[0][2])); + return new Edge(Vector3.at(this.verts[index][0], this.verts[index][1],this.verts[index][2]), Vector3.at(this.verts[0][0], this.verts[0][1], this.verts[0][2])); } else { - return new Edge(new Vector3(this.verts[index][0], this.verts[index][1],this.verts[index][2]), new Vector3(this.verts[index + 1][0], this.verts[index + 1][1], this.verts[index + 1][2])); + return new Edge(Vector3.at(this.verts[index][0], this.verts[index][1],this.verts[index][2]), Vector3.at(this.verts[index + 1][0], this.verts[index + 1][1], this.verts[index + 1][2])); } } @@ -57,7 +57,7 @@ public class Triangle { } public Vector3 getVertex(int index) { - return new Vector3(verts[index][0], verts[index][1], verts[index][2]); + return Vector3.at(verts[index][0], verts[index][1], verts[index][2]); } public boolean contains(BlockVector3 pos) { 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 a5ee6d7de..159c22806 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 @@ -259,7 +259,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(new BlockVector2(mutable.getBlockX(), mutable.getBlockZ()))); + extent.setBiome(mpos2d.toBlockVector2(), 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 e759c5908..1cfe22293 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 @@ -77,7 +77,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { int length = size.getInt(2); // Init clipboard - BlockVector3 origin = new BlockVector3(0, 0, 0); + BlockVector3 origin = BlockVector3.at(0, 0, 0); CuboidRegion region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE)); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, clipboardId); // Blocks 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 b0bbf1152..75fe331e1 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 @@ -80,12 +80,12 @@ public class SchemVis extends ImmutableVirtualWorld { // Set the origin to somewhere around where the player currently is FaweLocation pos = player.getLocation(); this.origin = player.getPlayer().getLocation(); - this.chunkOffset = new BlockVector2(pos.x >> 4,pos.z >> 4); + this.chunkOffset = BlockVector2.at(pos.x >> 4,pos.z >> 4); } private Set getFiles(BlockVector2 chunkPosA, BlockVector2 chunkPosB) { - BlockVector2 pos1 = new BlockVector2(Math.min(chunkPosA.getBlockX(), chunkPosB.getBlockX()), Math.min(chunkPosA.getBlockZ(), chunkPosB.getBlockZ())); - BlockVector2 pos2 = new BlockVector2(Math.max(chunkPosA.getBlockX(), chunkPosB.getBlockX()), Math.max(chunkPosA.getBlockZ(), chunkPosB.getBlockZ())); + BlockVector2 pos1 = BlockVector2.at(Math.min(chunkPosA.getBlockX(), chunkPosB.getBlockX()), Math.min(chunkPosA.getBlockZ(), chunkPosB.getBlockZ())); + BlockVector2 pos2 = BlockVector2.at(Math.max(chunkPosA.getBlockX(), chunkPosB.getBlockX()), Math.max(chunkPosA.getBlockZ(), chunkPosB.getBlockZ())); Set contained = new HashSet<>(); for (Long2ObjectMap.Entry> entry : files.long2ObjectEntrySet()) { long key = entry.getLongKey(); @@ -121,7 +121,7 @@ public class SchemVis extends ImmutableVirtualWorld { synchronized (this) { try { BlockVector2 tmpLastPosition = lastPosition; - lastPosition = new BlockVector2(chunkX, chunkZ); + lastPosition = BlockVector2.at(chunkX, chunkZ); boolean sneaking = this.player.isSneaking(); if (event.getInputType() == InputType.PRIMARY && !sneaking) { @@ -256,7 +256,7 @@ public class SchemVis extends ImmutableVirtualWorld { */ @Override public Vector3 getOrigin() { - return new Vector3(chunkOffset.getBlockX() << 4, 0, chunkOffset.getBlockZ() << 4); + return Vector3.at(chunkOffset.getBlockX() << 4, 0, chunkOffset.getBlockZ() << 4); } /** @@ -371,13 +371,13 @@ public class SchemVis extends ImmutableVirtualWorld { if (dimensionPair != null) { int width = (char) MathMan.unpairX(dimensionPair); int length = (char) MathMan.unpairY(dimensionPair); - BlockVector2 dimensions = new BlockVector2(width, length); + BlockVector2 dimensions = BlockVector2.at(width, length); BlockVector2 offset = registerAndGetChunkOffset(dimensions, cached); return; } if (cached.exists() && file.lastModified() <= cached.lastModified()) { try (InputStream fis = new BufferedInputStream(new FileInputStream(cached), 4)) { - BlockVector2 dimensions = new BlockVector2(IOUtil.readVarInt(fis), IOUtil.readVarInt(fis)); + BlockVector2 dimensions = BlockVector2.at(IOUtil.readVarInt(fis), IOUtil.readVarInt(fis)); DIMENSION_CACHE.put(file, MathMan.pair((short) dimensions.getBlockX(), (short) dimensions.getBlockZ())); BlockVector2 offset = registerAndGetChunkOffset(dimensions, cached); } @@ -472,7 +472,7 @@ public class SchemVis extends ImmutableVirtualWorld { int OCZ = MathMan.unpairIntY(origin); try { try (FileInputStream fis = new FileInputStream(cached)) { - BlockVector2 dimensions = new BlockVector2(IOUtil.readVarInt(fis), IOUtil.readVarInt(fis)); + BlockVector2 dimensions = BlockVector2.at(IOUtil.readVarInt(fis), IOUtil.readVarInt(fis)); try (FaweInputStream in = MainUtil.getCompressedIS(fis)) { NonCloseableInputStream nonCloseable = new NonCloseableInputStream(in); try (NBTInputStream nis = new NBTInputStream(nonCloseable)) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/AboveVisitor.java b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/AboveVisitor.java index c5ac0b700..71de953b1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/AboveVisitor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/AboveVisitor.java @@ -41,12 +41,12 @@ public class AboveVisitor extends RecursiveVisitor { Collection directions = getDirections(); directions.clear(); - directions.add(new BlockVector3(1, 0, 0)); - directions.add(new BlockVector3(-1, 0, 0)); - directions.add(new BlockVector3(0, 0, 1)); - directions.add(new BlockVector3(0, 0, -1)); - directions.add(new BlockVector3(0, 1, 0)); - directions.add(new BlockVector3(0, -1, 0)); + directions.add(BlockVector3.at(1, 0, 0)); + directions.add(BlockVector3.at(-1, 0, 0)); + directions.add(BlockVector3.at(0, 0, 1)); + directions.add(BlockVector3.at(0, 0, -1)); + directions.add(BlockVector3.at(0, 1, 0)); + directions.add(BlockVector3.at(0, -1, 0)); } @Override 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 fc70fd68b..82af1c1fc 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 @@ -38,12 +38,12 @@ public abstract class DFSVisitor implements Operation { this.hashQueue = new LinkedHashSet<>(); this.visited = new LinkedHashMap<>(); this.function = function; - this.directions.add(new BlockVector3(0, -1, 0)); - this.directions.add(new BlockVector3(0, 1, 0)); - this.directions.add(new BlockVector3(-1, 0, 0)); - this.directions.add(new BlockVector3(1, 0, 0)); - this.directions.add(new BlockVector3(0, 0, -1)); - this.directions.add(new BlockVector3(0, 0, 1)); + this.directions.add(BlockVector3.at(0, -1, 0)); + this.directions.add(BlockVector3.at(0, 1, 0)); + this.directions.add(BlockVector3.at(-1, 0, 0)); + this.directions.add(BlockVector3.at(1, 0, 0)); + this.directions.add(BlockVector3.at(0, 0, -1)); + this.directions.add(BlockVector3.at(0, 0, 1)); this.maxDepth = maxDepth; this.maxBranch = maxBranching; } @@ -92,7 +92,7 @@ public abstract class DFSVisitor implements Operation { // mutable.mutX(from.getX()); // mutable.mutY(from.getY()); // mutable.mutZ(from.getZ()); - BlockVector3 bv = new BlockVector3(from.getX(), from.getY(), from.getZ()); + BlockVector3 bv = BlockVector3.at(from.getX(), from.getY(), from.getZ()); function.apply(bv); countAdd = 0; countAttempt = 0; @@ -100,7 +100,7 @@ public abstract class DFSVisitor implements Operation { // mutable2.mutX(from.getX() + direction.x); // mutable2.mutY(from.getY() + direction.y); // mutable2.mutZ(from.getZ() + direction.z); - BlockVector3 bv2 = new BlockVector3(from.getX() + direction.x, from.getY() + direction.y, from.getZ() + direction.z); + BlockVector3 bv2 = BlockVector3.at(from.getX() + direction.x, from.getY() + direction.y, from.getZ() + direction.z); if (isVisitable(bv, bv2)) { adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ()); if ((current.from == null || !adjacent.equals(current.from))) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweChunkManager.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweChunkManager.java index 2234b919f..054ba8301 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweChunkManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweChunkManager.java @@ -50,8 +50,8 @@ public class FaweChunkManager extends ChunkManager { synchronized (FaweChunkManager.class) { EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); - CuboidRegion regionA = new CuboidRegion(new BlockVector3(pos1.getX(), pos1.getY(), pos1.getZ()), new BlockVector3(pos2.getX(), pos2.getY(), pos2.getZ())); - CuboidRegion regionB = new CuboidRegion(new BlockVector3(pos3.getX(), pos3.getY(), pos3.getZ()), new BlockVector3(pos4.getX(), pos4.getY(), pos4.getZ())); + CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); + CuboidRegion regionB = new CuboidRegion(BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()), BlockVector3.at(pos4.getX(), pos4.getY(), pos4.getZ())); ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint()); ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, sessionA, regionA.getMinimumPoint()); try { @@ -76,8 +76,8 @@ public class FaweChunkManager extends ChunkManager { synchronized (FaweChunkManager.class) { EditSession from = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); EditSession to = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); - CuboidRegion region = new CuboidRegion(new BlockVector3(pos1.getX(), pos1.getY(), pos1.getZ()), new BlockVector3(pos2.getX(), pos2.getY(), pos2.getZ())); - ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, new BlockVector3(pos3.getX(), pos3.getY(), pos3.getZ())); + CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); + ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ())); try { Operations.completeLegacy(copy); to.flushQueue(); @@ -99,7 +99,7 @@ public class FaweChunkManager extends ChunkManager { synchronized (FaweChunkManager.class) { EditSession editSession = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); World world = editSession.getWorld(); - CuboidRegion region = new CuboidRegion(new BlockVector3(pos1.getX(), pos1.getY(), pos1.getZ()), new BlockVector3(pos2.getX(), pos2.getY(), pos2.getZ())); + CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); world.regenerate(region, editSession); editSession.flushQueue(); TaskManager.IMP.task(whenDone); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweSchematicHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweSchematicHandler.java index 4b8cb8a34..dea13c625 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweSchematicHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweSchematicHandler.java @@ -53,7 +53,7 @@ public class FaweSchematicHandler extends SchematicHandler { Location[] corners = MainUtil.getCorners(world, regions); Location pos1 = corners[0]; Location pos2 = corners[1]; - final CuboidRegion region = new CuboidRegion(new BlockVector3(pos1.getX(), pos1.getY(), pos1.getZ()), new BlockVector3(pos2.getX(), pos2.getY(), pos2.getZ())); + final CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); final int mx = pos1.getX(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotRegionFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotRegionFilter.java index 526a0c9ea..39c47a01b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotRegionFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotRegionFilter.java @@ -24,7 +24,7 @@ public class PlotRegionFilter extends CuboidRegionFilter { for (Plot plot : plots) { Location pos1 = plot.getBottom(); Location pos2 = plot.getTop(); - add(new BlockVector2(pos1.getX(), pos1.getZ()), new BlockVector2(pos2.getX(), pos2.getZ())); + add(BlockVector2.at(pos1.getX(), pos1.getZ()), BlockVector2.at(pos2.getX(), pos2.getZ())); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java index 4ea875da8..f46d6ca4e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java @@ -84,7 +84,7 @@ public class PlotSetBiome extends Command { .build(); long seed = PseudoRandom.random.nextLong(); for (RegionWrapper region : regions) { - CuboidRegion cuboid = new CuboidRegion(new BlockVector3(region.minX, 0, region.minZ), new BlockVector3(region.maxX, 256, region.maxZ)); + CuboidRegion cuboid = new CuboidRegion(BlockVector3.at(region.minX, 0, region.minZ), BlockVector3.at(region.maxX, 256, region.maxZ)); session.regenerate(cuboid, biome, seed); } session.flushQueue(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSquaredFeature.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSquaredFeature.java index 169440aab..984cfef9d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSquaredFeature.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSquaredFeature.java @@ -125,8 +125,8 @@ public class PlotSquaredFeature extends FaweMaskManager { faweRegions.add(new com.boydti.fawe.object.RegionWrapper(current.minX, current.maxX, min, max, current.minZ, current.maxZ)); } final RegionWrapper region = regions.iterator().next(); - final BlockVector3 pos1 = new BlockVector3(region.minX, min, region.minZ); - final BlockVector3 pos2 = new BlockVector3(region.maxX, max, region.maxZ); + final BlockVector3 pos1 = BlockVector3.at(region.minX, min, region.minZ); + final BlockVector3 pos2 = BlockVector3.at(region.maxX, max, region.maxZ); final Plot finalPlot = plot; if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot) || regions.isEmpty()) { return null; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java index 5667cb24a..02d121f5e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java @@ -235,13 +235,13 @@ public class PlayerWrapper extends AbstractPlayerActor { Extent world = getLocation().getExtent(); // No free space above - if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir()) { + if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir()) { return false; } while (y <= world.getMaximumPoint().getY()) { // Found a ceiling! - if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { int platformY = Math.max(initialY, y - 3 - clearance); floatAt(x, platformY + 1, z, alwaysGlass); return true; @@ -269,7 +269,7 @@ public class PlayerWrapper extends AbstractPlayerActor { final Extent world = getLocation().getExtent(); while (y <= world.getMaximumPoint().getY() + 2) { - if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { break; // Hit something } else if (y > maxY + 1) { break; @@ -289,7 +289,7 @@ public class PlayerWrapper extends AbstractPlayerActor { RuntimeException caught = null; try { EditSession edit = new EditSessionBuilder(parent.getWorld()).player(FawePlayer.wrap(this)).build(); - edit.setBlock(new BlockVector3(x, y - 1, z), BlockTypes.GLASS); + edit.setBlock(BlockVector3.at(x, y - 1, z), BlockTypes.GLASS); edit.flushQueue(); LocalSession session = Fawe.get().getWorldEdit().getSessionManager().get(this); if (session != null) { @@ -301,7 +301,7 @@ public class PlayerWrapper extends AbstractPlayerActor { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { - setPosition(new Vector3(x + 0.5, y, z + 0.5)); + setPosition(Vector3.at(x + 0.5, y, z + 0.5)); } }); if (caught != null) { @@ -361,7 +361,7 @@ public class PlayerWrapper extends AbstractPlayerActor { boolean inFree = false; while ((block = hitBlox.getNextBlock()) != null) { - boolean free = !world.getBlock(new BlockVector3(block.getBlockX(), block.getBlockY(), block.getBlockZ())).getBlockType().getMaterial().isMovementBlocker(); + boolean free = !world.getBlock(BlockVector3.at(block.getBlockX(), block.getBlockY(), block.getBlockZ())).getBlockType().getMaterial().isMovementBlocker(); if (firstBlock) { firstBlock = false; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java index 24581fe10..a86279ef8 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java @@ -171,7 +171,7 @@ public final class NBTUtils { */ public static Vector3 toVector(ListTag listTag) { checkNotNull(listTag); - return new Vector3(listTag.asDouble(0), listTag.asDouble(1), listTag.asDouble(2)); + return Vector3.at(listTag.asDouble(0), listTag.asDouble(1), listTag.asDouble(2)); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java index 0a98bd7aa..f9e5d8373 100644 --- a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java +++ b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java @@ -214,7 +214,7 @@ public class YAMLNode { return null; } - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } /** @@ -238,7 +238,7 @@ public class YAMLNode { return null; } - return new Vector2(x, z); + return Vector2.at(x, z); } /** @@ -570,7 +570,7 @@ public class YAMLNode { continue; } - list.add(new Vector3(x, y, z)); + list.add(Vector3.at(x, y, z)); } return list; @@ -600,7 +600,7 @@ public class YAMLNode { continue; } - list.add(new Vector2(x, z)); + list.add(Vector2.at(x, z)); } return list; @@ -630,7 +630,7 @@ public class YAMLNode { continue; } - list.add(new BlockVector2(x, z)); + list.add(BlockVector2.at(x, z)); } return list; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java index 7ff06c9b4..2932cb245 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java @@ -249,7 +249,7 @@ public class CuboidClipboard { for (int x = 0; x < size.getBlockX(); ++x) { for (int y = 0; y < size.getBlockY(); ++y) { for (int z = 0; z < size.getBlockZ(); ++z) { - setBlock(x, y, z, editSession.getBlock(new BlockVector3(x, y, z).add(getOrigin()))); + setBlock(x, y, z, editSession.getBlock(BlockVector3.at(x, y, z).add(getOrigin()))); } } } @@ -265,7 +265,7 @@ public class CuboidClipboard { for (int x = 0; x < size.getBlockX(); ++x) { for (int y = 0; y < size.getBlockY(); ++y) { for (int z = 0; z < size.getBlockZ(); ++z) { - final BlockVector3 pt = new BlockVector3(x, y, z).add(getOrigin()); + final BlockVector3 pt = BlockVector3.at(x, y, z).add(getOrigin()); if (region.contains(pt)) { setBlock(x, y, z, editSession.getBlock(pt)); } else { 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 0b7d1d7b9..096393726 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -999,7 +999,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { for (int y = maxY; y >= minY; --y) { - BlockVector3 pt = new BlockVector3(x, y, z); + BlockVector3 pt = BlockVector3.at(x, y, z); BlockState block = getBlock(pt); if (block.getBlockType().getMaterial().isMovementBlocker()) { return y; @@ -1246,7 +1246,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, if (extent != null) { return this.extent.getMinimumPoint(); } else { - return new BlockVector3(-30000000, 0, -30000000); + return BlockVector3.at(-30000000, 0, -30000000); } } @@ -1255,7 +1255,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, if (extent != null) { return this.extent.getMaximumPoint(); } else { - return new BlockVector3(30000000, 255, 30000000); + return BlockVector3.at(30000000, 255, 30000000); } } @@ -1426,10 +1426,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, checkNotNull(pattern); checkArgument(radius >= 0, "radius >= 0"); checkArgument(depth >= 1, "depth >= 1"); - if (direction.equals(new BlockVector3(0, -1, 0))) { + if (direction.equals(BlockVector3.at(0, -1, 0))) { return fillXZ(origin, pattern, radius, depth, false); } - final MaskIntersection mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this))); + final MaskIntersection mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this))); // Want to replace blocks final BlockReplace replace = new BlockReplace(EditSession.this, pattern); @@ -1477,10 +1477,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, checkNotNull(pattern); checkArgument(radius >= 0, "radius >= 0"); checkArgument(depth >= 1, "depth >= 1"); - final MaskIntersection mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))), new BoundedHeightMask(Math.max( + final MaskIntersection mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), new BoundedHeightMask(Math.max( (origin.getBlockY() - depth) + 1, getMinimumPoint().getBlockY()), Math.min(getMaximumPoint().getBlockY(), origin.getBlockY())), Masks.negate(new ExistingBlockMask(EditSession.this))); // MaskIntersection mask = new MaskIntersection( -// new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))), +// new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), // new BoundedHeightMask( // Math.max(origin.getBlockY() - depth + 1, 0), // Math.min(getWorld().getMaxY(), origin.getBlockY())), @@ -1559,7 +1559,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, checkNotNull(position); checkArgument(apothem >= 1, "apothem >= 1"); - final BlockVector3 adjustment = new BlockVector3(1, 1, 1).multiply(apothem - 1); + final BlockVector3 adjustment = BlockVector3.at(1, 1, 1).multiply(apothem - 1); final Region region = new CuboidRegion(this.getWorld(), // Causes clamping of Y range position.add(adjustment.multiply(-1)), position.add(adjustment)); final Pattern pattern = BlockTypes.AIR.getDefaultState(); @@ -1742,8 +1742,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // Vector3 center = region.getCenter(); // Region centerRegion = new CuboidRegion( // getWorld(), // Causes clamping of Y range -// new BlockVector3(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())), -// new BlockVector3(MathUtils.roundHalfUp(center.getX()), +// BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())), +// BlockVector3.at(MathUtils.roundHalfUp(center.getX()), // center.getY(), MathUtils.roundHalfUp(center.getZ()))); // return setBlocks(centerRegion, pattern); } @@ -1892,7 +1892,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, checkNotNull(region); checkNotNull(pattern); final BlockReplace replace = new BlockReplace(EditSession.this, pattern); - final RegionOffset offset = new RegionOffset(new BlockVector3(0, 1, 0), replace); + final RegionOffset offset = new RegionOffset(BlockVector3.at(0, 1, 0), replace); int minY = region.getMinimumPoint().getBlockY(); int maxY = Math.min(getMaximumPoint().getBlockY(), region.getMaximumPoint().getBlockY() + 1); SurfaceRegionFunction surface = new SurfaceRegionFunction(this, offset, minY, maxY); @@ -1900,7 +1900,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, Operations.completeBlindly(visitor); return this.changes = visitor.getAffected(); // BlockReplace replace = new BlockReplace(this, pattern); -// RegionOffset offset = new RegionOffset(new BlockVector3(0, 1, 0), replace); +// RegionOffset offset = new RegionOffset(BlockVector3.at(0, 1, 0), replace); // GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), offset); // LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground); // Operations.completeLegacy(visitor); @@ -2066,7 +2066,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, new BoundedHeightMask(0, EditSession.this.getMaximumPoint().getBlockY()), new RegionMask( new EllipsoidRegion(null, origin, - new Vector3(radius, radius, radius))), liquidMask); + Vector3.at(radius, radius, radius))), liquidMask); final BlockReplace replace = new BlockReplace(EditSession.this, BlockTypes.AIR.getDefaultState()); final RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), this); @@ -2079,7 +2079,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // // MaskIntersection mask = new MaskIntersection( // new BoundedHeightMask(0, getWorld().getMaxY()), -// new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))), +// new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), // getWorld().createLiquidMask()); // // BlockReplace replace = new BlockReplace(this, new BlockPattern(BlockTypes.AIR.getDefaultState())); @@ -2111,7 +2111,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // There are boundaries that the routine needs to stay in MaskIntersection mask = new MaskIntersection( new BoundedHeightMask(0, Math.min(origin.getBlockY(), getMaximumPoint().getBlockY())), - new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))), + new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), liquidMask); BlockReplace replace = new BlockReplace(this, pattern); @@ -2528,12 +2528,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // int ceilRadius = (int) Math.ceil(radius); // for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { // for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { -// if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) { +// if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { // continue; // } // // for (int y = world.getMaxY(); y >= 1; --y) { -// BlockVector3 pt = new BlockVector3(x, y, z); +// BlockVector3 pt = BlockVector3.at(x, y, z); // BlockType id = getBlock(pt).getBlockType(); // // if (id == BlockTypes.ICE) { @@ -2601,12 +2601,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // int ceilRadius = (int) Math.ceil(radius); // for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { // for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { -// if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) { +// if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { // continue; // } // // for (int y = world.getMaxY(); y >= 1; --y) { -// BlockVector3 pt = new BlockVector3(x, y, z); +// BlockVector3 pt = BlockVector3.at(x, y, z); // BlockType id = getBlock(pt).getBlockType(); // // if (id.getMaterial().isAir()) { @@ -2693,12 +2693,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } // for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { // for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { -// if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) { +// if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { // continue; // } // // for (int y = world.getMaxY(); y >= 1; --y) { -// final BlockVector3 pt = new BlockVector3(x, y, z); +// final BlockVector3 pt = BlockVector3.at(x, y, z); // final BlockState block = getBlock(pt); // // if (block.getBlockType() == BlockTypes.DIRT || @@ -2783,11 +2783,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, switch (type.getTypeEnum()) { case GRASS: case DIRT: - treeType.generate(this, new BlockVector3(x, y + 1, z)); + treeType.generate(this, BlockVector3.at(x, y + 1, z)); this.changes++; break; case SNOW: - setBlock(new BlockVector3(x, y, z), BlockTypes.AIR.getDefaultState()); + setBlock(BlockVector3.at(x, y, z), BlockTypes.AIR.getDefaultState()); break; case AIR: case CAVE_AIR: @@ -2804,7 +2804,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ() // + size; ++z) { // // Don't want to be in the ground -// if (!getBlock(new BlockVector3(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) { +// if (!getBlock(BlockVector3.at(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) { // continue; // } // // The gods don't want a tree here @@ -2814,13 +2814,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // // for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) { // // Check if we hit the ground -// BlockType t = getBlock(new BlockVector3(x, y, z)).getBlockType(); +// BlockType t = getBlock(BlockVector3.at(x, y, z)).getBlockType(); // if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) { -// treeType.generate(this, new BlockVector3(x, y + 1, z)); +// treeType.generate(this, BlockVector3.at(x, y + 1, z)); // ++affected; // break; // } else if (t == BlockTypes.SNOW) { -// setBlock(new BlockVector3(x, y, z), BlockTypes.AIR.getDefaultState()); +// setBlock(BlockVector3.at(x, y, z), BlockTypes.AIR.getDefaultState()); // } else if (!t.getMaterial().isAir()) { // Trees won't grow on this! // break; } @@ -2959,7 +2959,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, //TODO Optimize - avoid vector creation (math) // final Vector3 current = mutablev.setComponents(x, y, z); // protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) { - final Vector3 current = new Vector3(x, y, z); + final Vector3 current = Vector3.at(x, y, z); environment.setCurrentBlock(current); final Vector3 scaled = current.subtract(zero).divide(unit); @@ -3069,22 +3069,22 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, for (int x = minX; x <= maxX; ++x) { for (int y = minY; y <= maxY; ++y) { - this.recurseHollow(region, new BlockVector3(x, y, minZ), outside); - this.recurseHollow(region, new BlockVector3(x, y, maxZ), outside); + this.recurseHollow(region, BlockVector3.at(x, y, minZ), outside); + this.recurseHollow(region, BlockVector3.at(x, y, maxZ), outside); } } for (int y = minY; y <= maxY; ++y) { for (int z = minZ; z <= maxZ; ++z) { - this.recurseHollow(region, new BlockVector3(minX, y, z), outside); - this.recurseHollow(region, new BlockVector3(maxX, y, z), outside); + this.recurseHollow(region, BlockVector3.at(minX, y, z), outside); + this.recurseHollow(region, BlockVector3.at(maxX, y, z), outside); } } for (int z = minZ; z <= maxZ; ++z) { for (int x = minX; x <= maxX; ++x) { - this.recurseHollow(region, new BlockVector3(x, minY, z), outside); - this.recurseHollow(region, new BlockVector3(x, maxY, z), outside); + this.recurseHollow(region, BlockVector3.at(x, minY, z), outside); + this.recurseHollow(region, BlockVector3.at(x, maxY, z), outside); } } @@ -3352,7 +3352,7 @@ 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 = new Vector2(x, z); + final Vector2 current = Vector2.at(x, z); environment.setCurrentBlock(current.toVector3(0)); final Vector2 scaled = current.subtract(zero2D).divide(unit2D); @@ -3459,7 +3459,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, final int cz = chunk.getBlockZ(); final int bx = cx << 4; final int bz = cz << 4; - final BlockVector3 cmin = new BlockVector3(bx, 0, bz); + final BlockVector3 cmin = BlockVector3.at(bx, 0, bz); final BlockVector3 cmax = cmin.add(15, getMaxY(), 15); final boolean containsBot1 = (fe == null || fe.contains(cmin.getBlockX(), cmin.getBlockY(), cmin.getBlockZ())); final boolean containsBot2 = region.contains(cmin); @@ -3481,7 +3481,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, int zz = z + bz; for (int y = 0; y < getMaxY() + 1; y++) { // BlockStateHolder block = getFullBlock(mutable.setComponents(xx, y, zz)); - BlockVector3 bv = new BlockVector3(xx, y, zz); + BlockVector3 bv = BlockVector3.at(xx, y, zz); BlockStateHolder block = getFullBlock(bv); fcs.add(mbv, block, BlockTypes.AIR.getDefaultState()); } @@ -3490,13 +3490,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } } else { if (!conNextX) { - setExistingBlocks(new BlockVector3(bx + 16, 0, bz), new BlockVector3(bx + 31, getMaxY(), bz + 15)); + setExistingBlocks(BlockVector3.at(bx + 16, 0, bz), BlockVector3.at(bx + 31, getMaxY(), bz + 15)); } if (!conNextZ) { - setExistingBlocks(new BlockVector3(bx, 0, bz + 16), new BlockVector3(bx + 15, getMaxY(), bz + 31)); + setExistingBlocks(BlockVector3.at(bx, 0, bz + 16), BlockVector3.at(bx + 15, getMaxY(), bz + 31)); } if (!chunks.contains(mutable2D.setComponents(cx + 1, cz + 1)) && !conNextX && !conNextZ) { - setExistingBlocks(new BlockVector3(bx + 16, 0, bz + 16), new BlockVector3(bx + 31, getMaxY(), bz + 31)); + setExistingBlocks(BlockVector3.at(bx + 16, 0, bz + 16), BlockVector3.at(bx + 31, getMaxY(), bz + 31)); } for (int x = 0; x < 16; x++) { int xx = x + bx; @@ -3506,7 +3506,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, mutable.mutZ(zz); for (int y = 0; y < getMaxY() + 1; y++) { mutable.mutY(y); - BlockVector3 mbv = new BlockVector3(xx, y, zz); + BlockVector3 mbv = BlockVector3.at(xx, y, zz); boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mbv); if (contains) { containsAny = true; 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 b80c5a261..d09251046 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -1154,7 +1154,7 @@ public class LocalSession implements TextureHolder { if (block != null) { // If it's null, we don't need to do anything. The old was already removed. Map tags = block.getNbtData().getValue(); - cuiTemporaryBlock = new BlockVector3( + cuiTemporaryBlock = BlockVector3.at( ((IntTag) tags.get("x")).getValue(), ((IntTag) tags.get("y")).getValue(), ((IntTag) tags.get("z")).getValue() diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/PlayerDirection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/PlayerDirection.java index 0c3aa122c..c28942b12 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/PlayerDirection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/PlayerDirection.java @@ -29,16 +29,16 @@ import com.sk89q.worldedit.util.Direction; */ public enum PlayerDirection { - NORTH(new Vector3(0, 0, -1), true), - NORTH_EAST((new Vector3(1, 0, -1)).normalize(), false), - EAST(new Vector3(1, 0, 0), true), - SOUTH_EAST((new Vector3(1, 0, 1)).normalize(), false), - SOUTH(new Vector3(0, 0, 1), true), - SOUTH_WEST((new Vector3(-1, 0, 1)).normalize(), false), - WEST(new Vector3(-1, 0, 0), true), - NORTH_WEST((new Vector3(-1, 0, -1)).normalize(), false), - UP(new Vector3(0, 1, 0), true), - DOWN(new Vector3(0, -1, 0), true); + NORTH(Vector3.at(0, 0, -1), true), + NORTH_EAST((Vector3.at(1, 0, -1)).normalize(), false), + EAST(Vector3.at(1, 0, 0), true), + SOUTH_EAST((Vector3.at(1, 0, 1)).normalize(), false), + SOUTH(Vector3.at(0, 0, 1), true), + SOUTH_WEST((Vector3.at(-1, 0, 1)).normalize(), false), + WEST(Vector3.at(-1, 0, 0), true), + NORTH_WEST((Vector3.at(-1, 0, -1)).normalize(), false), + UP(Vector3.at(0, 1, 0), true), + DOWN(Vector3.at(0, -1, 0), true); private final Vector3 dir; private final boolean isOrthogonal; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java index 7570f0aa8..542aef756 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java @@ -78,7 +78,7 @@ public class ChunkCommands { player.print(BBC.getPrefix() + "Chunk: " + chunkX + ", " + chunkZ); player.print(BBC.getPrefix() + "Old format: " + folder1 + "/" + folder2 + "/" + filename); player.print(BBC.getPrefix() + "McRegion: region/" + McRegionChunkStore.getFilename( - new BlockVector2(chunkX, chunkZ))); + BlockVector2.at(chunkX, chunkZ))); } @Command( 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 100ebe910..8595e1c3a 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 @@ -91,7 +91,7 @@ public class FlattenedClipboardTransform { maximum.withZ(minimum.getZ()) }; for (int i = 0; i < corners.length; i++) { - corners[i] = transformAround.apply(new Vector3(corners[i])); + corners[i] = transformAround.apply(corners[i]); } MutableVector newMinimum = new MutableVector(corners[0]); @@ -109,7 +109,7 @@ public class FlattenedClipboardTransform { newMinimum.mutY(Math.ceil(Math.floor(newMinimum.getY()))); newMinimum.mutZ(Math.ceil(Math.floor(newMinimum.getZ()))); - return new CuboidRegion(new BlockVector3(newMinimum.getX(), newMinimum.getY(), newMinimum.getZ()), new BlockVector3(newMaximum.getX(), newMaximum.getY(), newMaximum.getZ())); + return new CuboidRegion(BlockVector3.at(newMinimum.getX(), newMinimum.getY(), newMinimum.getZ()), BlockVector3.at(newMaximum.getX(), newMaximum.getY(), newMaximum.getZ())); } /** 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 9798f6c95..2bb5e5d5d 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 @@ -114,7 +114,7 @@ public class HistoryCommands extends MethodCommands { RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(world, uuid, Integer.parseInt(name.substring(0, name.length() - 3))); DiskStorageHistory.DiskStorageSummary summary = rollback.summarize(RegionWrapper.GLOBAL(), false); if (summary != null) { - rollback.setDimensions(new BlockVector3(summary.minX, 0, summary.minZ), new BlockVector3(summary.maxX, 255, summary.maxZ)); + rollback.setDimensions(BlockVector3.at(summary.minX, 0, summary.minZ), BlockVector3.at(summary.maxX, 255, summary.maxZ)); rollback.setTime(historyFile.lastModified()); RollbackDatabase db = DBHandler.IMP.getDatabase(world); db.logEdit(rollback); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java index e5d82d301..630ec56df 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java @@ -130,7 +130,7 @@ public class MaskCommands extends MethodCommands { max = 4 ) public Mask offset(double x, double y, double z, Mask mask) { - return new OffsetMask(mask, new BlockVector3(x, y, z)); + return new OffsetMask(mask, BlockVector3.at(x, y, z)); } @Command( @@ -390,7 +390,7 @@ public class MaskCommands extends MethodCommands { max = 1 ) public Mask below(Mask mask) throws ExpressionException { - OffsetMask offsetMask = new OffsetMask(mask, new BlockVector3(0, 1, 0)); + OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0)); return new MaskIntersection(offsetMask, Masks.negate(mask)); } @@ -402,7 +402,7 @@ public class MaskCommands extends MethodCommands { max = 1 ) public Mask above(Mask mask) throws ExpressionException { - OffsetMask offsetMask = new OffsetMask(mask, new BlockVector3(0, -1, 0)); + OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0)); return new MaskIntersection(offsetMask, Masks.negate(mask)); } 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 9db75d764..91317133f 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 @@ -120,7 +120,7 @@ public class RegionCommands extends MethodCommands { if (selection == null) { final int cx = loc.x >> 4; final int cz = loc.z >> 4; - selection = new CuboidRegion(new BlockVector3(cx - 8, 0, cz - 8).multiply(16), new BlockVector3(cx + 8, 0, cz + 8).multiply(16)); + selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); } int count = FaweAPI.fixLighting(loc.world, selection, FaweQueue.RelightMode.ALL); BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count); @@ -154,7 +154,7 @@ public class RegionCommands extends MethodCommands { if (selection == null) { final int cx = loc.x >> 4; final int cz = loc.z >> 4; - selection = new CuboidRegion(new BlockVector3(cx - 8, 0, cz - 8).multiply(16), new BlockVector3(cx + 8, 0, cz + 8).multiply(16)); + selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); } int count = FaweAPI.fixLighting(loc.world, selection, FaweQueue.RelightMode.NONE); BBC.UPDATED_LIGHTING_SELECTION.send(fp, count); @@ -624,7 +624,7 @@ public class RegionCommands extends MethodCommands { if (moveSelection) { try { final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); - BlockVector3 shiftVector = new BlockVector3(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count); + BlockVector3 shiftVector = BlockVector3.at(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count); region.shift(shiftVector); session.getRegionSelector(player.getWorld()).learnChanges(); 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 68774b64f..2c7ca62c3 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 @@ -110,7 +110,7 @@ public class SelectionCommands { if (args.argsLength() == 1) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { String[] coords = args.getString(0).split(","); - pos = new BlockVector3(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2])); + pos = BlockVector3.at(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2])); } else { BBC.SELECTOR_INVALID_COORDINATES.send(player, args.getString(0)); return; @@ -141,7 +141,7 @@ public class SelectionCommands { if (args.argsLength() == 1) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { String[] coords = args.getString(0).split(","); - pos = new BlockVector3(Integer.parseInt(coords[0]), + pos = BlockVector3.at(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2])); } else { @@ -237,8 +237,8 @@ public class SelectionCommands { final BlockVector2 min2D = ChunkStore.toChunk(region.getMinimumPoint()); final BlockVector2 max2D = ChunkStore.toChunk(region.getMaximumPoint()); - min = new BlockVector3(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); - max = new BlockVector3(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15); + min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); + max = BlockVector3.at(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15); BBC.SELECTION_CHUNKS.send(player, min2D.getBlockX() + ", " + min2D.getBlockZ(), max2D.getBlockX() + ", " + max2D.getBlockZ()); } else { @@ -251,14 +251,14 @@ public class SelectionCommands { } int x = Integer.parseInt(coords[0]); int z = Integer.parseInt(coords[1]); - BlockVector2 pos = new BlockVector2(x, z); + BlockVector2 pos = BlockVector2.at(x, z); min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toBlockVector3()); } else { // use player loc min2D = ChunkStore.toChunk(player.getBlockIn().toVector().toBlockPoint()); } - min = new BlockVector3(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); + min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); max = min.add(15, world.getMaxY(), 15); BBC.SELECTION_CHUNK.send(player, min2D.getBlockX() + ", " + min2D.getBlockZ()); @@ -328,8 +328,8 @@ public class SelectionCommands { try { int oldSize = region.getArea(); region.expand( - new BlockVector3(0, (player.getWorld().getMaxY() + 1), 0), - new BlockVector3(0, -(player.getWorld().getMaxY() + 1), 0)); + BlockVector3.at(0, (player.getWorld().getMaxY() + 1), 0), + BlockVector3.at(0, -(player.getWorld().getMaxY() + 1), 0)); session.getRegionSelector(player.getWorld()).learnChanges(); int newSize = region.getArea(); session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); @@ -567,15 +567,15 @@ public class SelectionCommands { int change = args.getInteger(0); if (!args.hasFlag('h')) { - changes.add((new BlockVector3(0, 1, 0)).multiply(change)); - changes.add((new BlockVector3(0, -1, 0)).multiply(change)); + changes.add((BlockVector3.at(0, 1, 0)).multiply(change)); + changes.add((BlockVector3.at(0, -1, 0)).multiply(change)); } if (!args.hasFlag('v')) { - changes.add((new BlockVector3(1, 0, 0)).multiply(change)); - changes.add((new BlockVector3(-1, 0, 0)).multiply(change)); - changes.add((new BlockVector3(0, 0, 1)).multiply(change)); - changes.add((new BlockVector3(0, 0, -1)).multiply(change)); + changes.add((BlockVector3.at(1, 0, 0)).multiply(change)); + changes.add((BlockVector3.at(-1, 0, 0)).multiply(change)); + changes.add((BlockVector3.at(0, 0, 1)).multiply(change)); + changes.add((BlockVector3.at(0, 0, -1)).multiply(change)); } return changes.toArray(new BlockVector3[0]); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java index 1875b9f30..2f51cdda5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java @@ -204,7 +204,7 @@ public class DefaultMaskParser extends FaweParser { // } else { // submask = new ExistingBlockMask(extent); // } -// OffsetMask offsetMask = new OffsetMask(submask, new BlockVector3(0, firstChar == '>' ? -1 : 1, 0)); +// OffsetMask offsetMask = new OffsetMask(submask, BlockVector3.at(0, firstChar == '>' ? -1 : 1, 0)); // return new MaskIntersection(offsetMask, Masks.negate(submask)); // // case '$': @@ -217,7 +217,7 @@ public class DefaultMaskParser extends FaweParser { // BaseBiome biome = Biomes.findBiomeByName(knownBiomes, biomeName, biomeRegistry); // if (biome == null) { // throw new InputParseException("Unknown biome '" + biomeName + '\''); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching } } //<<<<<<< HEAD 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 2d781077d..f62647bff 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 @@ -115,7 +115,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { byte free = 0; while (y <= world.getMaximumPoint().getBlockY() + 2) { - if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { ++free; } else { free = 0; @@ -123,10 +123,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (free == 2) { if (y - 1 != origY) { - final BlockVector3 pos = new BlockVector3(x, y - 2, z); + final BlockVector3 pos = BlockVector3.at(x, y - 2, z); final BlockStateHolder state = world.getBlock(pos); - setPosition(new Vector3(x + 0.5, y - 2 + BlockType.centralTopLimit(state), z + 0.5)); -// setPosition(new Vector3(x + 0.5, y - 2 + 1, z + 0.5)); + setPosition(Vector3.at(x + 0.5, y - 2 + BlockType.centralTopLimit(state), z + 0.5)); +// setPosition(Vector3.at(x + 0.5, y - 2 + 1, z + 0.5)); } return; @@ -144,10 +144,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { int z = searchPos.getBlockZ(); while (y >= 0) { - final BlockVector3 pos = new BlockVector3(x, y, z); + final BlockVector3 pos = BlockVector3.at(x, y, z); final BlockState id = world.getBlock(pos); if (id.getBlockType().getMaterial().isMovementBlocker()) { - setPosition(new Vector3(x + 0.5, y + + BlockType.centralTopLimit(id), z + 0.5)); + setPosition(Vector3.at(x + 0.5, y + + BlockType.centralTopLimit(id), z + 0.5)); return; } @@ -171,7 +171,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { int maxY = world.getMaxY(); if (y >= maxY) return false; - BlockMaterial initialMaterial = world.getBlockType(new BlockVector3(x, y, z)).getMaterial(); + BlockMaterial initialMaterial = world.getBlockType(BlockVector3.at(x, y, z)).getMaterial(); boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube(); @@ -181,7 +181,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { for (int level = y + 1; level <= maxY + 2; level++) { BlockState state; if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState(); - else state = world.getBlock(new BlockVector3(x, level, z)); + else state = world.getBlock(BlockVector3.at(x, level, z)); BlockTypes type = state.getBlockType(); BlockMaterial material = type.getMaterial(); @@ -196,7 +196,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { double bottomLimit = BlockType.centralBottomLimit(state); double space = level + bottomLimit - freeStart; if (space >= height) { - setPosition(new Vector3(x + 0.5, freeStart, z + 0.5)); + setPosition(Vector3.at(x + 0.5, freeStart, z + 0.5)); return true; } // Not enough room, reset the free position @@ -220,7 +220,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { final int z = pos.getBlockZ(); final Extent world = pos.getExtent(); - BlockMaterial initialMaterial = world.getBlockType(new BlockVector3(x, y, z)).getMaterial(); + BlockMaterial initialMaterial = world.getBlockType(BlockVector3.at(x, y, z)).getMaterial(); boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube(); @@ -233,7 +233,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { for (int level = y + 1; level > 0; level--) { BlockState state; if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState(); - else state = world.getBlock(new BlockVector3(x, level, z)); + else state = world.getBlock(BlockVector3.at(x, level, z)); BlockTypes type = state.getBlockType(); BlockMaterial material = type.getMaterial(); @@ -249,7 +249,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { double freeStart = level + topLimit; double space = freeEnd - freeStart; if (space >= height) { - setPosition(new Vector3(x + 0.5, freeStart, z + 0.5)); + setPosition(Vector3.at(x + 0.5, freeStart, z + 0.5)); return true; } // Not enough room, reset the free position @@ -280,13 +280,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { Extent world = getLocation().getExtent(); // No free space above - if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir()) { + if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir()) { return false; } while (y <= world.getMaximumPoint().getY()) { // Found a ceiling! - if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { int platformY = Math.max(initialY, y - 3 - clearance); floatAt(x, platformY + 1, z, alwaysGlass); return true; @@ -314,7 +314,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { final Extent world = getLocation().getExtent(); while (y <= world.getMaximumPoint().getY() + 2) { - if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { break; // Hit something } else if (y > maxY + 1) { break; @@ -332,14 +332,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public void floatAt(int x, int y, int z, boolean alwaysGlass) { try { - BlockVector3 spot = new BlockVector3(x, y - 1, z); + BlockVector3 spot = BlockVector3.at(x, y - 1, z); if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) { getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState()); } }catch (WorldEditException e) { e.printStackTrace(); } - setPosition(new Vector3(x + 0.5, y, z + 0.5)); + setPosition(Vector3.at(x + 0.5, y, z + 0.5)); } @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 99bddddd6..ca9140269 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 @@ -129,7 +129,7 @@ public class AbstractDelegateExtent implements LightingExtent { // mutable.mutX(x); // mutable.mutY(y); // mutable.mutZ(z); - return extent.getLazyBlock(new BlockVector3(x, y, z)); + return extent.getLazyBlock(BlockVector3.at(x, y, z)); } @Override @@ -142,7 +142,7 @@ public class AbstractDelegateExtent implements LightingExtent { // mutable.mutX(x); // mutable.mutY(y); // mutable.mutZ(z); - return setBlock(new BlockVector3(x, y, z), block); + return setBlock(BlockVector3.at(x, y, z), block); } public BlockState getBlock(BlockVector3 position) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index caf69d24b..74896c8cf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -127,15 +127,15 @@ public interface Extent extends InputExtent, OutputExtent { } default BlockState getLazyBlock(int x, int y, int z) { - return getLazyBlock(new BlockVector3(x, y, z)); + return getLazyBlock(BlockVector3.at(x, y, z)); } default boolean setBlock(int x, int y, int z, BlockStateHolder state) throws WorldEditException { - return setBlock(new BlockVector3(x, y, z), state); + return setBlock(BlockVector3.at(x, y, z), state); } default boolean setBiome(int x, int y, int z, BaseBiome biome) { - return setBiome(new BlockVector2(x, z), biome); + return setBiome(BlockVector2.at(x, z), biome); } default int getHighestTerrainBlock(final int x, final int z, int minY, int maxY) { 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 6e4aa0560..1af6018ec 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 @@ -84,7 +84,7 @@ public class MaskingExtent extends AbstractDelegateExtent { @Override public boolean setBiome(int x, int y, int z, BaseBiome biome) { - return mask.test(new BlockVector3(x, y, z)) && super.setBiome(x, y, z, biome); + return mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java index fd7d501e1..7a9269704 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java @@ -52,7 +52,7 @@ import java.util.List; */ public class NullExtent implements Extent { - private final BlockVector3 nullPoint = new BlockVector3(0, 0, 0); + private final BlockVector3 nullPoint = BlockVector3.at(0, 0, 0); public static final NullExtent INSTANCE = new NullExtent(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java index 5538f822d..8096ac5f7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java @@ -31,7 +31,6 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionOperationException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/cache/LastAccessExtentCache.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/cache/LastAccessExtentCache.java index b13a76c4d..fa120c4fd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/cache/LastAccessExtentCache.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/cache/LastAccessExtentCache.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.extent.cache; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.block.BlockState; /** 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 502ede4db..1e21634d8 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 @@ -312,11 +312,11 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable @Override public int getOpacity(int x, int y, int z) { - return getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().getLightOpacity(); + return getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().getLightOpacity(); } @Override public int getBrightness(int x, int y, int z) { - return getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().getLightValue(); + return getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().getLightValue(); } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java index c74132127..cd88d8571 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java @@ -117,12 +117,12 @@ public class MCEditSchematicReader extends NBTSchematicReader { int originX = requireTag(schematic, "WEOriginX", IntTag.class).getValue(); int originY = requireTag(schematic, "WEOriginY", IntTag.class).getValue(); int originZ = requireTag(schematic, "WEOriginZ", IntTag.class).getValue(); - BlockVector3 min = new BlockVector3(originX, originY, originZ); + BlockVector3 min = BlockVector3.at(originX, originY, originZ); int offsetX = requireTag(schematic, "WEOffsetX", IntTag.class).getValue(); int offsetY = requireTag(schematic, "WEOffsetY", IntTag.class).getValue(); int offsetZ = requireTag(schematic, "WEOffsetZ", IntTag.class).getValue(); - BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ); + BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ); origin = min.subtract(offset); region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); @@ -206,7 +206,7 @@ public class MCEditSchematicReader extends NBTSchematicReader { } } - BlockVector3 vec = new BlockVector3(x, y, z); + BlockVector3 vec = BlockVector3.at(x, y, z); tileEntitiesMap.put(vec, values); } @@ -220,7 +220,7 @@ public class MCEditSchematicReader extends NBTSchematicReader { for (int y = 0; y < height; ++y) { for (int z = 0; z < length; ++z) { int index = y * width * length + z * width + x; - BlockVector3 pt = new BlockVector3(x, y, z); + BlockVector3 pt = BlockVector3.at(x, y, z); BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]); try { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index 2de82f502..9a9abe70e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -122,14 +122,28 @@ public class SpongeSchematicReader extends NBTSchematicReader { private FaweClipboard setupClipboard(int size, UUID uuid) { if (fc != null) { if (fc.getDimensions().getX() == 0) { - fc.setDimensions(new BlockVector3(size, 1, 1)); + fc.setDimensions(BlockVector3.at(size, 1, 1)); } return fc; } +//<<<<<<< HEAD if (Settings.IMP.CLIPBOARD.USE_DISK) { return fc = new DiskOptimizedClipboard(size, 1, 1, uuid); } else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) { return fc = new CPUOptimizedClipboard(size, 1, 1); +//======= +// +// BlockVector3 min = BlockVector3.at(offsetParts[0], offsetParts[1], offsetParts[2]); +// +// if (metadata.containsKey("WEOffsetX")) { +// // We appear to have WorldEdit Metadata +// int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue(); +// int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue(); +// int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue(); +// BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ); +// origin = min.subtract(offset); +// region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching } else { return fc = new MemoryOptimizedClipboard(size, 1, 1); } @@ -310,7 +324,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { private Clipboard readVersion1(UUID uuid) throws IOException { width = height = length = offsetX = offsetY = offsetZ = Integer.MIN_VALUE; - final BlockArrayClipboard clipboard = new BlockArrayClipboard(new CuboidRegion(new BlockVector3(0, 0, 0), new BlockVector3(0, 0, 0)), fc); + final BlockArrayClipboard clipboard = new BlockArrayClipboard(new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(0, 0, 0)), fc); FastByteArrayOutputStream blocksOut = new FastByteArrayOutputStream(); FastByteArrayOutputStream biomesOut = new FastByteArrayOutputStream(); @@ -318,7 +332,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { streamer.addReader("Schematic.Width", (BiConsumer) (i, v) -> width = v); streamer.addReader("Schematic.Height", (BiConsumer) (i, v) -> height = v); streamer.addReader("Schematic.Length", (BiConsumer) (i, v) -> length = v); - streamer.addReader("Schematic.Offset", (BiConsumer) (i, v) -> min = new BlockVector3(v[0], v[1], v[2])); + streamer.addReader("Schematic.Offset", (BiConsumer) (i, v) -> min = BlockVector3.at(v[0], v[1], v[2])); streamer.addReader("Schematic.Metadata.WEOffsetX", (BiConsumer) (i, v) -> offsetX = v); streamer.addReader("Schematic.Metadata.WEOffsetY", (BiConsumer) (i, v) -> offsetY = v); streamer.addReader("Schematic.Metadata.WEOffsetZ", (BiConsumer) (i, v) -> offsetZ = v); @@ -329,6 +343,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { int index = ((IntTag) entry.getValue()).getValue(); palette[index] = (char) state.getOrdinal(); } +//<<<<<<< HEAD }); streamer.addReader("Schematic.BlockData.#", new NBTStreamer.LazyReader() { @Override @@ -338,6 +353,23 @@ public class SpongeSchematicReader extends NBTSchematicReader { } catch (IOException e) { e.printStackTrace(); } +//======= +// palette.put(id, state); +// } +// +// byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue(); +// +// Map> tileEntitiesMap = new HashMap<>(); +// try { +// List> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream() +// .map(tag -> (CompoundTag) tag) +// .map(CompoundTag::getValue) +// .collect(Collectors.toList()); +// +// for (Map tileEntity : tileEntityTags) { +// int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue(); +// tileEntitiesMap.put(BlockVector3.at(pos[0], pos[1], pos[2]), tileEntity); +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching } }); streamer.addReader("Schematic.Biomes.#", new NBTStreamer.LazyReader() { @@ -362,6 +394,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { int z = pos[2]; fc.setTile(x, y, z, value); } +//<<<<<<< HEAD }); streamer.addReader("Schematic.Entities.#", new BiConsumer() { @Override @@ -390,7 +423,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { BlockVector3 origin = min; CuboidRegion region; if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) { - origin = origin.subtract(new BlockVector3(offsetX, offsetY, offsetZ)); + origin = origin.subtract(BlockVector3.at(offsetX, offsetY, offsetZ)); region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); } else { region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); @@ -402,6 +435,21 @@ public class SpongeSchematicReader extends NBTSchematicReader { for (int index = 0; index < volume; index++) { BlockState state = BlockTypes.states[palette[fis.read()]]; fc.setBlock(index, state); +//======= +// // index = (y * length + z) * width + x +// int y = index / (width * length); +// int z = (index % (width * length)) / width; +// int x = (index % (width * length)) % width; +// BlockState state = palette.get(value); +// BlockVector3 pt = BlockVector3.at(x, y, z); +// try { +// if (tileEntitiesMap.containsKey(pt)) { +// Map values = Maps.newHashMap(tileEntitiesMap.get(pt)); +// for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) { +// if (handler.isAffectedBlock(state)) { +// handler.updateNBT(state, values); +// } +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching } } else { for (int index = 0; index < volume; index++) { @@ -419,7 +467,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { } } } - fc.setDimensions(new BlockVector3(width, height, length)); + fc.setDimensions(BlockVector3.at(width, height, length)); clipboard.init(region, fc); clipboard.setOrigin(origin); return clipboard; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java index 0c99deb7e..62f917239 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java @@ -178,13 +178,13 @@ public class SpongeSchematicWriter implements ClipboardWriter { // int z0 = min.getBlockZ() + z; // for (int x = 0; x < width; x++) { // int x0 = min.getBlockX() + x; -// BlockVector3 point = new BlockVector3(x0, y0, z0); +// BlockVector3 point = BlockVector3.at(x0, y0, z0); // BaseBlock block = clipboard.getFullBlock(point); // if (block.getNbtData() != null) { // Map values = new HashMap<>(); // for (Map.Entry entry : block.getNbtData().getValue().entrySet()) { // values.put(entry.getKey(), entry.getValue()); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching } int ordinal = block.getOrdinal(); char value = palette[ordinal]; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java index 92a3b6188..9c9947729 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java @@ -77,7 +77,7 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent { if (!enabled) { return getExtent().setBlock(location, block); } - BlockVector2 chunkPos = new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4); + BlockVector2 chunkPos = BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4); batches.computeIfAbsent(chunkPos, k -> new LocatedBlockList()).add(location, block); return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java index d374017fa..be7e77daa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java @@ -89,7 +89,7 @@ public class FastModeExtent extends AbstractDelegateExtent { @Override public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { if (enabled) { - dirtyChunks.add(new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4)); + dirtyChunks.add(BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4)); return world.setBlock(location, block, false); } else { return world.setBlock(location, block, true); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java index 530df4894..87d7c24e0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java @@ -93,7 +93,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent { @Override public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException { if (toolUse && block.getBlockType().getMaterial().isAir()) { - world.simulateBlockMine(new BlockVector3(x, y, z)); + world.simulateBlockMine(BlockVector3.at(x, y, z)); return true; } else { return super.setBlock(x, y, z, block); 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 2cfa5720d..6f6c0e766 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 @@ -163,12 +163,16 @@ public class ExtentEntityCopy implements EntityFunction { boolean hasFacing = tag.containsKey("Facing"); if (hasTilePosition) { +<<<<<<< HEAD //<<<<<<< HEAD changed = true; // Vector tilePosition = new Vector(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")); // Vector newTilePosition = transform.apply(tilePosition.subtract(from)).add(to); //======= Vector3 tilePosition = new Vector3(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")); +======= + Vector3 tilePosition = Vector3.at(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")); +>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching BlockVector3 newTilePosition = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint(); //>>>>>>> 399e0ad5... Refactor vector system to be cleaner 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 75487bc3e..81d344b16 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 @@ -43,14 +43,14 @@ public class BackwardsExtentBlockCopy implements Operation { } private CuboidRegion transform(Transform transform, Region region) { - BlockVector3 min = new BlockVector3(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - BlockVector3 max = new BlockVector3(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); + BlockVector3 min = BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); + BlockVector3 max = BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); BlockVector3 pos1 = region.getMinimumPoint(); BlockVector3 pos2 = region.getMaximumPoint(); for (int x : new int[] { pos1.getBlockX(), pos2.getBlockX() }) { for (int y : new int[] { pos1.getBlockY(), pos2.getBlockY() }) { for (int z : new int[] { pos1.getBlockZ(), pos2.getBlockZ() }) { - BlockVector3 pt = transform(transform, new BlockVector3(x, y, z)); + BlockVector3 pt = transform(transform, BlockVector3.at(x, y, z)); min = min.getMinimum(pt); max = max.getMaximum(pt); } @@ -68,7 +68,7 @@ public class BackwardsExtentBlockCopy implements Operation { // tmp.mutY((tmp.getBlockY() + origin.getBlockY())); // tmp.mutZ((tmp.getBlockZ() + origin.getBlockZ())); // return tmp; - return transform.apply(new Vector3(pt.getBlockX() - origin.getBlockX(), pt.getBlockY() - origin.getBlockY(), pt.getBlockZ() - origin.getBlockZ())).toBlockPoint().add(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ()); + return transform.apply(Vector3.at(pt.getBlockX() - origin.getBlockX(), pt.getBlockY() - origin.getBlockY(), pt.getBlockZ() - origin.getBlockZ())).toBlockPoint().add(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ()); } @Override 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 b2b5e5451..2cbabced0 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 @@ -48,7 +48,6 @@ import com.sk89q.worldedit.function.visitor.IntersectRegionFunction; import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.Identity; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.Region; @@ -322,7 +321,7 @@ public class ForwardExtentCopy implements Operation { int z = translation.getBlockZ(); maskFunc = position -> { - BlockVector3 bv = new BlockVector3(position.getBlockX() + x, position.getBlockY() + y, position.getBlockZ() + z); + BlockVector3 bv = BlockVector3.at(position.getBlockX() + x, position.getBlockY() + y, position.getBlockZ() + z); if (region.contains(bv)) { return sourceFunction.apply(bv); } @@ -330,7 +329,7 @@ public class ForwardExtentCopy implements Operation { }; copySrcFunc = position -> { - BlockVector3 bv = new BlockVector3(position.getBlockX() - x, position.getBlockY() - y, position.getBlockZ() - z); + BlockVector3 bv = BlockVector3.at(position.getBlockX() - x, position.getBlockY() - y, position.getBlockZ() - z); if (!region.contains(bv)) { return sourceFunction.apply(position); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java index ed255cb5c..574a884c4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java @@ -45,7 +45,7 @@ public class ClipboardPattern extends AbstractPattern { if (xp < 0) xp += sx; if (yp < 0) yp += sy; if (zp < 0) zp += sz; - return clipboard.getBlock(new BlockVector3(min.getX() + xp, min.getY() + yp, min.getZ() + zp)); + return clipboard.getBlock(BlockVector3.at(min.getX() + xp, min.getY() + yp, min.getZ() + zp)); //======= // public BlockStateHolder apply(BlockVector3 position) { // int xp = Math.abs(position.getBlockX()) % size.getBlockX(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java index 73acb9bc1..776359d5c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java @@ -46,7 +46,7 @@ public interface Pattern extends com.sk89q.worldedit.patterns.Pattern{ @Override default BaseBlock next(int x, int y, int z) { - return new BaseBlock(apply(new BlockVector3(x, y, z))); + return new BaseBlock(apply(BlockVector3.at(x, y, z))); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java index 87f7a2fb4..7f68c536e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java @@ -93,10 +93,6 @@ public class RepeatingExtentPattern extends AbstractPattern { int x = base.getBlockX() % size.getBlockX(); int y = base.getBlockY() % size.getBlockY(); int z = base.getBlockZ() % size.getBlockZ(); -//<<<<<<< HEAD -// return extent.getBlock(new Vector(x, y, z)); -//======= - return extent.getFullBlock(new BlockVector3(x, y, z)); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner + return extent.getFullBlock(BlockVector3.at(x, y, z)); } } 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 cad3e5bb7..8e1359b27 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 @@ -44,18 +44,18 @@ public abstract class BreadthFirstSearch implements Operation { public static final BlockVector3[] DIAGONAL_DIRECTIONS; static { - DEFAULT_DIRECTIONS[0] = (new BlockVector3(0, -1, 0)); - DEFAULT_DIRECTIONS[1] = (new BlockVector3(0, 1, 0)); - DEFAULT_DIRECTIONS[2] = (new BlockVector3(-1, 0, 0)); - DEFAULT_DIRECTIONS[3] = (new BlockVector3(1, 0, 0)); - DEFAULT_DIRECTIONS[4] = (new BlockVector3(0, 0, -1)); - DEFAULT_DIRECTIONS[5] = (new BlockVector3(0, 0, 1)); + DEFAULT_DIRECTIONS[0] = (BlockVector3.at(0, -1, 0)); + DEFAULT_DIRECTIONS[1] = (BlockVector3.at(0, 1, 0)); + DEFAULT_DIRECTIONS[2] = (BlockVector3.at(-1, 0, 0)); + DEFAULT_DIRECTIONS[3] = (BlockVector3.at(1, 0, 0)); + DEFAULT_DIRECTIONS[4] = (BlockVector3.at(0, 0, -1)); + DEFAULT_DIRECTIONS[5] = (BlockVector3.at(0, 0, 1)); List list = new ArrayList<>(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { for (int z = -1; z <= 1; z++) { if (x != 0 || y != 0 || z != 0) { - BlockVector3 pos = new BlockVector3(x, y, z); + BlockVector3 pos = BlockVector3.at(x, y, z); if (!list.contains(pos)) { list.add(pos); } @@ -100,10 +100,6 @@ public abstract class BreadthFirstSearch implements Operation { this.maxDepth = maxDepth; } - public Collection getDirections() { - return this.directions; - } - public void setDirections(List directions) { this.directions = directions; } @@ -116,6 +112,44 @@ public abstract class BreadthFirstSearch implements Operation { } return array; } + + /** + * Get the list of directions will be visited. + * + *

Directions are {@link BlockVector3}s that determine + * what adjacent points area available. Vectors should not be + * unit vectors. An example of a valid direction is + * {@code BlockVector3.at(1, 0, 1)}.

+ * + *

The list of directions can be cleared.

+ * + * @return the list of directions + */ + protected Collection getDirections() { + return directions; + } + + /** + * Add the directions along the axes as directions to visit. + */ + protected void addAxes() { + directions.add(BlockVector3.at(0, -1, 0)); + directions.add(BlockVector3.at(0, 1, 0)); + directions.add(BlockVector3.at(-1, 0, 0)); + directions.add(BlockVector3.at(1, 0, 0)); + directions.add(BlockVector3.at(0, 0, -1)); + directions.add(BlockVector3.at(0, 0, 1)); + } + + /** + * Add the diagonal directions as directions to visit. + */ + protected void addDiagonal() { + directions.add(BlockVector3.at(1, 0, 1)); + directions.add(BlockVector3.at(-1, 0, -1)); + directions.add(BlockVector3.at(1, 0, -1)); + directions.add(BlockVector3.at(-1, 0, 1)); + } public void visit(final BlockVector3 pos) { if (!isVisited(pos)) { @@ -223,7 +257,7 @@ public abstract class BreadthFirstSearch implements Operation { int x = from.getBlockX() + direction.x; int z = from.getBlockZ() + direction.z; if (!visited.contains(x, y, z)) { - if (isVisitable(from, new BlockVector3(x, y, z))) { + if (isVisitable(from, BlockVector3.at(x, y, z))) { j++; visited.add(x, y, z); tempQueue.add(x, y, z); 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 f74c7c4ae..069aaff4a 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 @@ -53,12 +53,12 @@ public class DirectionalVisitor extends RecursiveVisitor { this.dirVec = direction; final Collection directions = this.getDirections(); directions.clear(); - directions.add(new BlockVector3(1, 0, 0)); - directions.add(new BlockVector3(-1, 0, 0)); - directions.add(new BlockVector3(0, 0, 1)); - directions.add(new BlockVector3(0, 0, -1)); - directions.add(new BlockVector3(0, -1, 0)); - directions.add(new BlockVector3(0, 1, 0)); + directions.add(BlockVector3.at(1, 0, 0)); + directions.add(BlockVector3.at(-1, 0, 0)); + directions.add(BlockVector3.at(0, 0, 1)); + directions.add(BlockVector3.at(0, 0, -1)); + directions.add(BlockVector3.at(0, -1, 0)); + directions.add(BlockVector3.at(0, 1, 0)); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java index 17f7f3769..a3a8dac66 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java @@ -62,11 +62,11 @@ public class DownwardVisitor extends RecursiveVisitor { Collection directions = getDirections(); directions.clear(); - directions.add(new BlockVector3(1, 0, 0)); - directions.add(new BlockVector3(-1, 0, 0)); - directions.add(new BlockVector3(0, 0, 1)); - directions.add(new BlockVector3(0, 0, -1)); - directions.add(new BlockVector3(0, -1, 0)); + directions.add(BlockVector3.at(1, 0, 0)); + directions.add(BlockVector3.at(-1, 0, 0)); + directions.add(BlockVector3.at(0, 0, 1)); + directions.add(BlockVector3.at(0, 0, -1)); + directions.add(BlockVector3.at(0, -1, 0)); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/NonRisingVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/NonRisingVisitor.java index 5acf895a2..7e79e57a7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/NonRisingVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/NonRisingVisitor.java @@ -48,11 +48,11 @@ public class NonRisingVisitor extends RecursiveVisitor { super(mask, function, depth, hasFaweQueue); Collection directions = getDirections(); directions.clear(); - directions.add(new BlockVector3(1, 0, 0)); - directions.add(new BlockVector3(-1, 0, 0)); - directions.add(new BlockVector3(0, 0, 1)); - directions.add(new BlockVector3(0, 0, -1)); - directions.add(new BlockVector3(0, -1, 0)); + directions.add(BlockVector3.at(1, 0, 0)); + directions.add(BlockVector3.at(-1, 0, 0)); + directions.add(BlockVector3.at(0, 0, 1)); + directions.add(BlockVector3.at(0, 0, -1)); + directions.add(BlockVector3.at(0, -1, 0)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java index e685c7fe3..9edc43d2c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java @@ -397,7 +397,7 @@ public final class Functions { } catch (IllegalArgumentException e) { throw new EvaluationException(0, "Perlin noise error: " + e.getMessage()); } - return perlin.noise(new Vector3(x.getValue(), y.getValue(), z.getValue())); + return perlin.noise(Vector3.at(x.getValue(), y.getValue(), z.getValue())); } private static final ThreadLocal localVoronoi = ThreadLocal.withInitial(VoronoiNoise::new); @@ -410,7 +410,7 @@ public final class Functions { } catch (IllegalArgumentException e) { throw new EvaluationException(0, "Voronoi error: " + e.getMessage()); } - return voronoi.noise(new Vector3(x.getValue(), y.getValue(), z.getValue())); + return voronoi.noise(Vector3.at(x.getValue(), y.getValue(), z.getValue())); } private static final ThreadLocal localRidgedMulti = ThreadLocal.withInitial(RidgedMultiFractalNoise::new); @@ -424,7 +424,7 @@ public final class Functions { } catch (IllegalArgumentException e) { throw new EvaluationException(0, "Ridged multi error: " + e.getMessage()); } - return ridgedMulti.noise(new Vector3(x.getValue(), y.getValue(), z.getValue())); + return ridgedMulti.noise(Vector3.at(x.getValue(), y.getValue(), z.getValue())); } private static double queryInternal(RValue type, RValue data, double typeId, double dataValue) throws EvaluationException { 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 ab9b74064..26de9ff3d 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 @@ -55,6 +55,26 @@ public class BlockVector2 { .result(); }; + public static BlockVector2 at(double x, double z) { + return at((int) Math.floor(x), (int) Math.floor(z)); + } + + 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; /** @@ -63,17 +83,7 @@ public class BlockVector2 { * @param x the X coordinate * @param z the Z coordinate */ - public BlockVector2(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 BlockVector2(int x, int z) { + private BlockVector2(int x, int z) { this.x = x; this.z = z; } @@ -103,7 +113,7 @@ public class BlockVector2 { * @return a new vector */ public BlockVector2 withX(int x) { - return new BlockVector2(x, z); + return BlockVector2.at(x, z); } /** @@ -131,7 +141,7 @@ public class BlockVector2 { * @return a new vector */ public BlockVector2 withZ(int z) { - return new BlockVector2(x, z); + return BlockVector2.at(x, z); } /** @@ -152,7 +162,7 @@ public class BlockVector2 { * @return a new vector */ public BlockVector2 add(int x, int z) { - return new BlockVector2(this.x + x, this.z + z); + return BlockVector2.at(this.x + x, this.z + z); } /** @@ -170,7 +180,7 @@ public class BlockVector2 { newZ += other.z; } - return new BlockVector2(newX, newZ); + return BlockVector2.at(newX, newZ); } /** @@ -193,7 +203,7 @@ public class BlockVector2 { * @return a new vector */ public BlockVector2 subtract(int x, int z) { - return new BlockVector2(this.x - x, this.z - z); + return BlockVector2.at(this.x - x, this.z - z); } /** @@ -211,7 +221,7 @@ public class BlockVector2 { newZ -= other.z; } - return new BlockVector2(newX, newZ); + return BlockVector2.at(newX, newZ); } /** @@ -232,7 +242,7 @@ public class BlockVector2 { * @return a new vector */ public BlockVector2 multiply(int x, int z) { - return new BlockVector2(this.x * x, this.z * z); + return BlockVector2.at(this.x * x, this.z * z); } /** @@ -249,7 +259,7 @@ public class BlockVector2 { newZ *= other.z; } - return new BlockVector2(newX, newZ); + return BlockVector2.at(newX, newZ); } /** @@ -280,7 +290,7 @@ public class BlockVector2 { * @return a new vector */ public BlockVector2 divide(int x, int z) { - return new BlockVector2(this.x / x, this.z / z); + return BlockVector2.at(this.x / x, this.z / z); } /** @@ -343,7 +353,7 @@ public class BlockVector2 { double len = length(); double x = this.x / len; double z = this.z / len; - return new BlockVector2(x, z); + return BlockVector2.at(x, z); } /** @@ -407,7 +417,7 @@ public class BlockVector2 { * @return a new vector */ public BlockVector2 abs() { - return new BlockVector2(Math.abs(x), Math.abs(z)); + return BlockVector2.at(Math.abs(x), Math.abs(z)); } /** @@ -429,7 +439,7 @@ public class BlockVector2 { double sin = Math.sin(angle); double x2 = x * cos - z * sin; double z2 = x * sin + z * cos; - return new BlockVector2( + return BlockVector2.at( x2 + aboutX + translateX, z2 + aboutZ + translateZ); } @@ -461,7 +471,7 @@ public class BlockVector2 { } public Vector2 toVector2() { - return new Vector2(x, z); + return Vector2.at(x, z); } /** @@ -480,7 +490,7 @@ public class BlockVector2 { * @return a new vector */ public Vector3 toVector3(double y) { - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } /** @@ -499,7 +509,7 @@ public class BlockVector2 { * @return a new vector */ public BlockVector3 toBlockVector3(int y) { - return new BlockVector3(x, y, z); + return BlockVector3.at(x, y, z); } @Override 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 d3c6e1be5..cda4e5414 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 @@ -37,6 +37,28 @@ public class BlockVector3 { public static final BlockVector3 UNIT_Z = new BlockVector3(0, 0, 1); public static final BlockVector3 ONE = new BlockVector3(1, 1, 1); + public static BlockVector3 at(double x, double y, double z) { + return at((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z)); + } + + 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); + } + // thread-safe initialization idiom private static final class YzxOrderComparator { private static final Comparator YZX_ORDER = (a, b) -> { @@ -67,18 +89,7 @@ public class BlockVector3 { * @param y the Y coordinate * @param z the Z coordinate */ - public BlockVector3(double x, double y, double z) { - this((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z)); - } - - /** - * Construct an instance. - * - * @param x the X coordinate - * @param y the Y coordinate - * @param z the Z coordinate - */ - public BlockVector3(int x, int y, int z) { + private BlockVector3(int x, int y, int z) { this.x = x; this.y = y; this.z = z; @@ -109,7 +120,7 @@ public class BlockVector3 { * @return a new vector */ public BlockVector3 withX(int x) { - return new BlockVector3(x, y, z); + return BlockVector3.at(x, y, z); } /** @@ -137,7 +148,7 @@ public class BlockVector3 { * @return a new vector */ public BlockVector3 withY(int y) { - return new BlockVector3(x, y, z); + return BlockVector3.at(x, y, z); } /** @@ -165,7 +176,7 @@ public class BlockVector3 { * @return a new vector */ public BlockVector3 withZ(int z) { - return new BlockVector3(x, y, z); + return BlockVector3.at(x, y, z); } /** @@ -187,7 +198,7 @@ public class BlockVector3 { * @return a new vector */ public BlockVector3 add(int x, int y, int z) { - return new BlockVector3(this.x + x, this.y + y, this.z + z); + return BlockVector3.at(this.x + x, this.y + y, this.z + z); } /** @@ -206,7 +217,7 @@ public class BlockVector3 { newZ += other.z; } - return new BlockVector3(newX, newY, newZ); + return BlockVector3.at(newX, newY, newZ); } /** @@ -230,7 +241,7 @@ public class BlockVector3 { * @return a new vector */ public BlockVector3 subtract(int x, int y, int z) { - return new BlockVector3(this.x - x, this.y - y, this.z - z); + return BlockVector3.at(this.x - x, this.y - y, this.z - z); } /** @@ -249,7 +260,7 @@ public class BlockVector3 { newZ -= other.z; } - return new BlockVector3(newX, newY, newZ); + return BlockVector3.at(newX, newY, newZ); } /** @@ -271,7 +282,7 @@ public class BlockVector3 { * @return a new vector */ public BlockVector3 multiply(int x, int y, int z) { - return new BlockVector3(this.x * x, this.y * y, this.z * z); + return BlockVector3.at(this.x * x, this.y * y, this.z * z); } /** @@ -289,7 +300,7 @@ public class BlockVector3 { newZ *= other.z; } - return new BlockVector3(newX, newY, newZ); + return BlockVector3.at(newX, newY, newZ); } /** @@ -321,7 +332,7 @@ public class BlockVector3 { * @return a new vector */ public BlockVector3 divide(int x, int y, int z) { - return new BlockVector3(this.x / x, this.y / y, this.z / z); + return BlockVector3.at(this.x / x, this.y / y, this.z / z); } /** @@ -386,7 +397,7 @@ public class BlockVector3 { double x = this.x / len; double y = this.y / len; double z = this.z / len; - return new BlockVector3(x, y, z); + return BlockVector3.at(x, y, z); } /** @@ -434,10 +445,10 @@ public class BlockVector3 { public BlockVector3 clampY(int min, int max) { checkArgument(min <= max, "minimum cannot be greater than maximum"); if (y < min) { - return new BlockVector3(x, min, z); + return BlockVector3.at(x, min, z); } if (y > max) { - return new BlockVector3(x, max, z); + return BlockVector3.at(x, max, z); } return this; } @@ -481,7 +492,7 @@ public class BlockVector3 { * @return a new vector */ public BlockVector3 abs() { - return new BlockVector3(Math.abs(x), Math.abs(y), Math.abs(z)); + return BlockVector3.at(Math.abs(x), Math.abs(y), Math.abs(z)); } /** @@ -504,7 +515,7 @@ public class BlockVector3 { double x2 = x * cos - z * sin; double z2 = x * sin + z * cos; - return new BlockVector3( + return BlockVector3.at( x2 + aboutX + translateX, y, z2 + aboutZ + translateZ @@ -579,11 +590,11 @@ public class BlockVector3 { * @return a new {@link BlockVector2} */ public BlockVector2 toBlockVector2() { - return new BlockVector2(x, z); + return BlockVector2.at(x, z); } public Vector3 toVector3() { - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java index 8bcea6509..f0f7b67fb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java @@ -126,7 +126,7 @@ public final class MathUtils { * @return midpoint Vector3 */ public static Vector3 midpoint(Vector3 v1, Vector3 v2) { - return new Vector3( + return Vector3.at( (v1.getX() + v2.getX()) / 2, (v1.getY() + v2.getY()) / 2, (v1.getZ() + v2.getZ()) / 2 @@ -141,7 +141,7 @@ public final class MathUtils { * @return midpoint BlockVector3 */ public static BlockVector3 midpoint(BlockVector3 v1, BlockVector3 v2) { - return new BlockVector3( + return BlockVector3.at( (v1.getBlockX() + v2.getBlockX()) / 2, (v1.getBlockY() + v2.getBlockY()) / 2, (v1.getBlockZ() + v2.getBlockZ()) / 2 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 index bb3093e47..8fda11c05 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector.java @@ -580,15 +580,15 @@ public class MutableBlockVector implements Serializable { * @return a new {@link BlockVector2} */ public BlockVector2 toBlockVector2() { - return new BlockVector2(x, z); + return BlockVector2.at(x, z); } public Vector3 toVector3() { - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } public BlockVector3 toBlockVector3() { - return new BlockVector3(x, y, z); + return BlockVector3.at(x, y, z); } @Override 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 index ce957a5d5..09c3c4435 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2D.java @@ -453,7 +453,7 @@ public final class MutableBlockVector2D implements Serializable { * @return a new vector */ public Vector2 toVector2() { - return new Vector2(x, z); + return Vector2.at(x, z); } /** @@ -472,7 +472,7 @@ public final class MutableBlockVector2D implements Serializable { * @return a new vector */ public Vector3 toVector3(double y) { - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } /** @@ -491,7 +491,7 @@ public final class MutableBlockVector2D implements Serializable { * @return a new vector */ public BlockVector3 toBlockVector3(int y) { - return new BlockVector3(x, y, z); + return BlockVector3.at(x, y, z); } /** @@ -500,7 +500,7 @@ public final class MutableBlockVector2D implements Serializable { * @return a new vector */ public BlockVector2 toBlockVector2() { - return new BlockVector2(x, z); + return BlockVector2.at(x, z); } @Override 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 index df952ed71..fd4874de9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector.java @@ -338,7 +338,7 @@ public class MutableVector implements Serializable { * @return the cross product of this and the other vector */ public Vector3 cross(MutableVector other) { - return new Vector3( + return Vector3.at( y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x @@ -518,7 +518,7 @@ public class MutableVector implements Serializable { * @return a new {@code BlockVector} */ public static BlockVector3 toBlockPoint(double x, double y, double z) { - return new BlockVector3(x, y, z); + return BlockVector3.at(x, y, z); } /** @@ -536,11 +536,11 @@ public class MutableVector implements Serializable { * @return a new {@link Vector2} */ public Vector2 toVector2() { - return new Vector2(x, z); + return Vector2.at(x, z); } public Vector3 toVector3() { - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } @Override 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 e403cc5ea..5960e74f7 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 @@ -25,12 +25,29 @@ import com.sk89q.worldedit.math.transform.AffineTransform; * An immutable 2-dimensional vector. */ public final class Vector2 { - + public static final Vector2 ZERO = new Vector2(0, 0); public static final Vector2 UNIT_X = new Vector2(1, 0); public static final Vector2 UNIT_Z = new Vector2(0, 1); 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; /** @@ -39,21 +56,11 @@ public final class Vector2 { * @param x the X coordinate * @param z the Z coordinate */ - public Vector2(double x, double z) { + private Vector2(double x, double z) { this.x = x; this.z = z; } - /** - * Copy another vector. - * - * @param other the other vector - */ - public Vector2(Vector2 other) { - this.x = other.x; - this.z = other.z; - } - /** * Get the X coordinate. * @@ -70,7 +77,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 withX(double x) { - return new Vector2(x, z); + return Vector2.at(x, z); } /** @@ -89,7 +96,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 withZ(double z) { - return new Vector2(x, z); + return Vector2.at(x, z); } /** @@ -110,7 +117,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 add(double x, double z) { - return new Vector2(this.x + x, this.z + z); + return Vector2.at(this.x + x, this.z + z); } /** @@ -128,7 +135,7 @@ public final class Vector2 { newZ += other.z; } - return new Vector2(newX, newZ); + return Vector2.at(newX, newZ); } /** @@ -151,7 +158,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 subtract(double x, double z) { - return new Vector2(this.x - x, this.z - z); + return Vector2.at(this.x - x, this.z - z); } /** @@ -169,7 +176,7 @@ public final class Vector2 { newZ -= other.z; } - return new Vector2(newX, newZ); + return Vector2.at(newX, newZ); } /** @@ -190,7 +197,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 multiply(double x, double z) { - return new Vector2(this.x * x, this.z * z); + return Vector2.at(this.x * x, this.z * z); } /** @@ -207,7 +214,7 @@ public final class Vector2 { newZ *= other.z; } - return new Vector2(newX, newZ); + return Vector2.at(newX, newZ); } /** @@ -238,7 +245,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 divide(double x, double z) { - return new Vector2(this.x / x, this.z / z); + return Vector2.at(this.x / x, this.z / z); } /** @@ -329,7 +336,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 floor() { - return new Vector2(Math.floor(x), Math.floor(z)); + return Vector2.at(Math.floor(x), Math.floor(z)); } /** @@ -338,7 +345,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 ceil() { - return new Vector2(Math.ceil(x), Math.ceil(z)); + return Vector2.at(Math.ceil(x), Math.ceil(z)); } /** @@ -349,7 +356,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 round() { - return new Vector2(Math.floor(x + 0.5), Math.floor(z + 0.5)); + return Vector2.at(Math.floor(x + 0.5), Math.floor(z + 0.5)); } /** @@ -359,7 +366,7 @@ public final class Vector2 { * @return a new vector */ public Vector2 abs() { - return new Vector2(Math.abs(x), Math.abs(z)); + return Vector2.at(Math.abs(x), Math.abs(z)); } /** @@ -413,7 +420,7 @@ public final class Vector2 { } public static BlockVector2 toBlockPoint(double x, double z) { - return new BlockVector2(x, z); + return BlockVector2.at(x, z); } /** @@ -441,7 +448,7 @@ public final class Vector2 { * @return a new vector */ public Vector3 toVector3(double y) { - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } @Override 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 9995b06e9..392478aa3 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 @@ -37,6 +37,25 @@ public class Vector3 { public static final Vector3 UNIT_Z = new Vector3(0, 0, 1); 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); + } + // thread-safe initialization idiom private static final class YzxOrderComparator { private static final Comparator YZX_ORDER = (a, b) -> { @@ -67,23 +86,12 @@ public class Vector3 { * @param y the Y coordinate * @param z the Z coordinate */ - public Vector3(double x, double y, double z) { + private Vector3(double x, double y, double z) { this.x = x; this.y = y; this.z = z; } - /** - * Copy another vector. - * - * @param other another vector to make a copy of - */ - public Vector3(Vector3 other) { - this.x = other.x; - this.y = other.y; - this.z = other.z; - } - /** * Get the X coordinate. * @@ -100,7 +108,7 @@ public class Vector3 { * @return a new vector */ public Vector3 withX(double x) { - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } /** @@ -119,7 +127,7 @@ public class Vector3 { * @return a new vector */ public Vector3 withY(double y) { - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } /** @@ -138,7 +146,7 @@ public class Vector3 { * @return a new vector */ public Vector3 withZ(double z) { - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } /** @@ -160,7 +168,7 @@ public class Vector3 { * @return a new vector */ public Vector3 add(double x, double y, double z) { - return new Vector3(this.x + x, this.y + y, this.z + z); + return Vector3.at(this.x + x, this.y + y, this.z + z); } /** @@ -179,7 +187,7 @@ public class Vector3 { newZ += other.z; } - return new Vector3(newX, newY, newZ); + return Vector3.at(newX, newY, newZ); } /** @@ -203,7 +211,7 @@ public class Vector3 { * @return a new vector */ public Vector3 subtract(double x, double y, double z) { - return new Vector3(this.x - x, this.y - y, this.z - z); + return Vector3.at(this.x - x, this.y - y, this.z - z); } /** @@ -222,7 +230,7 @@ public class Vector3 { newZ -= other.z; } - return new Vector3(newX, newY, newZ); + return Vector3.at(newX, newY, newZ); } /** @@ -244,7 +252,7 @@ public class Vector3 { * @return a new vector */ public Vector3 multiply(double x, double y, double z) { - return new Vector3(this.x * x, this.y * y, this.z * z); + return Vector3.at(this.x * x, this.y * y, this.z * z); } /** @@ -262,7 +270,7 @@ public class Vector3 { newZ *= other.z; } - return new Vector3(newX, newY, newZ); + return Vector3.at(newX, newY, newZ); } /** @@ -294,7 +302,7 @@ public class Vector3 { * @return a new vector */ public Vector3 divide(double x, double y, double z) { - return new Vector3(this.x / x, this.y / y, this.z / z); + return Vector3.at(this.x / x, this.y / y, this.z / z); } /** @@ -403,10 +411,10 @@ public class Vector3 { public Vector3 clampY(int min, int max) { checkArgument(min <= max, "minimum cannot be greater than maximum"); if (y < min) { - return new Vector3(x, min, z); + return Vector3.at(x, min, z); } if (y > max) { - return new Vector3(x, max, z); + return Vector3.at(x, max, z); } return this; } @@ -417,7 +425,7 @@ public class Vector3 { * @return a new vector */ public Vector3 floor() { - return new Vector3(Math.floor(x), Math.floor(y), Math.floor(z)); + return Vector3.at(Math.floor(x), Math.floor(y), Math.floor(z)); } /** @@ -426,7 +434,7 @@ public class Vector3 { * @return a new vector */ public Vector3 ceil() { - return new Vector3(Math.ceil(x), Math.ceil(y), Math.ceil(z)); + return Vector3.at(Math.ceil(x), Math.ceil(y), Math.ceil(z)); } /** @@ -437,7 +445,7 @@ public class Vector3 { * @return a new vector */ public Vector3 round() { - return new Vector3(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 0.5)); + return Vector3.at(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 0.5)); } /** @@ -447,7 +455,7 @@ public class Vector3 { * @return a new vector */ public Vector3 abs() { - return new Vector3(Math.abs(x), Math.abs(y), Math.abs(z)); + return Vector3.at(Math.abs(x), Math.abs(y), Math.abs(z)); } /** @@ -548,7 +556,7 @@ public class Vector3 { * @return a new {@code BlockVector} */ public static BlockVector3 toBlockPoint(double x, double y, double z) { - return new BlockVector3(x, y, z); + return BlockVector3.at(x, y, z); } /** @@ -566,7 +574,7 @@ public class Vector3 { * @return a new {@link Vector2} */ public Vector2 toVector2() { - return new Vector2(x, z); + return Vector2.at(x, z); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index 46581b271..320d450f3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -200,19 +200,20 @@ public class HeightMap { } else { existing = PropertyGroup.LEVEL.set(existing, 15); session.setBlock(xr, newBlock, zr, existing); + //======= -// BlockState existing = session.getBlock(new BlockVector3(xr, curHeight, zr)); +// BlockState existing = session.getBlock(BlockVector3.at(xr, curHeight, zr)); // // // Skip water/lava // if (existing.getBlockType() != BlockTypes.WATER && existing.getBlockType() != BlockTypes.LAVA) { -// session.setBlock(new BlockVector3(xr, newHeight, zr), existing); +// session.setBlock(BlockVector3.at(xr, newHeight, zr), existing); // ++blocksChanged; // // // Grow -- start from 1 below top replacing airblocks // for (int y = newHeight - 1 - originY; y >= 0; --y) { // int copyFrom = (int) (y * scale); -// session.setBlock(new BlockVector3(xr, originY + y, zr), session.getBlock(new BlockVector3(xr, originY + copyFrom, zr))); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner +// session.setBlock(BlockVector3.at(xr, originY + y, zr), session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr))); +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching ++blocksChanged; } } @@ -225,8 +226,8 @@ public class HeightMap { // // Shrink -- start from bottom // for (int y = 0; y < newHeight - originY; ++y) { // int copyFrom = (int) (y * scale); -// session.setBlock(new BlockVector3(xr, originY + y, zr), session.getBlock(new BlockVector3(xr, originY + copyFrom, zr))); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner +// session.setBlock(BlockVector3.at(xr, originY + y, zr), session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr))); +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching ++blocksChanged; } // Set the top block of the column to be the same type @@ -294,12 +295,12 @@ public class HeightMap { } else if (curHeight > newHeight) { // Set the top block of the column to be the same type // (this could otherwise go wrong with rounding) - session.setBlock(xr, newHeight, zr, session.getBlock(xr, curHeight, zr)); + session.setBlock(BlockVector3.at(xr, newHeight, zr), session.getBlock(BlockVector3.at(xr, curHeight, zr))); ++blocksChanged; // Fill rest with air for (int y = newHeight + 1; y <= curHeight; ++y) { - session.setBlock(xr, y, zr, fillerAir); + session.setBlock(BlockVector3.at(xr, y, zr), fillerAir); ++blocksChanged; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java index af191dc72..13bc259ba 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java @@ -53,7 +53,7 @@ public final class Polygons { final List points = new ArrayList<>(nPoints); for (int i = 0; i < nPoints; ++i) { double angle = i * (2.0 * Math.PI) / nPoints; - final Vector2 pos = new Vector2(Math.cos(angle), Math.sin(angle)); + final Vector2 pos = Vector2.at(Math.cos(angle), Math.sin(angle)); final BlockVector2 blockVector2D = pos.multiply(radius).toBlockPoint().add(center); points.add(blockVector2D); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java index c2bc1e93b..c29190b77 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java @@ -38,7 +38,7 @@ public class Node { private double continuity; public Node() { - this(new Vector3(0, 0, 0)); + this(Vector3.at(0, 0, 0)); } public Node(Node other) { 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 7e10b4d6e..ee7b973e3 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 @@ -292,7 +292,7 @@ public class AffineTransform implements Transform, Serializable { @Override public Vector3 apply(Vector3 vector) { - return new Vector3( + return Vector3.at( vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03, vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13, vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23); 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 ccd9ea3d1..8ae246ccd 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 @@ -22,7 +22,7 @@ public class RoundedTransform implements Transform{ // mutable.mutX((int) Math.floor(val.getX() + 0.5)); // mutable.mutY((int) Math.floor(val.getY() + 0.5)); // mutable.mutZ((int) Math.floor(val.getZ() + 0.5)); - return new Vector3(Math.floor(val.getX() + 0.5), Math.floor(val.getY() + 0.5), Math.floor(val.getY() + 0.5)); + return Vector3.at(Math.floor(val.getX() + 0.5), Math.floor(val.getY() + 0.5), Math.floor(val.getY() + 0.5)); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java index b56d58ebf..521f23c62 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java @@ -88,10 +88,10 @@ public abstract class AbstractRegion implements Region { final List points = new ArrayList<>(4); - points.add(new BlockVector2(min.getX(), min.getZ())); - points.add(new BlockVector2(min.getX(), max.getZ())); - points.add(new BlockVector2(max.getX(), max.getZ())); - points.add(new BlockVector2(max.getX(), min.getZ())); + points.add(BlockVector2.at(min.getX(), min.getZ())); + points.add(BlockVector2.at(min.getX(), max.getZ())); + points.add(BlockVector2.at(max.getX(), max.getZ())); + points.add(BlockVector2.at(max.getX(), min.getZ())); return points; } @@ -166,11 +166,11 @@ public abstract class AbstractRegion implements Region { for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { - if (!contains(new BlockVector3(x, minY, z))) { + if (!contains(BlockVector3.at(x, minY, z))) { continue; } - chunks.add(new BlockVector2( + chunks.add(BlockVector2.at( x >> ChunkStore.CHUNK_SHIFTS, z >> ChunkStore.CHUNK_SHIFTS )); @@ -190,11 +190,11 @@ public abstract class AbstractRegion implements Region { for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { - if (!contains(new BlockVector3(x, y, z))) { + if (!contains(BlockVector3.at(x, y, z))) { continue; } - chunks.add(new BlockVector3( + chunks.add(BlockVector3.at( x >> ChunkStore.CHUNK_SHIFTS, y >> ChunkStore.CHUNK_SHIFTS, z >> ChunkStore.CHUNK_SHIFTS 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 aa645a0d4..50f737032 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 @@ -349,10 +349,17 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { }; } +//<<<<<<< HEAD @Override public int size() { return size; } +//======= +// for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) { +// for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) { +// chunks.add(BlockVector2.at(x, z)); +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching + @Override public boolean contains(Object o) { @@ -381,7 +388,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) { for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) { for (int y = min.getBlockY() >> ChunkStore.CHUNK_SHIFTS; y <= max.getBlockY() >> ChunkStore.CHUNK_SHIFTS; ++y) { - chunks.add(new BlockVector3(x, y, z)); + chunks.add(BlockVector3.at(x, y, z)); } } } @@ -463,6 +470,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public BlockVector3 next() { +//<<<<<<< HEAD mutable.mutX(x); mutable.mutY(y); mutable.mutZ(z); @@ -498,6 +506,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } else { x = cbx; z = cbz; +//======= +// if (!hasNext()) throw new NoSuchElementException(); +// BlockVector3 answer = BlockVector3.at(nextX, nextY, nextZ); +// if (++nextX > max.getBlockX()) { +// nextX = min.getBlockX(); +// if (++nextY > max.getBlockY()) { +// nextY = min.getBlockY(); +// if (++nextZ > max.getBlockZ()) { +// nextX = Integer.MIN_VALUE; +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching } } else { x = cbx; @@ -525,10 +543,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } @Override +//<<<<<<< HEAD public BlockVector3 next() { mutable.mutX(nextX); mutable.mutY(nextY); mutable.mutZ(nextZ); +//======= +// public BlockVector2 next() { +// if (!hasNext()) throw new NoSuchElementException(); +// BlockVector2 answer = BlockVector2.at(nextX, nextZ); +//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching if (++nextX > max.getBlockX()) { nextX = min.getBlockX(); if (++nextZ > max.getBlockZ()) { @@ -575,7 +599,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { public BlockVector2 next() { if (!hasNext()) throw new java.util.NoSuchElementException(); // BlockVector2 answer = mutable.setComponents(nextX, nextZ); - BlockVector2 answer = new BlockVector2(nextX, nextZ); + BlockVector2 answer = BlockVector2.at(nextX, nextZ); if (++nextX > max.getBlockX()) { nextX = min.getBlockX(); if (++nextZ > max.getBlockZ()) { 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 e2a1b1028..66b6241e6 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 @@ -268,7 +268,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { public void contract(BlockVector3... changes) throws RegionOperationException { center = center.subtract(calculateDiff2D(changes)); Vector2 newRadius = radius.subtract(calculateChanges2D(changes).toVector2()); - radius = new Vector2(1.5, 1.5).getMaximum(newRadius); + radius = Vector2.at(1.5, 1.5).getMaximum(newRadius); this.radiusInverse = Vector2.ONE.divide(radius); for (BlockVector3 change : changes) { int height = maxY - minY; @@ -377,7 +377,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { public static CylinderRegion createRadius(Extent extent, BlockVector3 center, double radius) { checkNotNull(extent); checkNotNull(center); - Vector2 radiusVec = new Vector2(radius, radius); + Vector2 radiusVec = Vector2.at(radius, radius); int minY = extent.getMinimumPoint().getBlockY(); int maxY = extent.getMaximumPoint().getBlockY(); return new CylinderRegion(center, radiusVec, minY, maxY); 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 c06a1851e..d61b5bf53 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 @@ -136,7 +136,7 @@ public class EllipsoidRegion extends AbstractRegion { public void contract(BlockVector3... changes) throws RegionOperationException { center = center.subtract(calculateDiff(changes)); Vector3 newRadius = radius.subtract(calculateChanges(changes).toVector3()); - setRadius(new Vector3(1.5, 1.5, 1.5).getMaximum(newRadius)); + setRadius(Vector3.at(1.5, 1.5, 1.5).getMaximum(newRadius)); } @Override @@ -199,11 +199,11 @@ public class EllipsoidRegion extends AbstractRegion { for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { - if (!contains(new BlockVector3(x, centerY, z))) { + if (!contains(BlockVector3.at(x, centerY, z))) { continue; } - chunks.add(new BlockVector2( + chunks.add(BlockVector2.at( x >> ChunkStore.CHUNK_SHIFTS, z >> ChunkStore.CHUNK_SHIFTS )); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java index f0216757e..5ea83211e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.regions; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator; import com.sk89q.worldedit.regions.iterator.FlatRegionIterator; import com.sk89q.worldedit.world.World; @@ -131,8 +130,8 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { minY = Math.min(Math.max(0, minY), world == null ? 255 : world.getMaxY()); maxY = Math.min(Math.max(0, maxY), world == null ? 255 : world.getMaxY()); - min = new BlockVector2(minX, minZ); - max = new BlockVector2(maxX, maxZ); + min = BlockVector2.at(minX, minZ); + max = BlockVector2.at(maxX, maxZ); } /** @@ -151,7 +150,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { * @param position the position */ public void addPoint(BlockVector3 position) { - points.add(new BlockVector2(position.getBlockX(), position.getBlockZ())); + points.add(BlockVector2.at(position.getBlockX(), position.getBlockZ())); recalculate(); } @@ -267,7 +266,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { for (int i = 0; i < points.size(); ++i) { BlockVector2 point = points.get(i); - points.set(i, new BlockVector2(point.getX() + changeX, point.getZ() + changeZ)); + points.set(i, BlockVector2.at(point.getX() + changeX, point.getZ() + changeZ)); } minY += changeY; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java index ed3896d06..cf55d2fa9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java @@ -34,7 +34,7 @@ public class CylinderRegionFactory implements RegionFactory { @Override public Region createCenteredAt(BlockVector3 position, double size) { - return new CylinderRegion(position, new Vector2(size, size), position.getBlockY() - (int) (height / 2), position.getBlockY() + (int) (height / 2)); + return new CylinderRegion(position, Vector2.at(size, size), position.getBlockY() - (int) (height / 2), position.getBlockY() + (int) (height / 2)); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/SphereRegionFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/SphereRegionFactory.java index 4ad8d4125..f30611b0f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/SphereRegionFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/SphereRegionFactory.java @@ -28,7 +28,7 @@ public class SphereRegionFactory implements RegionFactory { @Override public Region createCenteredAt(BlockVector3 position, double size) { - return new EllipsoidRegion(position, new Vector3(size, size, size)); + return new EllipsoidRegion(position, Vector3.at(size, size, size)); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java index 786e04a2b..6a7a06780 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java @@ -68,7 +68,7 @@ public class FlatRegion3DIterator implements Iterator { throw new NoSuchElementException(); } - BlockVector3 current = new BlockVector3(next2D.getBlockX(), nextY, next2D.getBlockZ()); + BlockVector3 current = BlockVector3.at(next2D.getBlockX(), nextY, next2D.getBlockZ()); if (nextY < maxY) { nextY++; } else if (flatIterator.hasNext()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java index 42bda7d86..f5beb35f7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java @@ -67,7 +67,7 @@ public class FlatRegionIterator implements Iterator { } private void forward() { - while (hasNext() && !region.contains(nextX, y, nextZ)) { + while (hasNext() && !region.contains(BlockVector3.at(nextX, y, nextZ))) { forwardOne(); } } @@ -78,7 +78,7 @@ public class FlatRegionIterator implements Iterator { throw new NoSuchElementException(); } - BlockVector2 answer = new BlockVector2(nextX, nextZ); + BlockVector2 answer = BlockVector2.at(nextX, nextZ); forwardOne(); forward(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java index 482d30151..1fd0aca43 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java @@ -63,7 +63,7 @@ public class RegionIterator implements Iterator { } private void forward() { - while (hasNext() && !region.contains(new BlockVector3(nextX, nextY, nextZ))) { + while (hasNext() && !region.contains(BlockVector3.at(nextX, nextY, nextZ))) { forwardOne(); } } @@ -72,7 +72,7 @@ public class RegionIterator implements Iterator { public BlockVector3 next() { if (!hasNext()) throw new java.util.NoSuchElementException(); - BlockVector3 answer = new BlockVector3(nextX, nextY, nextZ); + BlockVector3 answer = BlockVector3.at(nextX, nextY, nextZ); forwardOne(); forward(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java index 28c22cf96..b4eca9a7e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java @@ -115,8 +115,8 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector { final BlockVector3 o1 = position1; final BlockVector3 o2 = position2; - position1 = new BlockVector3(x1, y1, z1); - position2 = new BlockVector3(x2, y2, z2); + position1 = BlockVector3.at(x1, y1, z1); + position2 = BlockVector3.at(x2, y2, z2); region.setPos1(position1); region.setPos2(position2); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java index ee2bb8ba3..70ac199a2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java @@ -116,7 +116,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { checkNotNull(points); final BlockVector2 pos2D = points.get(0); - pos1 = new BlockVector3(pos2D.getX(), minY, pos2D.getZ()); + pos1 = BlockVector3.at(pos2D.getX(), minY, pos2D.getZ()); region = new Polygonal2DRegion(world, points, minY, maxY); } @@ -222,7 +222,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { @Override public void learnChanges() { BlockVector2 pt = region.getPoints().get(0); - pos1 = new BlockVector3(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ()); + pos1 = BlockVector3.at(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java index a37df4257..7d04e5463 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java @@ -59,7 +59,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector { super(oldSelector); final Vector3 radius = region.getRadius(); final double radiusScalar = Math.max(Math.max(radius.getX(), radius.getY()), radius.getZ()); - region.setRadius(new Vector3(radiusScalar, radiusScalar, radiusScalar)); + region.setRadius(Vector3.at(radiusScalar, radiusScalar, radiusScalar)); } /** @@ -70,7 +70,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector { * @param radius the radius */ public SphereRegionSelector(@Nullable World world, BlockVector3 center, int radius) { - super(world, center, new Vector3(radius, radius, radius)); + super(world, center, Vector3.at(radius, radius, radius)); } @Override @@ -80,7 +80,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector { } final double radiusScalar = Math.ceil(position.toVector3().distance(region.getCenter())); - region.setRadius(new Vector3(radiusScalar, radiusScalar, radiusScalar)); + region.setRadius(Vector3.at(radiusScalar, radiusScalar, radiusScalar)); return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java index 321c80b32..60a8808b1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java @@ -37,7 +37,7 @@ public class RegionShape extends ArbitraryShape { @Override protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) { - if (!this.extent.contains(new BlockVector3(x, y, z))) { + if (!this.extent.contains(BlockVector3.at(x, y, z))) { return null; } 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 a25210135..1d1416f67 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 @@ -44,7 +44,7 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment { public BlockVector3 toWorld(double x, double y, double z) { // unscale, unoffset, round-nearest - return new Vector3(x, y, z).multiply(unit).add(zero2).toBlockPoint(); + return Vector3.at(x, y, z).multiply(unit).add(zero2).toBlockPoint(); } public Vector3 toWorldRel(double x, double y, double z) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java index 70d73475e..47d6ae1c0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java @@ -30,27 +30,27 @@ import java.util.HashMap; */ public enum Direction { - NORTH(new Vector3(0, 0, -1), Flag.CARDINAL, 3, 1), - EAST(new Vector3(1, 0, 0), Flag.CARDINAL, 0, 2), - SOUTH(new Vector3(0, 0, 1), Flag.CARDINAL, 1, 3), - WEST(new Vector3(-1, 0, 0), Flag.CARDINAL, 2, 0), + NORTH(Vector3.at(0, 0, -1), Flag.CARDINAL, 3, 1), + EAST(Vector3.at(1, 0, 0), Flag.CARDINAL, 0, 2), + SOUTH(Vector3.at(0, 0, 1), Flag.CARDINAL, 1, 3), + WEST(Vector3.at(-1, 0, 0), Flag.CARDINAL, 2, 0), - UP(new Vector3(0, 1, 0), Flag.UPRIGHT, -1, -1), - DOWN(new Vector3(0, -1, 0), Flag.UPRIGHT, -1, -1), + UP(Vector3.at(0, 1, 0), Flag.UPRIGHT, -1, -1), + DOWN(Vector3.at(0, -1, 0), Flag.UPRIGHT, -1, -1), - NORTHEAST(new Vector3(1, 0, -1), Flag.ORDINAL, 7, 8), - NORTHWEST(new Vector3(-1, 0, -1), Flag.ORDINAL, 9, 6), - SOUTHEAST(new Vector3(1, 0, 1), Flag.ORDINAL, 6, 9), - SOUTHWEST(new Vector3(-1, 0, 1), Flag.ORDINAL, 8, 7), + NORTHEAST(Vector3.at(1, 0, -1), Flag.ORDINAL, 7, 8), + NORTHWEST(Vector3.at(-1, 0, -1), Flag.ORDINAL, 9, 6), + SOUTHEAST(Vector3.at(1, 0, 1), Flag.ORDINAL, 6, 9), + SOUTHWEST(Vector3.at(-1, 0, 1), Flag.ORDINAL, 8, 7), - WEST_NORTHWEST(new Vector3(-Math.cos(Math.PI / 8), 0, -Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 9, 6), - WEST_SOUTHWEST(new Vector3(-Math.cos(Math.PI / 8), 0, Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 8, 7), - NORTH_NORTHWEST(new Vector3(-Math.sin(Math.PI / 8), 0, -Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 9, 6), - NORTH_NORTHEAST(new Vector3(Math.sin(Math.PI / 8), 0, -Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 7, 8), - EAST_NORTHEAST(new Vector3(Math.cos(Math.PI / 8), 0, -Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 7, 8), - EAST_SOUTHEAST(new Vector3(Math.cos(Math.PI / 8), 0, Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 6, 9), - SOUTH_SOUTHEAST(new Vector3(Math.sin(Math.PI / 8), 0, Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 6, 9), - SOUTH_SOUTHWEST(new Vector3(-Math.sin(Math.PI / 8), 0, Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 8, 7); + WEST_NORTHWEST(Vector3.at(-Math.cos(Math.PI / 8), 0, -Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 9, 6), + WEST_SOUTHWEST(Vector3.at(-Math.cos(Math.PI / 8), 0, Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 8, 7), + NORTH_NORTHWEST(Vector3.at(-Math.sin(Math.PI / 8), 0, -Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 9, 6), + NORTH_NORTHEAST(Vector3.at(Math.sin(Math.PI / 8), 0, -Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 7, 8), + EAST_NORTHEAST(Vector3.at(Math.cos(Math.PI / 8), 0, -Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 7, 8), + EAST_SOUTHEAST(Vector3.at(Math.cos(Math.PI / 8), 0, Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 6, 9), + SOUTH_SOUTHEAST(Vector3.at(Math.sin(Math.PI / 8), 0, Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 6, 9), + SOUTH_SOUTHWEST(Vector3.at(-Math.sin(Math.PI / 8), 0, Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL, 8, 7); private final Vector3 direction; private final BlockVector3 blockVector; @@ -70,7 +70,7 @@ public enum Direction { private Direction(Vector3 vector, int flags, int left, int right) { this.direction = vector.normalize(); - this.blockVector = new BlockVector3(Math.signum(vector.getX()), Math.signum(vector.getY()), Math.signum(vector.getZ())); + this.blockVector = BlockVector3.at(Math.signum(vector.getX()), Math.signum(vector.getY()), Math.signum(vector.getZ())); this.flags = flags; this.left = left; this.right = right; 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 941748705..9fffc98a9 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 @@ -61,7 +61,7 @@ public class Location{ * @param z the Z coordinate */ public Location(Extent extent, double x, double y, double z) { - this(extent, new Vector3(x, y, z), Vector3.ZERO); + this(extent, Vector3.at(x, y, z), Vector3.ZERO); } /** @@ -86,7 +86,7 @@ public class Location{ * @param direction the direction vector */ public Location(Extent extent, double x, double y, double z, Vector3 direction) { - this(extent, new Vector3(x, y, z), direction); + this(extent, Vector3.at(x, y, z), direction); } /** @@ -101,7 +101,7 @@ public class Location{ * @param pitch the pitch, in degrees */ public Location(Extent extent, double x, double y, double z, float yaw, float pitch) { - this(extent, new Vector3(x, y, z), yaw, pitch); + this(extent, Vector3.at(x, y, z), yaw, pitch); } /** @@ -212,7 +212,7 @@ public class Location{ double yaw = Math.toRadians(this.getYaw()); double pitch = Math.toRadians(this.getPitch()); double xz = Math.cos(pitch); - return new Vector3( + return Vector3.at( -xz * Math.sin(yaw), -Math.sin(pitch), xz * Math.cos(yaw)); 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 09ec0aef4..715eb68dd 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 @@ -83,7 +83,7 @@ public class TargetBlock { double h = (checkDistance * Math.cos(Math.toRadians(yRotation))); - offset = new Vector3((h * Math.cos(Math.toRadians(xRotation))), + offset = Vector3.at((h * Math.cos(Math.toRadians(xRotation))), (checkDistance * Math.sin(Math.toRadians(yRotation))), (h * Math.sin(Math.toRadians(xRotation)))); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/VectorAdapter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/VectorAdapter.java index 4524e64f9..ec164d045 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/VectorAdapter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/VectorAdapter.java @@ -44,6 +44,6 @@ public class VectorAdapter implements JsonDeserializer { double y = jsonArray.get(1).getAsDouble(); double z = jsonArray.get(2).getAsDouble(); - return new Vector3(x, y, z); + return Vector3.at(x, y, z); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java index 9af32bdd5..a335f7583 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java @@ -120,12 +120,12 @@ public abstract class AbstractWorld implements World { @Override public BlockVector3 getMinimumPoint() { - return new BlockVector3(-30000000, 0, -30000000); + return BlockVector3.at(-30000000, 0, -30000000); } @Override public BlockVector3 getMaximumPoint() { - return new BlockVector3(30000000, 255, 30000000); + return BlockVector3.at(30000000, 255, 30000000); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java index 31cd6f571..bc5f21d3e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java @@ -108,12 +108,12 @@ public interface SimpleWorld extends World { @Override default BlockVector3 getMinimumPoint() { - return new BlockVector3(-30000000, 0, -30000000); + return BlockVector3.at(-30000000, 0, -30000000); } @Override default BlockVector3 getMaximumPoint() { - return new BlockVector3(30000000, 255, 30000000); + return BlockVector3.at(30000000, 255, 30000000); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java index 972bc985a..7d8a47015 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java @@ -224,7 +224,7 @@ public class AnvilChunk implements Chunk { values.put(entry.getKey(), entry.getValue()); } - BlockVector3 vec = new BlockVector3(x, y, z); + BlockVector3 vec = BlockVector3.at(x, y, z); tileEntities.put(vec, values); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java index e02a715ca..5bfb4f003 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java @@ -201,7 +201,7 @@ public class AnvilChunk13 implements Chunk { values.put(entry.getKey(), entry.getValue()); } - BlockVector3 vec = new BlockVector3(x, y, z); + BlockVector3 vec = BlockVector3.at(x, y, z); tileEntities.put(vec, values); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java index d337bf7bd..a69ac6a2a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java @@ -127,7 +127,7 @@ public class OldChunk implements Chunk { values.put(entry.getKey(), entry.getValue()); } - BlockVector3 vec = new BlockVector3(x, y, z); + BlockVector3 vec = BlockVector3.at(x, y, z); tileEntities.put(vec, values); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java index b243dcd3a..316026f03 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java @@ -79,7 +79,7 @@ public class SnapshotRestore { for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { - BlockVector3 pos = new BlockVector3(x, y, z); + BlockVector3 pos = BlockVector3.at(x, y, z); checkAndAddBlock(pos); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java index 4f270fade..bf728459b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java @@ -57,7 +57,7 @@ public abstract class ChunkStore implements Closeable { * @return chunk coordinates */ public static BlockVector2 toChunk(BlockVector3 position) { - return new BlockVector2(position.getX() >> CHUNK_SHIFTS, position.getZ() >> CHUNK_SHIFTS); + return BlockVector2.at(position.getX() >> CHUNK_SHIFTS, position.getZ() >> CHUNK_SHIFTS); } /** 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 9c2a08760..71537f7cb 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 @@ -57,7 +57,7 @@ public class LocationTest { @Test public void testToVector() throws Exception { World world = mock(World.class); - Vector3 position = new Vector3(1, 1, 1); + Vector3 position = Vector3.at(1, 1, 1); Location location = new Location(world, position); assertEquals(position, location.toVector()); } @@ -65,14 +65,14 @@ public class LocationTest { @Test public void testGetX() throws Exception { World world = mock(World.class); - Location location = new Location(world, new Vector3(TEST_VALUE, 0, 0)); + Location location = new Location(world, Vector3.at(TEST_VALUE, 0, 0)); assertEquals(TEST_VALUE, location.getX(), EPSILON); } @Test public void testGetBlockX() throws Exception { World world = mock(World.class); - Location location = new Location(world, new Vector3(TEST_VALUE, 0, 0)); + Location location = new Location(world, Vector3.at(TEST_VALUE, 0, 0)); assertEquals(TEST_VALUE, location.getBlockX()); } @@ -90,14 +90,14 @@ public class LocationTest { @Test public void testGetY() throws Exception { World world = mock(World.class); - Location location = new Location(world, new Vector3(0, TEST_VALUE, 0)); + Location location = new Location(world, Vector3.at(0, TEST_VALUE, 0)); assertEquals(TEST_VALUE, location.getY(), EPSILON); } @Test public void testGetBlockY() throws Exception { World world = mock(World.class); - Location location = new Location(world, new Vector3(0, TEST_VALUE, 0)); + Location location = new Location(world, Vector3.at(0, TEST_VALUE, 0)); assertEquals(TEST_VALUE, location.getBlockY()); } @@ -115,14 +115,14 @@ public class LocationTest { @Test public void testGetZ() throws Exception { World world = mock(World.class); - Location location = new Location(world, new Vector3(0, 0, TEST_VALUE)); + Location location = new Location(world, Vector3.at(0, 0, TEST_VALUE)); assertEquals(TEST_VALUE, location.getZ(), EPSILON); } @Test public void testGetBlockZ() throws Exception { World world = mock(World.class); - Location location = new Location(world, new Vector3(0, 0, TEST_VALUE)); + Location location = new Location(world, Vector3.at(0, 0, TEST_VALUE)); assertEquals(TEST_VALUE, location.getBlockZ()); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java index b353e046c..e847d02dd 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java @@ -47,11 +47,11 @@ final class ForgeAdapter { } public static Vector3 adapt(Vec3d vector) { - return new Vector3(vector.x, vector.y, vector.z); + return Vector3.at(vector.x, vector.y, vector.z); } public static Vector3 adapt(BlockPos pos) { - return new Vector3(pos.getX(), pos.getY(), pos.getZ()); + return Vector3.at(pos.getX(), pos.getY(), pos.getZ()); } public static Vec3d toVec3(BlockVector3 vector) { diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntity.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntity.java index 94bb3c8a5..b5cd5f516 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntity.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntity.java @@ -66,7 +66,7 @@ class ForgeEntity implements Entity { public Location getLocation() { net.minecraft.entity.Entity entity = entityRef.get(); if (entity != null) { - Vector3 position = new Vector3(entity.posX, entity.posY, entity.posZ); + Vector3 position = Vector3.at(entity.posX, entity.posY, entity.posZ); float yaw = entity.rotationYaw; float pitch = entity.rotationPitch; diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index 223031f4a..98842e5b8 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -80,7 +80,7 @@ public class ForgePlayer extends AbstractPlayerActor { @Override public Location getLocation() { - Vector3 position = new Vector3(this.player.posX, this.player.posY, this.player.posZ); + Vector3 position = Vector3.at(this.player.posX, this.player.posY, this.player.posZ); return new Location( ForgeWorldEdit.inst.getWorld(this.player.world), position, diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index f0b68ebcb..1b740bd08 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -449,7 +449,7 @@ public class ForgeWorld extends AbstractWorld { public List getEntities(Region region) { List entities = new ArrayList<>(); for (net.minecraft.entity.Entity entity : getWorld().loadedEntityList) { - if (region.contains(new BlockVector3(entity.posX, entity.posY, entity.posZ))) { + if (region.contains(BlockVector3.at(entity.posX, entity.posY, entity.posZ))) { entities.add(new ForgeEntity(entity)); } } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java index b62bee328..74c2a6a3c 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java @@ -249,7 +249,7 @@ public abstract class SpongeWorld extends AbstractWorld { List entities = new ArrayList<>(); for (org.spongepowered.api.entity.Entity entity : getWorld().getEntities()) { org.spongepowered.api.world.Location loc = entity.getLocation(); - if (region.contains(new BlockVector3(loc.getX(), loc.getY(), loc.getZ()))) { + if (region.contains(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ()))) { entities.add(new SpongeEntity(entity)); } } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplAdapter.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplAdapter.java index 01cc7dfc0..d6cb96f8e 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplAdapter.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplAdapter.java @@ -57,7 +57,7 @@ public interface SpongeImplAdapter { } default Location adapt(org.spongepowered.api.world.Location loc, Vector3d rot) { - Vector3 position = new Vector3(loc.getX(), loc.getY(), loc.getZ()); + Vector3 position = Vector3.at(loc.getX(), loc.getY(), loc.getZ()); return new Location(getWorld(loc.getExtent()), position, (float) rot.getY(), (float) rot.getX()); }