diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java index 3bf29bdd9..1faf08922 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java @@ -22,11 +22,11 @@ package com.sk89q.worldedit.blocks; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; /** * A implementation of a lazy block for {@link Extent#getLazyBlock(Vector)} @@ -42,7 +42,7 @@ import com.sk89q.worldedit.extent.Extent; public class LazyBlock extends BaseBlock { private final Extent extent; - private final Vector position; + private final BlockVector3 position; private boolean loaded = false; /** @@ -52,7 +52,7 @@ public class LazyBlock extends BaseBlock { * @param extent the extent to later load the full block data from * @param position the position to later load the full block data from */ - public LazyBlock(BlockType type, Extent extent, Vector position) { + public LazyBlock(BlockType type, Extent extent, BlockVector3 position) { super(type); checkNotNull(extent); checkNotNull(position); @@ -67,7 +67,7 @@ public class LazyBlock extends BaseBlock { * @param extent the extent to later load the full block data from * @param position the position to later load the full block data from */ - public LazyBlock(BlockState state, Extent extent, Vector position) { + public LazyBlock(BlockState state, Extent extent, BlockVector3 position) { super(state); checkNotNull(extent); checkNotNull(position); 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 524ab74ee..e91593c0c 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 @@ -526,7 +526,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights[index] & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { + if (mask.test(mutable.toBlockVector3())) { int newHeight = table.average(x, z, index); setLayerHeightRaw(index, newHeight); } @@ -581,7 +581,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } mutable.mutX(x); mutable.mutY(y); - if (!mask.test(mutable)) { + if (!mask.test(mutable.toBlockVector3())) { continue; } if (placed.containsRadius(x, z, distance)) { @@ -601,9 +601,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { - schematic.paste(this, mutable, false); + schematic.paste(this, mutable.toBlockVector3(), false); } else { - schematic.paste(this, mutable, false, transform); + schematic.paste(this, mutable.toBlockVector3(), false, transform); } if (x + distance < getWidth()) { x += distance; @@ -629,7 +629,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } mutable.mutX(x); mutable.mutY(y); - if (!mask.test(mutable)) { + if (!mask.test(mutable.toBlockVector3())) { continue; } if (placed.containsRadius(x, z, distance)) { @@ -650,9 +650,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { - schematic.paste(this, mutable, false); + schematic.paste(this, mutable.toBlockVector3(), false); } else { - schematic.paste(this, mutable, false, transform); + schematic.paste(this, mutable.toBlockVector3(), false, transform); } if (x + distance < getWidth()) { x += distance; @@ -1132,7 +1132,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (mask != null) { mutable.mutX(z); mutable.mutY(heights.getByte(index) & 0xFF); - if (!mask.test(mutable)) continue; + if (!mask.test(mutable.toBlockVector3())) continue; } if (imgMask != null) { int height = imgMask.getRGB(x, z) & 0xFF; @@ -1251,7 +1251,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr for (int x = 0; x < getWidth(); x++, index++) { mutable.mutX(x); mutable.mutY(heights.getByte(index) & 0xFF); - if (mask.test(mutable)) { + if (mask.test(mutable.toBlockVector3())) { int color = img.getRGB(x, z); BlockType block = textureUtil.getNearestBlock(color); if (block != null) { @@ -1327,7 +1327,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { + if (mask.test(mutable.toBlockVector3())) { biomes.setByte(index, biome); } } @@ -1356,7 +1356,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) { mutable.mutX(x); mutable.mutY(height); - overlayArr[index] = pattern.apply(mutable).getInternalId(); + overlayArr[index] = pattern.apply(mutable.toBlockVector3()).getInternalId(); } } } @@ -1383,7 +1383,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) { mutable.mutX(x); mutable.mutY(height); - mainArr[index] = pattern.apply(mutable).getInternalId(); + mainArr[index] = pattern.apply(mutable.toBlockVector3()).getInternalId(); } } } @@ -1408,7 +1408,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) { mutable.mutX(x); mutable.mutY(height); - floorArr[index] = pattern.apply(mutable).getInternalId(); + floorArr[index] = pattern.apply(mutable.toBlockVector3()).getInternalId(); } } } @@ -1435,7 +1435,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr if (height == 255 || height > 0 && !white && PseudoRandom.random.nextInt(256) <= height) { mutable.mutX(x); mutable.mutY(height); - int combined = pattern.apply(mutable).getInternalId(); + int combined = pattern.apply(mutable.toBlockVector3()).getInternalId(); mainArr[index] = combined; floorArr[index] = combined; } @@ -1457,8 +1457,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { - overlay.setInt(index, pattern.apply(mutable).getInternalId()); + if (mask.test(mutable.toBlockVector3())) { + overlay.setInt(index, pattern.apply(mutable.toBlockVector3()).getInternalId()); } } } @@ -1476,8 +1476,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { - floor.setInt(index, pattern.apply(mutable).getInternalId()); + if (mask.test(mutable.toBlockVector3())) { + floor.setInt(index, pattern.apply(mutable.toBlockVector3()).getInternalId()); } } } @@ -1496,8 +1496,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { - main.setInt(index, pattern.apply(mutable).getInternalId()); + if (mask.test(mutable.toBlockVector3())) { + main.setInt(index, pattern.apply(mutable.toBlockVector3()).getInternalId()); } } } @@ -1516,8 +1516,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { - int combined = pattern.apply(mutable).getInternalId(); + if (mask.test(mutable.toBlockVector3())) { + int combined = pattern.apply(mutable.toBlockVector3()).getInternalId(); floor.setInt(index, combined); main.setInt(index, combined); } @@ -1543,7 +1543,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - floorArr[index] = value.apply(mutable).getInternalId(); + floorArr[index] = value.apply(mutable.toBlockVector3()).getInternalId(); } } }); @@ -1564,7 +1564,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - int combined = value.apply(mutable).getInternalId(); + int combined = value.apply(mutable.toBlockVector3()).getInternalId(); mainArr[index] = combined; floorArr[index] = combined; } @@ -1586,7 +1586,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - mainArr[index] = value.apply(mutable).getInternalId(); + mainArr[index] = value.apply(mutable.toBlockVector3()).getInternalId(); } } }); @@ -1607,7 +1607,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - overlayArr[index] = value.apply(mutable).getInternalId(); + overlayArr[index] = value.apply(mutable.toBlockVector3()).getInternalId(); } } }); @@ -1994,7 +1994,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { + if (mask.test(mutable.toBlockVector3())) { overlay.setInt(index, combined); } } @@ -2009,7 +2009,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { + if (mask.test(mutable.toBlockVector3())) { floor.setInt(index, combined); } } @@ -2025,7 +2025,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { + if (mask.test(mutable.toBlockVector3())) { main.setInt(index, combined); } } @@ -2041,7 +2041,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr int y = heights.getByte(index) & 0xFF; mutable.mutX(x); mutable.mutY(y); - if (mask.test(mutable)) { + if (mask.test(mutable.toBlockVector3())) { floor.setInt(index, combined); main.setInt(index, combined); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/OreGen.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/OreGen.java index 47e78d776..8ce917252 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/OreGen.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/OreGen.java @@ -43,7 +43,7 @@ public class OreGen extends Resource { @Override public boolean spawn(Random rand, int x, int z) throws WorldEditException { int y = rand.nextInt(maxY - minY) + minY; - if (!mask.test(mutable.setComponents(x, y, z))) { + if (!mask.test(mutable.setComponents(x, y, z).toBlockVector3())) { return false; } double f = rand.nextDouble() * Math.PI; @@ -106,8 +106,8 @@ public class OreGen extends Resource { double dz = (zz + 0.5D - d9) * id11o2; double dxyz2 = dxy2 + dz * dz; if ((dxyz2 < 1)) { - if (mask.test(mutable)) - pattern.apply(extent, mutable, mutable); + if (mask.test(mutable.toBlockVector3())) + pattern.apply(extent, mutable.toBlockVector3(), mutable.toBlockVector3()); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/SchemGen.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/SchemGen.java index d39f3b9c3..bf0570823 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/SchemGen.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/SchemGen.java @@ -36,7 +36,7 @@ public class SchemGen extends Resource { int y = extent.getNearestSurfaceTerrainBlock(x, z, mutable.getBlockY(), 0, 255); if (y == -1) return false; mutable.mutY(y); - if (!mask.test(mutable)) { + if (!mask.test(mutable.toBlockVector3())) { return false; } mutable.mutY(y + 1); @@ -48,9 +48,9 @@ public class SchemGen extends Resource { Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { - schematic.paste(extent, mutable, false); + schematic.paste(extent, mutable.toBlockVector3(), false); } else { - schematic.paste(extent, mutable, false, transform); + schematic.paste(extent, mutable.toBlockVector3(), false, transform); } mutable.mutY(y); return true; 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 153342707..4e60fb01f 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 @@ -286,9 +286,9 @@ public interface FaweQueue extends HasFaweQueue, Extent { CompoundTag tile = getTileEntity(x, y, z); if (tile != null) { BaseBlock block = BaseBlock.getFromInternalId(combined, tile); - onEach.run(mutable, block); + onEach.run(mutable.toBlockVector3(), block); } else { - onEach.run(mutable, state); + onEach.run(mutable.toBlockVector3(), state); } } } @@ -316,7 +316,7 @@ public interface FaweQueue extends HasFaweQueue, Extent { mutable.mutZ(zz); mutable.mutY(y); BaseBlock block = BaseBlock.getFromInternalId(combined, tile); - onEach.run(mutable, block); + onEach.run(mutable.toBlockVector3(), block); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java index 80a6c53d7..4cf217e94 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java @@ -80,7 +80,7 @@ public class BlobBrush implements Brush { mutable.mutY(yr); for (int zr = -sizeInt; zr <= sizeInt; zr++) { mutable.mutZ(zr); - Vector3 pt = transform.apply(mutable); + Vector3 pt = transform.apply(mutable.toVector3()); int x = MathMan.roundInt(pt.getX()); int y = MathMan.roundInt(pt.getY()); int z = MathMan.roundInt(pt.getZ()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java index 34007b9f4..db6d15120 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java @@ -98,11 +98,11 @@ public class ImageBrush implements Brush { int dy = vector.getBlockY() - cy; int dz = vector.getBlockZ() - cz; - Vector3 pos1 = transform.apply(mutable.setComponents(dx - 0.5, dy - 0.5, dz - 0.5)); + Vector3 pos1 = transform.apply(mutable.setComponents(dx - 0.5, dy - 0.5, dz - 0.5).toVector3()); int x1 = (int) (pos1.getX() * scale + centerX); int z1 = (int) (pos1.getZ() * scale + centerZ); - Vector3 pos2 = transform.apply(mutable.setComponents(dx + 0.5, dy + 0.5, dz + 0.5)); + Vector3 pos2 = transform.apply(mutable.setComponents(dx + 0.5, dy + 0.5, dz + 0.5).toVector3()); int x2 = (int) (pos2.getX() * scale + centerX); int z2 = (int) (pos2.getZ() * scale + centerZ); if (x2 < x1) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java index 687cedc63..31e41cb2c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java @@ -53,9 +53,9 @@ public class LayerBrush implements Brush { int previous2 = layers[depth - 2].getInternalId(); for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) { mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ()); - if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) { + if (visitor.isVisited(mutable.toBlockVector3()) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) { mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2); - if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) { + if (visitor.isVisited(mutable.toBlockVector3()) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) { found = true; break; } else { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java index fd22324ff..e2f9560ac 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java @@ -77,7 +77,8 @@ public class ShatterBrush extends ScatterBrush { int dSqr = (dx * dx) + (dy * dy) + (dz * dz); if (dSqr <= radius2) { MutableBlockVector v = mutable.setComponents(x2, y2, z2); - if (surfaceTest.test(v) && finalMask.test(v)) { + BlockVector3 bv = v.toBlockVector3(); + if (surfaceTest.test(bv) && finalMask.test(bv)) { // (collision) If it's visited and part of another frontier, set the block if (!placed.add(x2, y2, z2)) { if (!frontierVisited.contains(x2, y2, z2)) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java index 5c6acae47..658fb88b2 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 @@ -157,7 +157,7 @@ public class SplineBrush implements Brush, ResettableTool { sum.mutY(sum.getY() + p.getY()); sum.mutZ(sum.getZ() + p.getZ()); } - return sum.multiply(1.0 / points.size()); + return sum.multiply(1.0 / points.size()).toVector3(); } private BlockVector3 normal(Collection points, BlockVector3 centroid) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java index 00b4e070a..f95ff1799 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java @@ -73,7 +73,7 @@ public class StencilBrush extends HeightBrush { int dy = vector.getBlockY() - cy; int dz = vector.getBlockZ() - cz; - Vector3 srcPos = transform.apply(mutable.setComponents(dx, dy, dz)); + Vector3 srcPos = transform.apply(mutable.setComponents(dx, dy, dz).toVector3()); dx = MathMan.roundInt(srcPos.getX()); dz = MathMan.roundInt(srcPos.getZ()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java index 548eeeaf8..c3bf06e11 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 @@ -60,7 +60,7 @@ public class SurfaceSpline implements Brush { tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, 0, maxY); if (tipy == -1) continue; if (radius == 0) { - BlockVector3 set = MutableBlockVector.get(tipx, tipy, tipz); + BlockVector3 set = MutableBlockVector.get(tipx, tipy, tipz).toBlockVector3(); try { pattern.apply(editSession, set, set); } catch (WorldEditException e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java index 8569ea195..29b8c66de 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java @@ -22,7 +22,7 @@ public class RotatableHeightMap extends AbstractDelegateHeightMap { public double getHeight(int x, int z) { mutable.mutX(x); mutable.mutZ(z); - BlockVector3 pos = transform.apply(mutable.setComponents(x, 0, z)).toBlockPoint(); + BlockVector3 pos = transform.apply(mutable.setComponents(x, 0, z).toVector3()).toBlockPoint(); return super.getHeight(pos.getBlockX(), pos.getBlockZ()); } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java index 8f17679b4..1535d875e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java @@ -81,7 +81,7 @@ public class ScalableHeightMap implements com.boydti.fawe.object.brush.heightmap MutableBlockVector bv = new MutableBlockVector(pos); for (int y = minY; y <= maxY; y++) { bv.mutY(y); - BlockStateHolder block = clipboard.getBlock(bv); + BlockStateHolder block = clipboard.getBlock(bv.toBlockVector3()); if (!block.getBlockType().getMaterial().isAir()) { highestY = y + 1; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java index c950f8bf3..7df002287 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java @@ -25,11 +25,11 @@ public class MutableBiomeChange implements Change { @Override public void undo(UndoContext context) throws WorldEditException { - context.getExtent().setBiome(mutable, from); + context.getExtent().setBiome(mutable.toBlockVector2(), from); } @Override public void redo(UndoContext context) throws WorldEditException { - context.getExtent().setBiome(mutable, to); + context.getExtent().setBiome(mutable.toBlockVector2(), to); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java index 2c570edd3..b1643ae33 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java @@ -57,7 +57,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { @Override public BaseBiome getBiome(int x, int z) { - return extent.getBiome(mutableBlockVector2D.setComponents(mx + x, mz + z)); + return extent.getBiome(mutableBlockVector2D.setComponents(mx + x, mz + z).toBlockVector2()); } @Override @@ -137,7 +137,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { pos.mutX(x); int xx = pos.getBlockX() - mx; - if (region.contains(pos)) { + if (region.contains(pos.toBlockVector3())) { BlockState block = getBlockAbs(x, y, z); if (!air && block.getBlockType().getMaterial().isAir()) { continue; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java index cc69c2f8b..be4dc649a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java @@ -50,7 +50,7 @@ public class BlockVectorSet extends AbstractCollection implements int cz = MathMan.unpairY(pair); pos.mutX((cx << 11) + pos.getBlockX()); pos.mutZ((cz << 11) + pos.getBlockZ()); - return pos; + return pos.toBlockVector3(); } } count += newSize; @@ -117,7 +117,7 @@ public class BlockVectorSet extends AbstractCollection implements int pair = entry.getIntKey(); int cx = MathMan.unpairX(pair); int cz = MathMan.unpairY(pair); - return mutable.setComponents((cx << 11) + localPos.getBlockX(), localPos.getBlockY(), (cz << 11) + localPos.getBlockZ()); + return mutable.setComponents((cx << 11) + localPos.getBlockX(), localPos.getBlockY(), (cz << 11) + localPos.getBlockZ()).toBlockVector3(); } }; } 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 72d483733..bb06f78b9 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 @@ -102,7 +102,7 @@ public class LocalBlockVector2DSet implements Set { if (index != -1) { int x = MathMan.unpairSearchCoordsX(index); int y = MathMan.unpairSearchCoordsY(index); - return mutable.setComponents(x, y); + return mutable.setComponents(x, y).toBlockVector2(); } return null; } @@ -131,7 +131,7 @@ public class LocalBlockVector2DSet implements Set { mutable.setComponents(x, y); previous = index; index = set.nextSetBit(index + 1); - return mutable; + return mutable.toBlockVector2(); } return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/LocalBlockVectorSet.java index d4aff5660..710c83682 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 @@ -117,7 +117,7 @@ public class LocalBlockVectorSet implements Set { int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); int y = b1; int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); - return MutableBlockVector.get(x, y, z); + return MutableBlockVector.get(x, y, z).toBlockVector3(); } return null; } @@ -151,7 +151,7 @@ public class LocalBlockVectorSet implements Set { mutable.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21)); previous = index; index = set.nextSetBit(index + 1); - return mutable; + return mutable.toBlockVector3(); } return null; } @@ -310,7 +310,7 @@ public class LocalBlockVectorSet implements Set { public void forEach(BlockVectorSetVisitor visitor) { int size = size(); int index = -1; - BlockVector3 mVec = MutableBlockVector.get(0, 0, 0); + BlockVector3 mVec = MutableBlockVector.get(0, 0, 0).toBlockVector3(); for (int i = 0; i < size; i++) { index = set.nextSetBit(index + 1); int b1 = (index & 0xFF); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java index 02ea126b3..56ce8bc33 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/BlockTranslateExtent.java @@ -28,7 +28,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent { mutable.mutX((location.getX() + dx)); mutable.mutY((location.getY() + dy)); mutable.mutZ((location.getZ() + dz)); - return getExtent().setBlock(mutable, block); + return getExtent().setBlock(mutable.toBlockVector3(), block); } @Override @@ -36,7 +36,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent { mutable.mutX(x + dx); mutable.mutY(y + dy); mutable.mutZ(z + dz); - return getExtent().setBlock(mutable, block); + return getExtent().setBlock(mutable.toBlockVector3(), block); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java index b652e741f..e6c22493d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java @@ -23,7 +23,7 @@ public class OffsetExtent extends ResettableExtent { @Override public boolean setBiome(BlockVector2 position, BaseBiome biome) { - return getExtent().setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz), biome); + return getExtent().setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz).toBlockVector2(), biome); } @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 dbe59d503..4b8ed466b 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 @@ -83,7 +83,7 @@ public class PositionTransformExtent extends ResettableExtent { mutable.mutX(position.getBlockX()); mutable.mutZ(position.getBlockZ()); mutable.mutY(0); - return super.getBiome(getPos(mutable).toBlockVector2()); + return super.getBiome(getPos(mutable.toBlockVector3()).toBlockVector2()); } @Override @@ -102,7 +102,7 @@ public class PositionTransformExtent extends ResettableExtent { mutable.mutX(position.getBlockX()); mutable.mutZ(position.getBlockZ()); mutable.mutY(0); - return super.setBiome(getPos(mutable).toBlockVector2(), biome); + return super.setBiome(getPos(mutable.toBlockVector3()).toBlockVector2(), biome); } public void setTransform(Transform transform) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java index 54ab458c6..2f5700203 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java @@ -30,7 +30,7 @@ public class RandomOffsetTransform extends ResettableExtent { public boolean setBiome(BlockVector2 pos, BaseBiome biome) { int x = pos.getBlockX() + random.nextInt(1 + (dx << 1)) - dx; int z = pos.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz; - return getExtent().setBiome(mutable.setComponents(x, z), biome); + return getExtent().setBiome(mutable.setComponents(x, z).toBlockVector2(), biome); } @Override 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 937573404..e53ad52fc 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 @@ -46,7 +46,7 @@ public class ScaleTransform extends ResettableExtent { mutable.mutX((min.getX() + (pos.getX() - min.getX()) * dx)); mutable.mutY((min.getY() + (pos.getY() - min.getY()) * dy)); mutable.mutZ((min.getZ() + (pos.getZ() - min.getZ()) * dz)); - return mutable; + return mutable.toBlockVector3(); } private BlockVector3 getPos(int x, int y, int z) { @@ -56,7 +56,7 @@ public class ScaleTransform extends ResettableExtent { mutable.mutX((min.getX() + (x - min.getX()) * dx)); mutable.mutY((min.getY() + (y - min.getY()) * dy)); mutable.mutZ((min.getZ() + (z - min.getZ()) * dz)); - return mutable; + return mutable.toBlockVector3(); } @@ -73,7 +73,7 @@ public class ScaleTransform extends ResettableExtent { for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) { for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { - result |= super.setBlock(pos, block); + result |= super.setBlock(pos.toBlockVector3(), block); } } } @@ -109,7 +109,7 @@ public class ScaleTransform extends ResettableExtent { for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) { for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { - result |= super.setBlock(pos, block); + result |= super.setBlock(pos.toBlockVector3(), block); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java index 53aea79da..b9b5699a9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java @@ -54,6 +54,6 @@ public class SourceMaskExtent extends TemporalExtent { mutable.mutX(x); mutable.mutY(y); mutable.mutZ(z); - return mask.test(mutable) && super.setBlock(x, y, z, block); + return mask.test(mutable.toBlockVector3()) && super.setBlock(x, y, z, block); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java index e0082d330..f39d98d93 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 @@ -34,15 +34,15 @@ public class TransformExtent extends BlockTransformExtent { @Override public BlockVector3 getMinimumPoint() { - BlockVector3 pos1 = new MutableBlockVector(getPos(super.getMinimumPoint())); - BlockVector3 pos2 = new MutableBlockVector(getPos(super.getMaximumPoint())); + BlockVector3 pos1 = getPos(super.getMinimumPoint()); + BlockVector3 pos2 = getPos(super.getMaximumPoint()); return pos1.getMinimum(pos2); } @Override public BlockVector3 getMaximumPoint() { - BlockVector3 pos1 = new MutableBlockVector(getPos(super.getMinimumPoint())); - BlockVector3 pos2 = new MutableBlockVector(getPos(super.getMaximumPoint())); + BlockVector3 pos1 = getPos(super.getMinimumPoint()); + BlockVector3 pos2 = getPos(super.getMaximumPoint()); return pos1.getMaximum(pos2); } @@ -99,7 +99,7 @@ public class TransformExtent extends BlockTransformExtent { mutable.mutX(position.getBlockX()); mutable.mutZ(position.getBlockZ()); mutable.mutY(0); - return super.getBiome(getPos(mutable).toBlockVector2()); + return super.getBiome(getPos(mutable.toBlockVector3()).toBlockVector2()); } @Override @@ -118,6 +118,6 @@ public class TransformExtent extends BlockTransformExtent { mutable.mutX(position.getBlockX()); mutable.mutZ(position.getBlockZ()); mutable.mutY(0); - return super.setBiome(getPos(mutable).toBlockVector2(), biome); + return super.setBiome(getPos(mutable.toBlockVector3()).toBlockVector2(), biome); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/function/SurfaceRegionFunction.java b/worldedit-core/src/main/java/com/boydti/fawe/object/function/SurfaceRegionFunction.java index ddaf51d58..c2bfc4825 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/function/SurfaceRegionFunction.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/function/SurfaceRegionFunction.java @@ -30,7 +30,7 @@ public class SurfaceRegionFunction implements FlatRegionFunction { int layer = extent.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY, false); if (layer != -1) { lastY = layer; - return function.apply(mutable.setComponents(x, layer, z)); + return function.apply(mutable.setComponents(x, layer, z).toBlockVector3()); } return false; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/BiomeCopy.java b/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/BiomeCopy.java index ddd216369..582ce0e19 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/BiomeCopy.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/BiomeCopy.java @@ -3,6 +3,7 @@ package com.boydti.fawe.object.function.block; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.RegionFunction; +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector2D; @@ -24,7 +25,8 @@ public class BiomeCopy implements RegionFunction { int z = position.getBlockZ(); if (x != mPos2d.getBlockX() || z != mPos2d.getBlockZ()) { mPos2d.setComponents(x, z); - return destination.setBiome(mPos2d, source.getBiome(mPos2d)); + BlockVector2 bv = mPos2d.toBlockVector2(); + return destination.setBiome( bv, source.getBiome(bv)); } return false; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java index a3fa905e6..76ae10ad6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java @@ -58,23 +58,23 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask { int y = v.getBlockY(); int z = v.getBlockZ(); if (mask.test(x + 1, y, z)) { - return mutable.setComponents(1, 0, 0); - } + mutable.setComponents(1, 0, 0); + }else if (mask.test(x - 1, y, z)) { - return mutable.setComponents(-1, 0, 0); - } + mutable.setComponents(-1, 0, 0); + }else if (mask.test(x, y, z + 1)) { - return mutable.setComponents(0, 0, 1); - } + mutable.setComponents(0, 0, 1); + }else if (mask.test(x, y, z - 1)) { - return mutable.setComponents(0, 0, -1); - } - if (y < 256 && mask.test(x, y + 1, z)) { - return mutable.setComponents(0, 1, 0); - } - if (y > 0 && mask.test(x, y - 1, z)) { - return mutable.setComponents(0, -1, 0); - } - return null; + mutable.setComponents(0, 0, -1); + }else + if (y < 256 && mask.test(x, y + 1, z)) { + mutable.setComponents(0, 1, 0); + }else + if (y > 0 && mask.test(x, y - 1, z)) { + mutable.setComponents(0, -1, 0); + } + return (mutable.getX() == 0 && mutable.getY() == 0 && mutable.getZ() == 0) ? null : mutable.toBlockVector3(); } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java index 851915978..4607bbb66 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java @@ -21,38 +21,38 @@ public class AdjacentMask extends AbstractMask { public boolean test(BlockVector3 bv) { v.setComponents(bv); int count = 0; - double x = v.getX(); - double y = v.getY(); - double z = v.getZ(); + double x = bv.getX(); + double y = bv.getY(); + double z = bv.getZ(); v.mutX(x + 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x - 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x); v.mutY(y + 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutY(y); return true; } v.mutY(y - 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutY(y); return true; } v.mutY(y); v.mutZ(z + 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutZ(z); return true; } v.mutZ(z - 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutZ(z); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/BiomeMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/BiomeMask.java index 679c15735..13d4444d4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/BiomeMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/BiomeMask.java @@ -23,7 +23,7 @@ public class BiomeMask extends AbstractExtentMask implements ResettableMask { @Override public boolean test(BlockVector3 vector) { - BlockVector2 pos = mutable.setComponents(vector.getBlockX(), vector.getBlockZ()); + BlockVector2 pos = mutable.setComponents(vector.getBlockX(), vector.getBlockZ()).toBlockVector2(); return getExtent().getBiome(pos).getId() == biome.getId(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java index b5ee4a811..0e08d7ee0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/CachedMask.java @@ -51,11 +51,11 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask { if (!check) { return cache_results.contains(x, y, z); } - boolean result = getMask().test(mutable.setComponents(x, y, z)); + boolean result = getMask().test(mutable.setComponents(x, y, z).toBlockVector3()); if (result) cache_results.add(x, y, z); return result; } catch (UnsupportedOperationException ignore) { - boolean result = getMask().test(mutable.setComponents(x, y, z)); + boolean result = getMask().test(mutable.setComponents(x, y, z).toBlockVector3()); if (y < 0 || y > 255) return result; resetCache(); cache_checked.setOffset(x, z); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java index aae0022b1..824ca358d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SolidPlaneMask.java @@ -34,13 +34,13 @@ public class SolidPlaneMask extends SolidBlockMask implements ResettableMask { originZ = vector.getBlockZ(); mode = 0; Extent extent = getExtent(); - if (!extent.getBlockType(mutable.setComponents(originX - 1, originY, originZ)).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX + 1, originY, originZ)).getMaterial().isAir()) { + if (!extent.getBlockType(mutable.setComponents(originX - 1, originY, originZ).toBlockVector3()).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX + 1, originY, originZ).toBlockVector3()).getMaterial().isAir()) { mode &= 1; } - if (!extent.getBlockType(mutable.setComponents(originX, originY, originZ - 1)).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY, originZ + 1)).getMaterial().isAir()) { + if (!extent.getBlockType(mutable.setComponents(originX, originY, originZ - 1).toBlockVector3()).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY, originZ + 1).toBlockVector3()).getMaterial().isAir()) { mode &= 4; } - if (!extent.getBlockType(mutable.setComponents(originX, originY - 1, originZ + 1)).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY + 1, originZ + 1)).getMaterial().isAir()) { + if (!extent.getBlockType(mutable.setComponents(originX, originY - 1, originZ + 1).toBlockVector3()).getMaterial().isAir() && !extent.getBlockType(mutable.setComponents(originX, originY + 1, originZ + 1).toBlockVector3()).getMaterial().isAir()) { mode &= 2; } if (Integer.bitCount(mode) >= 3) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java index 9776acfe7..85f3bbce0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/WallMask.java @@ -25,23 +25,23 @@ public class WallMask extends AbstractMask { double y = v.getY(); double z = v.getZ(); v.mutX(x + 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x - 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutX(x); return true; } v.mutX(x); v.mutZ(z + 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutZ(z); return true; } v.mutZ(z - 1); - if (mask.test(v) && ++count == min && max >= 8) { + if (mask.test(v.toBlockVector3()) && ++count == min && max >= 8) { v.mutZ(z); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java index cb71d055c..cbde00836 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java @@ -15,7 +15,7 @@ import java.io.IOException; public class NoXPattern extends AbstractPattern { private final Pattern pattern; - private transient MutableBlockVector mutable = new MutableBlockVector(); +// private transient MutableBlockVector mutable = new MutableBlockVector(); public NoXPattern(Pattern pattern) { this.pattern = pattern; @@ -23,20 +23,21 @@ public class NoXPattern extends AbstractPattern { @Override public BlockStateHolder apply(BlockVector3 pos) { - mutable.mutY((pos.getY())); - mutable.mutZ((pos.getZ())); - return pattern.apply(mutable); +// mutable.mutY((pos.getY())); +// mutable.mutZ((pos.getZ())); +// return pattern.apply(mutable.toBlockVector3()); + return pattern.apply(pos); } @Override public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException { - mutable.mutY((get.getY())); - mutable.mutZ((get.getZ())); - return pattern.apply(extent, set, mutable); +// mutable.mutY((get.getY())); +// mutable.mutZ((get.getZ())); + return pattern.apply(extent, set, get); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); - mutable = new MutableBlockVector(); +// mutable = new MutableBlockVector(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java index 451a17a59..e4dffad72 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java @@ -20,24 +20,24 @@ public class NoYPattern extends AbstractPattern { this.pattern = pattern; } - private transient MutableBlockVector mutable = new MutableBlockVector(); +// private transient MutableBlockVector mutable = new MutableBlockVector(); @Override public BlockStateHolder apply(BlockVector3 pos) { - mutable.mutX((pos.getX())); - mutable.mutZ((pos.getZ())); - return pattern.apply(mutable); +// mutable.mutX((pos.getX())); +// mutable.mutZ((pos.getZ())); + return pattern.apply(pos); } @Override public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException { - mutable.mutX((get.getX())); - mutable.mutZ((get.getZ())); - return pattern.apply(extent, set, mutable); +// mutable.mutX((get.getX())); +// mutable.mutZ((get.getZ())); + return pattern.apply(extent, set, get); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); - mutable = new MutableBlockVector(); +// mutable = new MutableBlockVector(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java index fa45fc95e..2556286e9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java @@ -20,24 +20,24 @@ public class NoZPattern extends AbstractPattern { this.pattern = pattern; } - private transient MutableBlockVector mutable = new MutableBlockVector(); +// private transient MutableBlockVector mutable = new MutableBlockVector(); @Override public BlockStateHolder apply(BlockVector3 pos) { - mutable.mutX((pos.getX())); - mutable.mutY((pos.getY())); - return pattern.apply(mutable); +// mutable.mutX((pos.getX())); +// mutable.mutY((pos.getY())); + return pattern.apply(pos); } @Override public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException { - mutable.mutX((get.getX())); - mutable.mutY((get.getY())); - return pattern.apply(extent, set, mutable); +// mutable.mutX((get.getX())); +// mutable.mutY((get.getY())); + return pattern.apply(extent, set, get); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); - mutable = new MutableBlockVector(); +// mutable = new MutableBlockVector(); } } 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 c557ca686..5c0ae033c 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 @@ -15,7 +15,7 @@ import java.io.IOException; public class OffsetPattern extends AbstractPattern { private final int dx, dy, dz; - private transient MutableBlockVector mutable = new MutableBlockVector(); +// private transient MutableBlockVector mutable = new MutableBlockVector(); private final Pattern pattern; public OffsetPattern(Pattern pattern, int dx, int dy, int dz) { @@ -27,22 +27,24 @@ public class OffsetPattern extends AbstractPattern { @Override public BlockStateHolder apply(BlockVector3 position) { - mutable.mutX((position.getX() + dx)); - mutable.mutY((position.getY() + dy)); - mutable.mutZ((position.getZ() + dz)); - return pattern.apply(mutable); +// mutable.mutX((position.getX() + dx)); +// 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)); } @Override public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException { - mutable.mutX((get.getX() + dx)); - mutable.mutY((get.getY() + dy)); - mutable.mutZ((get.getZ() + dz)); - return pattern.apply(extent, set, mutable); +// mutable.mutX((get.getX() + dx)); +// mutable.mutY((get.getY() + dy)); +// mutable.mutZ((get.getZ() + dz)); +// return pattern.apply(extent, set, mutable); + return pattern.apply(extent, set, new BlockVector3(get.getX() + dx, get.getY() + dy, get.getZ() + dz)); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); - mutable = new MutableBlockVector(); +// mutable = new MutableBlockVector(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java index 952d26d0c..3fa8190a2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java @@ -38,7 +38,7 @@ public class RandomOffsetPattern extends AbstractPattern { mutable.mutX((position.getX() + r.nextInt(dx2) - dx)); mutable.mutY((position.getY() + r.nextInt(dy2) - dy)); mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz)); - return pattern.apply(mutable); + return pattern.apply(mutable.toBlockVector3()); } @Override @@ -46,7 +46,7 @@ public class RandomOffsetPattern extends AbstractPattern { mutable.mutX((get.getX() + r.nextInt(dx2) - dx)); mutable.mutY((get.getY() + r.nextInt(dy2) - dy)); mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz)); - return pattern.apply(extent, set, mutable); + return pattern.apply(extent, set, mutable.toBlockVector3()); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java index dce3c993d..296b4f0e2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java @@ -30,7 +30,7 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter mutable.mutX((pos.getX() - origin.getX())); mutable.mutY((pos.getY() - origin.getY())); mutable.mutZ((pos.getZ() - origin.getZ())); - return pattern.apply(mutable); + return pattern.apply(mutable.toBlockVector3()); } @Override @@ -41,7 +41,7 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter mutable.mutX((get.getX() - origin.getX())); mutable.mutY((get.getY() - origin.getY())); mutable.mutZ((get.getZ() - origin.getZ())); - return pattern.apply(extent, set, mutable); + return pattern.apply(extent, set, mutable.toBlockVector3()); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java index 845ec1d86..159b7ea38 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java @@ -48,7 +48,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern { mutable.mutX((position.getX() + r.nextInt(dx2) - dx)); mutable.mutY((position.getY() + r.nextInt(dy2) - dy)); mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz)); - BlockStateHolder block = pattern.apply(mutable); + BlockStateHolder block = pattern.apply(mutable.toBlockVector3()); if (solid[block.getInternalBlockTypeId()]) { return block; } else { @@ -61,9 +61,9 @@ public class SolidRandomOffsetPattern extends AbstractPattern { mutable.mutX((get.getX() + r.nextInt(dx2) - dx)); mutable.mutY((get.getY() + r.nextInt(dy2) - dy)); mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz)); - BlockStateHolder block = pattern.apply(mutable); + BlockStateHolder block = pattern.apply(mutable.toBlockVector3()); if (solid[block.getInternalBlockTypeId()]) { - return pattern.apply(extent, set, mutable); + return pattern.apply(extent, set, mutable.toBlockVector3()); } else { return pattern.apply(extent, set, get); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java index 7d6fab7ea..f480b1b1f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java @@ -50,22 +50,22 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { next = buffer[i]; BlockVector3 dir = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i]; next.setComponents(cur.getBlockX() + dir.getBlockX(), cur.getBlockY() + dir.getBlockY(), cur.getBlockZ() + dir.getBlockZ()); - if (allowed(next)) { + if (allowed(next.toBlockVector3())) { allowed[index++] = next; } } if (index == 0) { - return cur; + return cur.toBlockVector3(); } next = allowed[PseudoRandom.random.nextInt(index)]; cur.setComponents(next.getBlockX(), next.getBlockY(), next.getBlockZ()); } - return cur; + return cur.toBlockVector3(); } private boolean allowed(BlockVector3 bv) { MutableBlockVector v = new MutableBlockVector(bv); - BlockStateHolder block = pattern.apply(v); + BlockStateHolder block = pattern.apply(bv); if (!block.getBlockType().getMaterial().isMovementBlocker()) { return false; } @@ -73,34 +73,34 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { int y = v.getBlockY(); int z = v.getBlockZ(); v.mutY(y + 1); - if (canPassthrough(v)) { + if (canPassthrough(v.toBlockVector3())) { v.mutY(y); return true; } v.mutY(y - 1); - if (canPassthrough(v)) { + if (canPassthrough(v.toBlockVector3())) { v.mutY(y); return true; } v.mutY(y); v.mutX(x + 1); - if (canPassthrough(v)) { + if (canPassthrough(v.toBlockVector3())) { v.mutX(x); return true; } v.mutX(x - 1); - if (canPassthrough(v)) { + if (canPassthrough(v.toBlockVector3())) { v.mutX(x); return true; } v.mutX(x); v.mutZ(z + 1); - if (canPassthrough(v)) { + if (canPassthrough(v.toBlockVector3())) { v.mutZ(z); return true; } v.mutZ(z - 1); - if (canPassthrough(v)) { + if (canPassthrough(v.toBlockVector3())) { v.mutZ(z); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/FaweQueueDelegateExtent.java index 4a0f361f3..3951e8728 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 @@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class FaweQueueDelegateExtent extends DelegateFaweQueue { private final FaweQueue parentQueue; private final Extent parentExtent; - private final MutableBlockVector2D mutable2d = new MutableBlockVector2D(); +// private final MutableBlockVector2D mutable2d = new MutableBlockVector2D(); public FaweQueueDelegateExtent(FaweQueue parentQueue, Extent parentExtent) { super(parentQueue); @@ -58,7 +58,7 @@ public class FaweQueueDelegateExtent extends DelegateFaweQueue { @Override public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException { - return parentExtent.getBiome(mutable2d.setComponents(x, z)).getId(); + return parentExtent.getBiome(new BlockVector2(x, z)).getId(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java index 197324020..654fdd9d3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java @@ -19,8 +19,10 @@ package com.boydti.fawe.object.regions; -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MutableBlockVector; +import com.sk89q.worldedit.math.MutableVector; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.regions.polyhedron.Edge; @@ -36,7 +38,7 @@ public class PolyhedralRegion extends AbstractRegion { /** * Vertices that are contained in the convex hull. */ - private final Set vertices = new LinkedHashSet(); + private final Set vertices = new LinkedHashSet(); /** * Triangles that form the convex hull. @@ -46,22 +48,22 @@ public class PolyhedralRegion extends AbstractRegion { /** * Vertices that are coplanar to the first 3 vertices. */ - private final Set vertexBacklog = new LinkedHashSet(); + private final Set vertexBacklog = new LinkedHashSet(); /** * Minimum point of the axis-aligned bounding box. */ - private Vector minimumPoint; + private BlockVector3 minimumPoint; /** * Maximum point of the axis-aligned bounding box. */ - private Vector maximumPoint; + private BlockVector3 maximumPoint; /** * Accumulator for the barycenter of the polyhedron. Divide by vertices.size() to get the actual center. */ - private Vector centerAccum = Vector.ZERO; + private BlockVector3 centerAccum = BlockVector3.ZERO; /** * The last triangle that caused a {@link #contains(Vector)} to classify a point as "outside". Used for optimization. @@ -104,7 +106,7 @@ public class PolyhedralRegion extends AbstractRegion { minimumPoint = null; maximumPoint = null; - centerAccum = Vector.ZERO; + centerAccum = BlockVector3.ZERO; lastTriangle = null; } @@ -115,7 +117,7 @@ public class PolyhedralRegion extends AbstractRegion { * @param vertex the vertex * @return true, if something changed. */ - public boolean addVertex(Vector vertex) { + public boolean addVertex(BlockVector3 vertex) { checkNotNull(vertex); lastTriangle = null; // Probably not necessary @@ -141,8 +143,10 @@ public class PolyhedralRegion extends AbstractRegion { if (minimumPoint == null) { minimumPoint = maximumPoint = vertex; } else { - minimumPoint = new MutableBlockVector(Vector.getMinimum(minimumPoint, vertex)); - maximumPoint = new MutableBlockVector(Vector.getMaximum(maximumPoint, vertex)); +// minimumPoint = new MutableBlockVector(minimumPoint.getMinimum(vertex)); +// maximumPoint = new MutableBlockVector(maximumPoint.getMaximum(vertex)); + minimumPoint = minimumPoint.getMinimum(vertex); + maximumPoint = maximumPoint.getMaximum(vertex); } int size = vertices.size(); @@ -155,7 +159,7 @@ public class PolyhedralRegion extends AbstractRegion { case 3: // Generate minimal mesh to start from - final Vector[] v = vertices.toArray(new Vector[vertices.size()]); + final BlockVector3[] v = vertices.toArray(new BlockVector3[vertices.size()]); triangles.add((new Triangle(v[0], v[size - 2], v[size - 1]))); triangles.add((new Triangle(v[0], v[size - 1], v[size - 2]))); @@ -186,8 +190,8 @@ public class PolyhedralRegion extends AbstractRegion { // Add triangles between the remembered edges and the new vertex. for (Edge edge : borderEdges) { - com.sk89q.worldedit.regions.polyhedron.Triangle triangle = edge.createTriangle(vertex); - Triangle fTria = new Triangle(triangle.getVertex(0), triangle.getVertex(1), triangle.getVertex(2)); + com.sk89q.worldedit.regions.polyhedron.Triangle triangle = edge.createTriangle(vertex.toVector3()); + Triangle fTria = new Triangle(triangle.getVertex(0).toBlockPoint(), triangle.getVertex(1).toBlockPoint(), triangle.getVertex(2).toBlockPoint()); triangles.add(fTria); } @@ -196,9 +200,9 @@ public class PolyhedralRegion extends AbstractRegion { vertices.remove(vertex); // Clone, clear and work through the backlog - final List vertexBacklog2 = new ArrayList(vertexBacklog); + final List vertexBacklog2 = new ArrayList(vertexBacklog); vertexBacklog.clear(); - for (Vector vertex2 : vertexBacklog2) { + for (BlockVector3 vertex2 : vertexBacklog2) { addVertex(vertex2); } @@ -213,39 +217,39 @@ public class PolyhedralRegion extends AbstractRegion { } @Override - public Vector getMinimumPoint() { + public BlockVector3 getMinimumPoint() { return minimumPoint; } @Override - public Vector getMaximumPoint() { + public BlockVector3 getMaximumPoint() { return maximumPoint; } @Override - public Vector getCenter() { - return centerAccum.divide(vertices.size()); + public Vector3 getCenter() { + return centerAccum.divide(vertices.size()).toVector3(); } @Override - public void expand(Vector... changes) throws RegionOperationException { + public void expand(BlockVector3... changes) throws RegionOperationException { } @Override - public void contract(Vector... changes) throws RegionOperationException { + public void contract(BlockVector3... changes) throws RegionOperationException { } @Override - public void shift(Vector change) throws RegionOperationException { + public void shift(BlockVector3 change) throws RegionOperationException { shiftCollection(vertices, change); shiftCollection(vertexBacklog, change); for (int i = 0; i < triangles.size(); ++i) { final Triangle triangle = triangles.get(i); - final Vector v0 = change.add(triangle.getVertex(0)); - final Vector v1 = change.add(triangle.getVertex(1)); - final Vector v2 = change.add(triangle.getVertex(2)); + final BlockVector3 v0 = change.add(triangle.getVertex(0).toBlockPoint()); + final BlockVector3 v1 = change.add(triangle.getVertex(1).toBlockPoint()); + final BlockVector3 v2 = change.add(triangle.getVertex(2).toBlockPoint()); triangles.set(i, new Triangle(v0, v1, v2)); } @@ -256,24 +260,24 @@ public class PolyhedralRegion extends AbstractRegion { lastTriangle = null; } - private static void shiftCollection(Collection collection, Vector change) { - final List tmp = new ArrayList(collection); + private static void shiftCollection(Collection collection, BlockVector3 change) { + final List tmp = new ArrayList(collection); collection.clear(); - for (Vector vertex : tmp) { + for (BlockVector3 vertex : tmp) { collection.add(change.add(vertex)); } } @Override - public boolean contains(Vector position) { + public boolean contains(BlockVector3 position) { if (!isDefined()) { return false; } final int x = position.getBlockX(); final int y = position.getBlockY(); final int z = position.getBlockZ(); - final Vector min = getMinimumPoint(); - final Vector max = getMaximumPoint(); + final BlockVector3 min = getMinimumPoint(); + final BlockVector3 max = getMaximumPoint(); if (x < min.getBlockX()) return false; if (x > max.getBlockX()) return false; if (z < min.getBlockZ()) return false; @@ -283,7 +287,7 @@ public class PolyhedralRegion extends AbstractRegion { return containsRaw(position); } - private boolean containsRaw(Vector pt) { + private boolean containsRaw(BlockVector3 pt) { if (lastTriangle != null && lastTriangle.contains(pt)) { return true; } @@ -299,12 +303,12 @@ public class PolyhedralRegion extends AbstractRegion { return false; } - public Collection getVertices() { + public Collection getVertices() { if (vertexBacklog.isEmpty()) { return vertices; } - final List ret = new ArrayList(vertices); + final List ret = new ArrayList(vertices); ret.addAll(vertexBacklog); return ret; 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 5f8b3323b..b6e15531e 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 @@ -3,7 +3,8 @@ package com.boydti.fawe.object.regions; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.StringMan; import com.google.common.base.Preconditions; -import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.polyhedron.Edge; public class Triangle { @@ -23,10 +24,10 @@ public class Triangle { private final double[] vmin = new double[3]; private final double[] vmax = new double[3]; - private final Vector normalVec; + private final BlockVector3 normalVec; private final double b; - public Triangle(Vector pos1, Vector pos2, Vector pos3) { + public Triangle(BlockVector3 pos1, BlockVector3 pos2, BlockVector3 pos3) { verts[0] = new double[]{pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()}; verts[1] = new double[]{pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()}; verts[2] = new double[]{pos3.getBlockX(), pos3.getBlockY(), pos3.getBlockZ()}; @@ -37,16 +38,16 @@ public class Triangle { this.b = Math.max(Math.max(this.normalVec.dot(pos1), this.normalVec.dot(pos2)), this.normalVec.dot(pos3)); } - public boolean above(Vector pt) { + public boolean above(BlockVector3 pt) { Preconditions.checkNotNull(pt); return this.normalVec.dot(pt) > this.b; } public Edge getEdge(int index) { if (index == this.verts.length - 1) { - return new Edge(new Vector(this.verts[index]), new Vector(this.verts[0])); + 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])); } else { - return new Edge(new Vector(this.verts[index]), new Vector(this.verts[index + 1])); + 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])); } } @@ -55,11 +56,11 @@ public class Triangle { return StringMan.getString(verts); } - public Vector getVertex(int index) { - return new Vector(verts[index]); + public Vector3 getVertex(int index) { + return new Vector3(verts[index][0], verts[index][1], verts[index][2]); } - public boolean contains(Vector pos) { + public boolean contains(BlockVector3 pos) { center[0] = pos.getBlockX() + RADIUS; center[1] = pos.getBlockY() + RADIUS; center[2] = pos.getBlockZ() + RADIUS; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java index f14b6f03a..96402196e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java @@ -6,15 +6,14 @@ import com.boydti.fawe.object.regions.FuzzyRegion; import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.MaskTraverser; -import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; @@ -27,7 +26,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio private final Player player; private FuzzyRegion region; - private ArrayList positions; + private ArrayList positions; public FuzzyRegionSelector(Player player, @Nullable World world, Mask mask) { super(new EditSessionBuilder(world) @@ -43,7 +42,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio } @Override - public List getVerticies() { + public List getVerticies() { return positions; } @@ -72,7 +71,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio } @Override - public boolean selectPrimary(Vector position, SelectorLimits limits) { + public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) { setWorld(getWorld()); new MaskTraverser(getMask()).reset(getExtent()); positions.clear(); @@ -83,7 +82,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio } @Override - public boolean selectSecondary(Vector position, SelectorLimits limits) { + public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) { this.positions.add(position); new MaskTraverser(getMask()).reset(getExtent()); this.region.select(position.getBlockX(), position.getBlockY(), position.getBlockZ()); @@ -91,13 +90,13 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio } @Override - public void explainPrimarySelection(Actor actor, LocalSession session, Vector position) { + public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) { int size = this.region.getArea(); BBC.SELECTOR_FUZZY_POS1.send(player, position, "(" + region.getArea() + ")"); } @Override - public void explainSecondarySelection(Actor actor, LocalSession session, Vector position) { + public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) { int size = this.region.getArea(); BBC.SELECTOR_FUZZY_POS2.send(player, position, "(" + region.getArea() + ")"); } @@ -108,11 +107,11 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio } @Override - public BlockVector getPrimaryPosition() throws IncompleteRegionException { + public BlockVector3 getPrimaryPosition() throws IncompleteRegionException { if (positions.isEmpty()) { throw new IncompleteRegionException(); } - return new BlockVector(positions.get(0)); + return positions.get(0); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java index 56229f252..c9a68d2a8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java @@ -21,14 +21,13 @@ package com.boydti.fawe.object.regions.selector; import com.boydti.fawe.object.regions.PolyhedralRegion; import com.boydti.fawe.object.regions.Triangle; -import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.cui.CUIRegion; import com.sk89q.worldedit.internal.cui.SelectionPointEvent; import com.sk89q.worldedit.internal.cui.SelectionPolygonEvent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; @@ -46,7 +45,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { private final transient PolyhedralRegion region; - private transient BlockVector pos1; + private transient BlockVector3 pos1; /** * Create a new selector with a {@code null} world. @@ -65,7 +64,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { } @Override - public List getVerticies() { + public List getVerticies() { return new ArrayList<>(region.getVertices()); } @@ -81,15 +80,15 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { } @Override - public boolean selectPrimary(Vector position, SelectorLimits limits) { + public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) { checkNotNull(position); clear(); - pos1 = position.toBlockVector(); + pos1 = position; return region.addVertex(position); } @Override - public boolean selectSecondary(Vector position, SelectorLimits limits) { + public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) { checkNotNull(position); Optional vertexLimit = limits.getPolyhedronVertexLimit(); @@ -102,7 +101,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { } @Override - public BlockVector getPrimaryPosition() throws IncompleteRegionException { + public BlockVector3 getPrimaryPosition() throws IncompleteRegionException { return pos1; } @@ -132,7 +131,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { @Override public void learnChanges() { - pos1 = region.getVertices().iterator().next().toBlockVector(); + pos1 = region.getVertices().iterator().next(); } @Override @@ -157,7 +156,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { @Override - public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) { + public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) { checkNotNull(player); checkNotNull(session); checkNotNull(pos); @@ -168,7 +167,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { } @Override - public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) { + public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) { checkNotNull(player); checkNotNull(session); checkNotNull(pos); @@ -200,12 +199,12 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { checkNotNull(player); checkNotNull(session); - Collection vertices = region.getVertices(); + Collection vertices = region.getVertices(); Collection triangles = region.getTriangles(); - Map vertexIds = new HashMap(vertices.size()); + Map vertexIds = new HashMap(vertices.size()); int lastVertexId = -1; - for (Vector vertex : vertices) { + for (BlockVector3 vertex : vertices) { vertexIds.put(vertex, ++lastVertexId); session.dispatchCUIEvent(player, new SelectionPointEvent(lastVertexId, vertex, getArea())); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java index 4a90cbe76..a1f89f488 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java @@ -2,10 +2,10 @@ package com.boydti.fawe.object.schematic; import com.boydti.fawe.Fawe; import com.boydti.fawe.util.TextureUtil; -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MutableBlockVector; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -68,12 +68,13 @@ public class PNGWriter implements ClipboardWriter { boolean fill = length * 4 < imageSize && width * 4 < imageSize; - MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); - Vector mutableTop = new Vector(0, 0, 0); - Vector mutableRight = new Vector(0, 0, 0); - Vector mutableLeft = new Vector(0, 0, 0); + MutableBlockVector mutable, mutableTop, mutableRight, mutableLeft; + mutable = mutableTop = mutableRight = mutableLeft = new MutableBlockVector(0, 0, 0); +// Vector mutableTop = new Vector(0, 0, 0); +// Vector mutableRight = new Vector(0, 0, 0); +// Vector mutableLeft = new Vector(0, 0, 0); - Vector min = clipboard.getMinimumPoint(); + BlockVector3 min = clipboard.getMinimumPoint(); int y0 = min.getBlockY(); int z0 = min.getBlockZ(); int x0 = min.getBlockX(); @@ -95,16 +96,16 @@ public class PNGWriter implements ClipboardWriter { double cpy2 = cpy1 + dpyj[zz]; for (int y = y0; y < y0 + height; y++) { mutable.mutY(y); - BlockStateHolder block = clipboard.getBlock(mutable); + BlockStateHolder block = clipboard.getBlock(mutable.toBlockVector3()); if (block.getBlockType().getMaterial().isAir()) { continue; } mutableTop.mutY(y + 1); mutableRight.mutY(y); mutableLeft.mutY(y); - if (!clipboard.getBlock(mutableTop).getBlockType().getMaterial().isAir() && - !clipboard.getBlock(mutableRight).getBlockType().getMaterial().isAir() && - !clipboard.getBlock(mutableLeft).getBlockType().getMaterial().isAir() ) { + if (!clipboard.getBlock(mutableTop.toBlockVector3()).getBlockType().getMaterial().isAir() && + !clipboard.getBlock(mutableRight.toBlockVector3()).getBlockType().getMaterial().isAir() && + !clipboard.getBlock(mutableLeft.toBlockVector3()).getBlockType().getMaterial().isAir() ) { continue; } double cpy = cpy2 - dpxi[y - y0]; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java index 1bd435f19..a5ee6d7de 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 @@ -22,6 +22,7 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.visitor.RegionVisitor; +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector2D; import com.sk89q.worldedit.math.transform.Transform; @@ -220,7 +221,7 @@ public class Schematic { int zz = z + relz; if (xx != mpos2d.getBlockX() || zz != mpos2d.getBlockZ()) { mpos2d.setComponents(xx, zz); - extent.setBiome(mpos2d, bac.IMP.getBiome(x, z)); + extent.setBiome(mpos2d.toBlockVector2(), bac.IMP.getBiome(x, z)); } if (!pasteAir && block.getBlockType().getMaterial().isAir()) { return; @@ -245,7 +246,7 @@ public class Schematic { final int rely = to.getBlockY() - origin.getBlockY(); final int relz = to.getBlockZ() - origin.getBlockZ(); RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() { - MutableBlockVector2D mpos2d_2 = new MutableBlockVector2D(); +// MutableBlockVector2D mpos2d_2 = new MutableBlockVector2D(); MutableBlockVector2D mpos2d = new MutableBlockVector2D(); { mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE); @@ -257,7 +258,8 @@ public class Schematic { int zz = mutable.getBlockZ() + relz; 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, clipboard.getBiome(mpos2d_2.setComponents(mutable.getBlockX(), mutable.getBlockZ()))); + extent.setBiome(mpos2d.toBlockVector2(), clipboard.getBiome(new BlockVector2(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 5720015f9..e759c5908 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 @@ -13,8 +13,6 @@ import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.NamedTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.BaseEntity; @@ -23,6 +21,8 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MutableBlockVector; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.registry.state.AbstractProperty; @@ -77,8 +77,8 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { int length = size.getInt(2); // Init clipboard - Vector origin = new Vector(0, 0, 0); - CuboidRegion region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE)); + BlockVector3 origin = new BlockVector3(0, 0, 0); + CuboidRegion region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE)); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, clipboardId); // Blocks ListTag blocks = (ListTag) tags.get("blocks"); @@ -175,7 +175,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { // Palette { ArrayList> palette = new ArrayList<>(); - for (Vector point : region) { + for (BlockVector3 point : region) { BlockStateHolder block = clipboard.getBlock(point); int combined = block.getInternalId(); BlockTypes type = block.getBlockType(); @@ -215,8 +215,8 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { // Blocks { ArrayList> blocks = new ArrayList<>(); - Vector min = region.getMinimumPoint(); - for (Vector point : region) { + BlockVector3 min = region.getMinimumPoint(); + for (BlockVector3 point : region) { BlockStateHolder block = clipboard.getBlock(point); switch (block.getBlockType()) { case STRUCTURE_VOID: @@ -272,7 +272,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { } } - private Tag writeVector(Vector vector, String name) { + private Tag writeVector(BlockVector3 vector, String name) { List list = new ArrayList(); list.add(new DoubleTag(vector.getX())); list.add(new DoubleTag(vector.getY())); 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 7d78397be..b0bbf1152 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 @@ -18,16 +18,20 @@ import com.google.common.io.Files; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.worldedit.*; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.InputType; import com.sk89q.worldedit.event.platform.PlayerInputEvent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MutableBlockVector2D; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TargetBlock; +import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BlockTypes; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; @@ -53,8 +57,8 @@ public class SchemVis extends ImmutableVirtualWorld { private final MutableBlockVector2D lastPos = new MutableBlockVector2D(); private final FawePlayer player; private final Location origin; - private final BlockVector2D chunkOffset; - private BlockVector2D lastPosition; + private final BlockVector2 chunkOffset; + private BlockVector2 lastPosition; public static SchemVis create(FawePlayer player, Collection files) throws IOException { checkNotNull(player); @@ -76,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 BlockVector2D(pos.x >> 4,pos.z >> 4); + this.chunkOffset = new BlockVector2(pos.x >> 4,pos.z >> 4); } - private Set getFiles(BlockVector2D chunkPosA, BlockVector2D chunkPosB) { - BlockVector2D pos1 = new BlockVector2D(Math.min(chunkPosA.getBlockX(), chunkPosB.getBlockX()), Math.min(chunkPosA.getBlockZ(), chunkPosB.getBlockZ())); - BlockVector2D pos2 = new BlockVector2D(Math.max(chunkPosA.getBlockX(), chunkPosB.getBlockX()), Math.max(chunkPosA.getBlockZ(), chunkPosB.getBlockZ())); + 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())); Set contained = new HashSet<>(); for (Long2ObjectMap.Entry> entry : files.long2ObjectEntrySet()) { long key = entry.getLongKey(); @@ -116,8 +120,8 @@ public class SchemVis extends ImmutableVirtualWorld { LocalSession session = this.player.getSession(); synchronized (this) { try { - BlockVector2D tmpLastPosition = lastPosition; - lastPosition = new BlockVector2D(chunkX, chunkZ); + BlockVector2 tmpLastPosition = lastPosition; + lastPosition = new BlockVector2(chunkX, chunkZ); boolean sneaking = this.player.isSneaking(); if (event.getInputType() == InputType.PRIMARY && !sneaking) { @@ -251,8 +255,8 @@ public class SchemVis extends ImmutableVirtualWorld { * @return offset vector */ @Override - public Vector getOrigin() { - return new BlockVector(chunkOffset.getBlockX() << 4, 0, chunkOffset.getBlockZ() << 4); + public Vector3 getOrigin() { + return new Vector3(chunkOffset.getBlockX() << 4, 0, chunkOffset.getBlockZ() << 4); } /** @@ -313,15 +317,15 @@ public class SchemVis extends ImmutableVirtualWorld { * @param schemDimensions * @return */ - private BlockVector2D registerAndGetChunkOffset(BlockVector2D schemDimensions, File file) { + private BlockVector2 registerAndGetChunkOffset(BlockVector2 schemDimensions, File file) { int chunkX = schemDimensions.getBlockX() >> 4; int chunkZ = schemDimensions.getBlockZ() >> 4; MutableBlockVector2D pos2 = new MutableBlockVector2D(); MutableBlockVector2D curPos = lastPos; // Find next free position - while (!isAreaFree(curPos, pos2.setComponents(curPos.getBlockX() + chunkX, curPos.getBlockZ() + chunkZ))) { + while (!isAreaFree(curPos.toBlockVector2(), pos2.setComponents(curPos.getBlockX() + chunkX, curPos.getBlockZ() + chunkZ).toBlockVector2())) { // if (curPos == lastPos && !files.containsKey(MathMan.pairInt(curPos.getBlockX(), curPos.getBlockZ()))) { -// curPos = new MutableBlockVector2D(); +// curPos = new MutableBlockVector2(); // curPos.setComponents(lastPos.getBlockX(), lastPos.getBlockZ()); // } curPos.nextPosition(); @@ -339,10 +343,10 @@ public class SchemVis extends ImmutableVirtualWorld { } } for (int i = 0; i < Math.min(chunkX, chunkZ); i++) curPos.nextPosition(); - return curPos.toBlockVector2D(); + return curPos.toBlockVector2(); } - private boolean isAreaFree(BlockVector2D chunkPos1, BlockVector2D chunkPos2 /* inclusive */) { + private boolean isAreaFree(BlockVector2 chunkPos1, BlockVector2 chunkPos2 /* inclusive */) { for (int x = chunkPos1.getBlockX(); x <= chunkPos2.getBlockX(); x++) { for (int z = chunkPos1.getBlockZ(); z <= chunkPos2.getBlockZ(); z++) { if (files.containsKey(MathMan.pairInt(x, z)) || (x == 0 && z == 0)) return false; @@ -367,15 +371,15 @@ public class SchemVis extends ImmutableVirtualWorld { if (dimensionPair != null) { int width = (char) MathMan.unpairX(dimensionPair); int length = (char) MathMan.unpairY(dimensionPair); - BlockVector2D dimensions = new BlockVector2D(width, length); - BlockVector2D offset = registerAndGetChunkOffset(dimensions, cached); + BlockVector2 dimensions = new BlockVector2(width, length); + BlockVector2 offset = registerAndGetChunkOffset(dimensions, cached); return; } if (cached.exists() && file.lastModified() <= cached.lastModified()) { try (InputStream fis = new BufferedInputStream(new FileInputStream(cached), 4)) { - BlockVector2D dimensions = new BlockVector2D(IOUtil.readVarInt(fis), IOUtil.readVarInt(fis)); + BlockVector2 dimensions = new BlockVector2(IOUtil.readVarInt(fis), IOUtil.readVarInt(fis)); DIMENSION_CACHE.put(file, MathMan.pair((short) dimensions.getBlockX(), (short) dimensions.getBlockZ())); - BlockVector2D offset = registerAndGetChunkOffset(dimensions, cached); + BlockVector2 offset = registerAndGetChunkOffset(dimensions, cached); } } else { try { @@ -389,9 +393,9 @@ public class SchemVis extends ImmutableVirtualWorld { clipboard.setOrigin(clipboard.getMinimumPoint()); try { MCAQueue queue = new MCAQueue(null, null, false); - BlockVector2D dimensions = clipboard.getDimensions().toVector2D().toBlockVector2D(); - BlockVector2D offset = registerAndGetChunkOffset(dimensions, cached); - new Schematic(clipboard).paste(queue, Vector.ZERO, true); + BlockVector2 dimensions = clipboard.getDimensions().toBlockVector2(); + BlockVector2 offset = registerAndGetChunkOffset(dimensions, cached); + new Schematic(clipboard).paste(queue, BlockVector3.ZERO, true); try (FileOutputStream fos = new FileOutputStream(cached)) { IOUtil.writeVarInt(fos, dimensions.getBlockX()); IOUtil.writeVarInt(fos, dimensions.getBlockZ()); @@ -468,7 +472,7 @@ public class SchemVis extends ImmutableVirtualWorld { int OCZ = MathMan.unpairIntY(origin); try { try (FileInputStream fis = new FileInputStream(cached)) { - BlockVector2D dimensions = new BlockVector2D(IOUtil.readVarInt(fis), IOUtil.readVarInt(fis)); + BlockVector2 dimensions = new BlockVector2(IOUtil.readVarInt(fis), IOUtil.readVarInt(fis)); try (FaweInputStream in = MainUtil.getCompressedIS(fis)) { NonCloseableInputStream nonCloseable = new NonCloseableInputStream(in); try (NBTInputStream nis = new NBTInputStream(nonCloseable)) { @@ -616,4 +620,16 @@ public class SchemVis extends ImmutableVirtualWorld { } } } + + @Override + public boolean playEffect(Vector3 position, int type, int data) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean setBiome(BlockVector2 position, BaseBiome biome) { + // TODO Auto-generated method stub + return false; + } } 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 1b130f976..c5ac0b700 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 @@ -1,10 +1,11 @@ package com.boydti.fawe.object.visitor; import com.boydti.fawe.object.HasFaweQueue; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; +import com.sk89q.worldedit.math.BlockVector3; + import java.util.Collection; @@ -38,18 +39,18 @@ public class AboveVisitor extends RecursiveVisitor { this.baseY = baseY; - Collection directions = getDirections(); + Collection directions = getDirections(); directions.clear(); - directions.add(new Vector(1, 0, 0)); - directions.add(new Vector(-1, 0, 0)); - directions.add(new Vector(0, 0, 1)); - directions.add(new Vector(0, 0, -1)); - directions.add(new Vector(0, 1, 0)); - directions.add(new Vector(0, -1, 0)); + 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)); } @Override - public boolean isVisitable(Vector from, Vector to) { + public boolean isVisitable(BlockVector3 from, BlockVector3 to) { return (from.getBlockY() >= baseY) && super.isVisitable(from, to); } } \ No newline at end of file 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 f7ea5eb28..fc70fd68b 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 @@ -77,8 +77,8 @@ public abstract class DFSVisitor implements Operation { NodePair current; Node from; Node adjacent; - MutableBlockVector mutable = new MutableBlockVector(); - MutableBlockVector mutable2 = new MutableBlockVector(); +// MutableBlockVector mutable = new MutableBlockVector(); +// MutableBlockVector mutable2 = new MutableBlockVector(); int countAdd, countAttempt; IntegerTrio[] dirs = getIntDirections(); @@ -89,18 +89,20 @@ public abstract class DFSVisitor implements Operation { if (visited.containsKey(from)) { continue; } - mutable.mutX(from.getX()); - mutable.mutY(from.getY()); - mutable.mutZ(from.getZ()); - function.apply(mutable); +// mutable.mutX(from.getX()); +// mutable.mutY(from.getY()); +// mutable.mutZ(from.getZ()); + BlockVector3 bv = new BlockVector3(from.getX(), from.getY(), from.getZ()); + function.apply(bv); countAdd = 0; countAttempt = 0; for (IntegerTrio direction : dirs) { - mutable2.mutX(from.getX() + direction.x); - mutable2.mutY(from.getY() + direction.y); - mutable2.mutZ(from.getZ() + direction.z); - if (isVisitable(mutable, mutable2)) { - adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ()); +// 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); + if (isVisitable(bv, bv2)) { + adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ()); if ((current.from == null || !adjacent.equals(current.from))) { AtomicInteger adjacentCount = visited.get(adjacent); if (adjacentCount == null) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/Fast2DIterator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/Fast2DIterator.java index 33379dd08..50a53fdef 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/Fast2DIterator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/Fast2DIterator.java @@ -6,46 +6,47 @@ import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.util.ExtentTraverser; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector2; + import java.util.Iterator; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class Fast2DIterator implements Iterable { +public class Fast2DIterator implements Iterable { - private final Iterable iterable; + private final Iterable iterable; private final MappedFaweQueue queue; - public Fast2DIterator(@Nonnull Iterable iter, @Nullable EditSession extent) { + public Fast2DIterator(@Nonnull Iterable iter, @Nullable EditSession extent) { this(iter, (HasFaweQueue) extent); } - public Fast2DIterator(@Nonnull Iterable iter, @Nullable Extent extent) { + public Fast2DIterator(@Nonnull Iterable iter, @Nullable Extent extent) { this(iter, (HasFaweQueue) (extent != null ? (extent instanceof HasFaweQueue ? extent : new ExtentTraverser(extent).findAndGet(HasFaweQueue.class)) : null)); } - public Fast2DIterator(@Nonnull Iterable iter, @Nullable HasFaweQueue editSession) { + public Fast2DIterator(@Nonnull Iterable iter, @Nullable HasFaweQueue editSession) { this(iter, (FaweQueue) (editSession != null ? editSession.getQueue() : null)); } - public Fast2DIterator(@Nonnull Iterable iter, @Nullable FaweQueue faweQueue) { + public Fast2DIterator(@Nonnull Iterable iter, @Nullable FaweQueue faweQueue) { this.iterable = iter; this.queue = faweQueue != null && faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null; } - public Iterable getIterable() { + public Iterable getIterable() { return iterable; } @Override - public Iterator iterator() { + public Iterator iterator() { if (queue == null || Settings.IMP.QUEUE.PRELOAD_CHUNKS <= 1) { - return (Iterator) iterable.iterator(); + return (Iterator) iterable.iterator(); } - return new Iterator() { - Iterator trailIter = iterable.iterator(); - Iterator leadIter = iterable.iterator(); + return new Iterator() { + Iterator trailIter = iterable.iterator(); + Iterator leadIter = iterable.iterator(); int lastTrailChunkX = Integer.MIN_VALUE; int lastTrailChunkZ = Integer.MIN_VALUE; int lastLeadChunkX = Integer.MIN_VALUE; @@ -64,8 +65,8 @@ public class Fast2DIterator implements Iterable { } @Override - public Vector2D next() { - Vector2D pt = trailIter.next(); + public BlockVector2 next() { + BlockVector2 pt = trailIter.next(); if (lastTrailChunkX != (lastTrailChunkX = pt.getBlockX() >> 4) || lastTrailChunkZ != (lastTrailChunkZ = pt.getBlockZ() >> 4)) { if (leadIter.hasNext()) { try { @@ -78,7 +79,7 @@ public class Fast2DIterator implements Iterable { amount = 1; } for (int count = 0; count < amount; ) { - Vector2D v = leadIter.next(); + BlockVector2 v = leadIter.next(); int vcx = v.getBlockX() >> 4; int vcz = v.getBlockZ() >> 4; if (vcx != lastLeadChunkX || vcz != lastLeadChunkZ) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/FastChunkIterator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/FastChunkIterator.java index 7149fd563..44c241f87 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/FastChunkIterator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/FastChunkIterator.java @@ -6,54 +6,55 @@ import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.util.ExtentTraverser; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector2; + import java.util.Iterator; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class FastChunkIterator implements Iterable { +public class FastChunkIterator implements Iterable { - private final Iterable iterable; + private final Iterable iterable; private final MappedFaweQueue queue; - public FastChunkIterator(@Nonnull Iterable iter, @Nullable EditSession extent) { + public FastChunkIterator(@Nonnull Iterable iter, @Nullable EditSession extent) { this(iter, (HasFaweQueue) extent); } - public FastChunkIterator(@Nonnull Iterable iter, @Nullable Extent extent) { + public FastChunkIterator(@Nonnull Iterable iter, @Nullable Extent extent) { this(iter, (HasFaweQueue) (extent != null ? (extent instanceof HasFaweQueue ? extent : new ExtentTraverser(extent).findAndGet(HasFaweQueue.class)) : null)); } - public FastChunkIterator(@Nonnull Iterable iter, @Nullable HasFaweQueue editSession) { + public FastChunkIterator(@Nonnull Iterable iter, @Nullable HasFaweQueue editSession) { this(iter, (FaweQueue) (editSession != null ? editSession.getQueue() : null)); } - public FastChunkIterator(@Nonnull Iterable iter, @Nullable FaweQueue faweQueue) { + public FastChunkIterator(@Nonnull Iterable iter, @Nullable FaweQueue faweQueue) { this.iterable = iter; this.queue = faweQueue != null && faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null; } - public Iterable getIterable() { + public Iterable getIterable() { return iterable; } @Override - public Iterator iterator() { + public Iterator iterator() { if (queue == null || Settings.IMP.QUEUE.PRELOAD_CHUNKS <= 1) { - return (Iterator) iterable.iterator(); + return (Iterator) iterable.iterator(); } - final Iterator trailIter = iterable.iterator(); - final Iterator leadIter = iterable.iterator(); + final Iterator trailIter = iterable.iterator(); + final Iterator leadIter = iterable.iterator(); int amount = Settings.IMP.QUEUE.PRELOAD_CHUNKS; for (int i = 0; i < Settings.IMP.QUEUE.PRELOAD_CHUNKS && leadIter.hasNext(); i++) { - Vector2D toLoad = leadIter.next(); + BlockVector2 toLoad = leadIter.next(); queue.queueChunkLoad(toLoad.getBlockX(), toLoad.getBlockZ()); } if (!leadIter.hasNext()) { - return (Iterator) trailIter; + return (Iterator) trailIter; } - return new Iterator() { + return new Iterator() { @Override public void remove() { trailIter.remove(); @@ -65,9 +66,9 @@ public class FastChunkIterator implements Iterable { } @Override - public Vector2D next() { + public BlockVector2 next() { if (leadIter.hasNext()) { - Vector2D toLoad = leadIter.next(); + BlockVector2 toLoad = leadIter.next(); queue.queueChunkLoad(toLoad.getBlockX(), toLoad.getBlockZ()); } return trailIter.next(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/FastIterator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/FastIterator.java index e4d5e2d82..ee936f88d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/FastIterator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/FastIterator.java @@ -6,46 +6,47 @@ import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.util.ExtentTraverser; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; + import java.util.Iterator; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class FastIterator implements Iterable { +public class FastIterator implements Iterable { - private final Iterable iterable; + private final Iterable iterable; private final MappedFaweQueue queue; - public FastIterator(@Nonnull Iterable iter, @Nullable EditSession extent) { + public FastIterator(@Nonnull Iterable iter, @Nullable EditSession extent) { this(iter, (HasFaweQueue) extent); } - public FastIterator(@Nonnull Iterable iter, @Nullable Extent extent) { + public FastIterator(@Nonnull Iterable iter, @Nullable Extent extent) { this(iter, (HasFaweQueue) (extent != null ? (extent instanceof HasFaweQueue ? extent : new ExtentTraverser(extent).findAndGet(HasFaweQueue.class)) : null)); } - public FastIterator(@Nonnull Iterable iter, @Nullable HasFaweQueue editSession) { + public FastIterator(@Nonnull Iterable iter, @Nullable HasFaweQueue editSession) { this(iter, (FaweQueue) (editSession != null ? editSession.getQueue() : null)); } - public FastIterator(@Nonnull Iterable iter, @Nullable FaweQueue faweQueue) { + public FastIterator(@Nonnull Iterable iter, @Nullable FaweQueue faweQueue) { this.iterable = iter; this.queue = faweQueue != null && faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null; } - public Iterable getIterable() { + public Iterable getIterable() { return iterable; } @Override - public Iterator iterator() { + public Iterator iterator() { if (queue == null || Settings.IMP.QUEUE.PRELOAD_CHUNKS <= 1) { - return (Iterator) iterable.iterator(); + return (Iterator) iterable.iterator(); } - return new Iterator() { - Iterator trailIter = iterable.iterator(); - Iterator leadIter = iterable.iterator(); + return new Iterator() { + Iterator trailIter = iterable.iterator(); + Iterator leadIter = iterable.iterator(); int lastTrailChunkX = Integer.MIN_VALUE; int lastTrailChunkZ = Integer.MIN_VALUE; int lastLeadChunkX = Integer.MIN_VALUE; @@ -64,8 +65,8 @@ public class FastIterator implements Iterable { } @Override - public Vector next() { - Vector pt = trailIter.next(); + public BlockVector3 next() { + BlockVector3 pt = trailIter.next(); if (lastTrailChunkX != (lastTrailChunkX = pt.getBlockX() >> 4) || lastTrailChunkZ != (lastTrailChunkZ = pt.getBlockZ() >> 4)) { if (leadIter.hasNext()) { try { @@ -78,7 +79,7 @@ public class FastIterator implements Iterable { amount = 1; } for (int count = 0; count < amount; ) { - Vector v = leadIter.next(); + BlockVector3 v = leadIter.next(); int vcx = v.getBlockX() >> 4; int vcz = v.getBlockZ() >> 4; if (vcx != lastLeadChunkX || vcz != lastLeadChunkZ) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/SimpleRegion.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/SimpleRegion.java index f01b054bb..6879154db 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/SimpleRegion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/SimpleRegion.java @@ -1,42 +1,42 @@ package com.boydti.fawe.regions; -import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.world.World; public abstract class SimpleRegion extends AbstractRegion { - private final Vector max; - private final Vector min; + private final BlockVector3 max; + private final BlockVector3 min; - public SimpleRegion(World world, Vector min, Vector max) { + public SimpleRegion(World world, BlockVector3 min, BlockVector3 max) { super(world); this.min = min; this.max = max; } @Override - public Vector getMinimumPoint() { + public BlockVector3 getMinimumPoint() { return min; } @Override - public Vector getMaximumPoint() { + public BlockVector3 getMaximumPoint() { return max; } @Override - public void expand(Vector... changes) throws RegionOperationException { + public void expand(BlockVector3... changes) throws RegionOperationException { throw new UnsupportedOperationException("Region is immutable"); } @Override - public void contract(Vector... changes) throws RegionOperationException { + public void contract(BlockVector3... changes) throws RegionOperationException { throw new UnsupportedOperationException("Region is immutable"); } @Override - public boolean contains(Vector p) { + public boolean contains(BlockVector3 p) { return contains(p.getBlockX(), p.getBlockY(), p.getBlockZ()); } 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 f1fe00c9a..2234b919f 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 @@ -8,9 +8,9 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.ChunkManager; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; @@ -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 Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ())); - CuboidRegion regionB = new CuboidRegion(new Vector(pos3.getX(), pos3.getY(), pos3.getZ()), new Vector(pos4.getX(), pos4.getY(), pos4.getZ())); + 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())); 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 Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ())); - ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, new Vector(pos3.getX(), pos3.getY(), pos3.getZ())); + 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())); 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 Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ())); + CuboidRegion region = new CuboidRegion(new BlockVector3(pos1.getX(), pos1.getY(), pos1.getZ()), new BlockVector3(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 e5e59f484..4b8cb8a34 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 @@ -18,9 +18,9 @@ import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.block.LocalBlockQueue; import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import java.io.File; import java.io.FileNotFoundException; @@ -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 Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ())); + final CuboidRegion region = new CuboidRegion(new BlockVector3(pos1.getX(), pos1.getY(), pos1.getZ()), new BlockVector3(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 e32e4a856..526a0c9ea 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 @@ -4,7 +4,8 @@ import com.boydti.fawe.regions.general.CuboidRegionFilter; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotArea; -import com.sk89q.worldedit.BlockVector2D; +import com.sk89q.worldedit.math.BlockVector2; + import java.util.ArrayList; @@ -23,7 +24,7 @@ public class PlotRegionFilter extends CuboidRegionFilter { for (Plot plot : plots) { Location pos1 = plot.getBottom(); Location pos2 = plot.getTop(); - add(new BlockVector2D(pos1.getX(), pos1.getZ()), new BlockVector2D(pos2.getX(), pos2.getZ())); + add(new BlockVector2(pos1.getX(), pos1.getZ()), new BlockVector2(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 2d016eed3..4ea875da8 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 @@ -21,9 +21,9 @@ import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.CommandDeclaration; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Capability; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.Biomes; @@ -84,7 +84,7 @@ public class PlotSetBiome extends Command { .build(); long seed = PseudoRandom.random.nextLong(); for (RegionWrapper region : regions) { - CuboidRegion cuboid = new CuboidRegion(new Vector(region.minX, 0, region.minZ), new Vector(region.maxX, 256, region.maxZ)); + CuboidRegion cuboid = new CuboidRegion(new BlockVector3(region.minX, 0, region.minZ), new BlockVector3(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 d313d4f19..169440aab 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 @@ -23,7 +23,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; import com.intellectualcrafters.plot.util.block.QueueProvider; import com.plotsquared.listener.WEManager; -import com.sk89q.worldedit.BlockVector; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import java.util.HashSet; @@ -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 BlockVector pos1 = new BlockVector(region.minX, min, region.minZ); - final BlockVector pos2 = new BlockVector(region.maxX, max, region.maxZ); + final BlockVector3 pos1 = new BlockVector3(region.minX, min, region.minZ); + final BlockVector3 pos2 = new BlockVector3(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/util/TextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java index 8aa1fd03b..044beeb4e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java @@ -8,7 +8,6 @@ import com.boydti.fawe.util.image.ImageUtil; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockMaterial; import com.sk89q.worldedit.util.command.binding.Text; @@ -16,6 +15,7 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.BlockPattern; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -42,7 +42,7 @@ public class TextureUtil implements TextureHolder{ public static TextureUtil fromClipboard(Clipboard clipboard) throws FileNotFoundException { boolean[] ids = new boolean[BlockTypes.size()]; - for (com.sk89q.worldedit.Vector pt : clipboard.getRegion()) { + for (BlockVector3 pt : clipboard.getRegion()) { ids[clipboard.getBlock(pt).getInternalBlockTypeId()] = true; } HashSet blocks = new HashSet<>(); @@ -65,7 +65,7 @@ public class TextureUtil implements TextureHolder{ for (int typeId : tu.getValidBlockIds()) { BlockType block = BlockTypes.get(typeId); pattern.setBlock(block.getDefaultState()); - if (mask.test(Vector.ZERO)) blocks.add(block); + if (mask.test(BlockVector3.ZERO)) blocks.add(block); } return fromBlocks(blocks); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java index bbe9a1dbc..ef0f5fc33 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java @@ -9,10 +9,10 @@ import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.extent.NullExtent; import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMaskManager; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import java.lang.reflect.Field; import java.util.*; @@ -160,10 +160,10 @@ public class WEManager { public boolean intersects(final Region region1, final Region region2) { - Vector rg1P1 = region1.getMinimumPoint(); - Vector rg1P2 = region1.getMaximumPoint(); - Vector rg2P1 = region2.getMinimumPoint(); - Vector rg2P2 = region2.getMaximumPoint(); + BlockVector3 rg1P1 = region1.getMinimumPoint(); + BlockVector3 rg1P2 = region1.getMaximumPoint(); + BlockVector3 rg2P1 = region2.getMinimumPoint(); + BlockVector3 rg2P2 = region2.getMaximumPoint(); return (rg1P1.getBlockX() <= rg2P2.getBlockX()) && (rg1P2.getBlockX() >= rg2P1.getBlockX()) && (rg1P1.getBlockZ() <= rg2P2.getBlockZ()) && (rg1P2.getBlockZ() >= rg2P1.getBlockZ()); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java index d952f8521..ecaf2d3a3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java @@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.object.FaweLocation; import com.boydti.fawe.object.FawePlayer; import com.google.common.base.Charsets; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -15,6 +14,8 @@ import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.extension.platform.*; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.inventory.BlockBag; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; @@ -166,11 +167,12 @@ public class FakePlayer extends AbstractPlayerActor { } @Override - public void setPosition(Vector pos, float pitch, float yaw) { - if (pos instanceof Location) { - Extent extent = ((Location) pos).getExtent(); - if (extent instanceof World) this.world = (World) extent; - } + public void setPosition(Vector3 pos, float pitch, float yaw) { + //TODO: find replacement for following code +// if (pos instanceof Location) { +// Extent extent = ((Location) pos).getExtent(); +// if (extent instanceof World) this.world = (World) extent; +// } this.pos = new Location(world, pos, yaw, pitch); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/LocationMaskedPlayerWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/LocationMaskedPlayerWrapper.java index 412fd3daa..9bb2e0781 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/LocationMaskedPlayerWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/LocationMaskedPlayerWrapper.java @@ -1,7 +1,7 @@ package com.boydti.fawe.wrappers; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; public class LocationMaskedPlayerWrapper extends PlayerWrapper { @@ -32,7 +32,7 @@ public class LocationMaskedPlayerWrapper extends PlayerWrapper { } @Override - public void setPosition(Vector pos, float pitch, float yaw) { + public void setPosition(Vector3 pos, float pitch, float yaw) { this.position = new Location(position.getExtent(), pos, pitch, yaw); if (allowTeleport) { super.setPosition(pos, pitch, yaw); 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 a5ec89f5f..5667cb24a 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 @@ -16,6 +16,8 @@ import com.sk89q.worldedit.extension.platform.AbstractPlayerActor; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.internal.cui.CUIEvent; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; @@ -90,7 +92,7 @@ public class PlayerWrapper extends AbstractPlayerActor { } @Override - public void setPosition(Vector pos, float pitch, float yaw) { + public void setPosition(Vector3 pos, float pitch, float yaw) { parent.setPosition(pos, pitch, yaw); } @@ -233,13 +235,13 @@ public class PlayerWrapper extends AbstractPlayerActor { Extent world = getLocation().getExtent(); // No free space above - if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isAir()) { + if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir()) { return false; } while (y <= world.getMaximumPoint().getY()) { // Found a ceiling! - if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { int platformY = Math.max(initialY, y - 3 - clearance); floatAt(x, platformY + 1, z, alwaysGlass); return true; @@ -267,7 +269,7 @@ public class PlayerWrapper extends AbstractPlayerActor { final Extent world = getLocation().getExtent(); while (y <= world.getMaximumPoint().getY() + 2) { - if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { break; // Hit something } else if (y > maxY + 1) { break; @@ -287,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 Vector(x, y - 1, z), BlockTypes.GLASS); + edit.setBlock(new BlockVector3(x, y - 1, z), BlockTypes.GLASS); edit.flushQueue(); LocalSession session = Fawe.get().getWorldEdit().getSessionManager().get(this); if (session != null) { @@ -299,7 +301,7 @@ public class PlayerWrapper extends AbstractPlayerActor { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { - setPosition(new Vector(x + 0.5, y, z + 0.5)); + setPosition(new Vector3(x + 0.5, y, z + 0.5)); } }); if (caught != null) { @@ -359,7 +361,7 @@ public class PlayerWrapper extends AbstractPlayerActor { boolean inFree = false; while ((block = hitBlox.getNextBlock()) != null) { - boolean free = !world.getBlock(block.toVector()).getBlockType().getMaterial().isMovementBlocker(); + boolean free = !world.getBlock(new BlockVector3(block.getBlockX(), block.getBlockY(), block.getBlockZ())).getBlockType().getMaterial().isMovementBlocker(); if (firstBlock) { firstBlock = false; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java index e22970871..8559998ff 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java @@ -10,6 +10,9 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; @@ -59,12 +62,12 @@ public class WorldWrapper extends AbstractWorld { } @Override - public boolean useItem(Vector position, BaseItem item, Direction face) { + public boolean useItem(BlockVector3 position, BaseItem item, Direction face) { return parent.useItem(position, item, face); } @Override - public boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException { + public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException { return parent.setBlock(position, block, notifyAndLight); } @@ -79,12 +82,12 @@ public class WorldWrapper extends AbstractWorld { } @Override - public void dropItem(Vector pt, BaseItemStack item, int times) { + public void dropItem(Vector3 pt, BaseItemStack item, int times) { parent.dropItem(pt, item, times); } @Override - public void simulateBlockMine(final Vector pt) { + public void simulateBlockMine(final BlockVector3 pt) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { @@ -94,7 +97,7 @@ public class WorldWrapper extends AbstractWorld { } @Override - public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException { + public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException { return TaskManager.IMP.sync((Supplier) () -> { try { return parent.generateTree(type, editSession, position); @@ -105,27 +108,27 @@ public class WorldWrapper extends AbstractWorld { } @Override - public void checkLoadedChunk(Vector pt) { + public void checkLoadedChunk(BlockVector3 pt) { parent.checkLoadedChunk(pt); } @Override - public void fixAfterFastMode(Iterable chunks) { + public void fixAfterFastMode(Iterable chunks) { parent.fixAfterFastMode(chunks); } @Override - public void fixLighting(Iterable chunks) { + public void fixLighting(Iterable chunks) { parent.fixLighting(chunks); } @Override - public boolean playEffect(Vector position, int type, int data) { + public boolean playEffect(Vector3 position, int type, int data) { return parent.playEffect(position, type, data); } @Override - public boolean queueBlockBreakEffect(Platform server, Vector position, BlockType blockType, double priority) { + public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) { return parent.queueBlockBreakEffect(server, position, blockType, priority); } @@ -150,12 +153,12 @@ public class WorldWrapper extends AbstractWorld { } @Override - public Vector getMinimumPoint() { + public BlockVector3 getMinimumPoint() { return parent.getMinimumPoint(); } @Override - public Vector getMaximumPoint() { + public BlockVector3 getMaximumPoint() { return parent.getMaximumPoint(); } @@ -171,17 +174,17 @@ public class WorldWrapper extends AbstractWorld { } @Override - public int getBlockLightLevel(Vector position) { + public int getBlockLightLevel(BlockVector3 position) { return parent.getBlockLightLevel(position); } @Override - public boolean clearContainerBlockContents(Vector position) { + public boolean clearContainerBlockContents(BlockVector3 position) { return parent.clearContainerBlockContents(position); } @Override - public void dropItem(Vector position, BaseItemStack item) { + public void dropItem(Vector3 position, BaseItemStack item) { parent.dropItem(position, item); } @@ -227,27 +230,27 @@ public class WorldWrapper extends AbstractWorld { } @Override - public BlockState getBlock(Vector position) { + public BlockState getBlock(BlockVector3 position) { return parent.getBlock(position); } @Override - public BlockState getLazyBlock(Vector position) { + public BlockState getLazyBlock(BlockVector3 position) { return parent.getLazyBlock(position); } @Override - public BlockState getFullBlock(Vector position) { + public BlockState getFullBlock(BlockVector3 position) { return parent.getFullBlock(position); } @Override - public BaseBiome getBiome(Vector2D position) { + public BaseBiome getBiome(BlockVector2 position) { return parent.getBiome(position); } @Override - public boolean setBiome(Vector2D position, BaseBiome biome) { + public boolean setBiome(BlockVector2 position, BaseBiome biome) { return parent.setBiome(position, biome); } } 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 930f0763a..7ff06c9b4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java @@ -31,6 +31,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; @@ -85,18 +86,18 @@ public class CuboidClipboard { private BlockArrayClipboard clipboard; private AffineTransform transform; - public Vector size; + public BlockVector3 size; /** * Constructs the clipboard. * * @param size the dimensions of the clipboard (should be at least 1 on every dimension) */ - public CuboidClipboard(Vector size) { + public CuboidClipboard(BlockVector3 size) { checkNotNull(size); MainUtil.warnDeprecated(BlockArrayClipboard.class, ClipboardFormat.class); this.size = size; - this.clipboard = this.init(Vector.ZERO, Vector.ZERO); + this.clipboard = this.init(BlockVector3.ZERO, BlockVector3.ZERO); } public CuboidClipboard(BlockArrayClipboard clipboard) { @@ -111,12 +112,12 @@ public class CuboidClipboard { * @param origin the origin point where the copy was made, which must be the * {@link CuboidRegion#getMinimumPoint()} relative to the copy */ - public CuboidClipboard(Vector size, Vector origin) { + public CuboidClipboard(BlockVector3 size, BlockVector3 origin) { checkNotNull(size); checkNotNull(origin); MainUtil.warnDeprecated(BlockArrayClipboard.class, ClipboardFormat.class); this.size = size; - this.clipboard = init(Vector.ZERO, origin); + this.clipboard = init(BlockVector3.ZERO, origin); } /** @@ -127,7 +128,7 @@ public class CuboidClipboard { * {@link CuboidRegion#getMinimumPoint()} relative to the copy * @param offset the offset from the minimum point of the copy where the user was */ - public CuboidClipboard(Vector size, Vector origin, Vector offset) { + public CuboidClipboard(BlockVector3 size, BlockVector3 origin, BlockVector3 offset) { checkNotNull(size); checkNotNull(origin); checkNotNull(offset); @@ -138,9 +139,9 @@ public class CuboidClipboard { /* ------------------------------------------------------------------------------------------------------------- */ - private BlockArrayClipboard init(Vector offset, Vector min) { - Vector origin = min.subtract(offset); - CuboidRegion region = new CuboidRegion(min, min.add(size).subtract(Vector.ONE)); + private BlockArrayClipboard init(BlockVector3 offset, BlockVector3 min) { + BlockVector3 origin = min.subtract(offset); + CuboidRegion region = new CuboidRegion(min, min.add(size).subtract(BlockVector3.ONE)); BlockArrayClipboard clipboard = new BlockArrayClipboard(region); clipboard.setOrigin(origin); return clipboard; @@ -153,7 +154,7 @@ public class CuboidClipboard { /* ------------------------------------------------------------------------------------------------------------- */ - public BaseBlock getBlock(Vector position) { + public BaseBlock getBlock(BlockVector3 position) { return getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ()); } @@ -162,11 +163,11 @@ public class CuboidClipboard { return adapt(clipboard.IMP.getBlock(x, y, z)); } - public BaseBlock getLazyBlock(Vector position) { + public BaseBlock getLazyBlock(BlockVector3 position) { return getBlock(position); } - public void setBlock(Vector location, BaseBlock block) { + public void setBlock(BlockVector3 location, BaseBlock block) { setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block); } @@ -235,7 +236,7 @@ public class CuboidClipboard { public void flip(FlipDirection dir, boolean aroundPlayer) { checkNotNull(dir); Direction direction = dir.direction; - AffineTransform newTransform = new AffineTransform().scale(direction.toVector().positive().multiply(-2).add(1, 1, 1)); + AffineTransform newTransform = new AffineTransform().scale(direction.toVector().abs().multiply(-2).add(1, 1, 1)); this.transform = transform == null ? newTransform : newTransform.combine(transform); } @@ -248,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 Vector(x, y, z).add(getOrigin()))); + setBlock(x, y, z, editSession.getBlock(new BlockVector3(x, y, z).add(getOrigin()))); } } } @@ -264,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 Vector pt = new Vector(x, y, z).add(getOrigin()); + final BlockVector3 pt = new BlockVector3(x, y, z).add(getOrigin()); if (region.contains(pt)) { setBlock(x, y, z, editSession.getBlock(pt)); } else { @@ -288,7 +289,7 @@ public class CuboidClipboard { * @param noAir true to not copy air blocks in the source * @throws MaxChangedBlocksException thrown if too many blocks were changed */ - public void paste(EditSession editSession, Vector newOrigin, boolean noAir) throws MaxChangedBlocksException { + public void paste(EditSession editSession, BlockVector3 newOrigin, boolean noAir) throws MaxChangedBlocksException { paste(editSession, newOrigin, noAir, false); } @@ -306,7 +307,7 @@ public class CuboidClipboard { * @param entities true to copy entities * @throws MaxChangedBlocksException thrown if too many blocks were changed */ - public void paste(EditSession editSession, Vector newOrigin, boolean noAir, boolean entities) throws MaxChangedBlocksException { + public void paste(EditSession editSession, BlockVector3 newOrigin, boolean noAir, boolean entities) throws MaxChangedBlocksException { new Schematic(clipboard).paste(editSession, newOrigin, false, !noAir, entities, transform); editSession.flushQueue(); } @@ -324,7 +325,7 @@ public class CuboidClipboard { * @param noAir true to not copy air blocks in the source * @throws MaxChangedBlocksException thrown if too many blocks were changed */ - public void place(EditSession editSession, Vector newOrigin, boolean noAir) throws MaxChangedBlocksException { + public void place(EditSession editSession, BlockVector3 newOrigin, boolean noAir) throws MaxChangedBlocksException { paste(editSession, newOrigin, noAir, false); } @@ -339,7 +340,7 @@ public class CuboidClipboard { * @deprecated use {@link #getBlock(Vector)} instead */ @Deprecated - public BaseBlock getPoint(Vector position) throws ArrayIndexOutOfBoundsException { + public BaseBlock getPoint(BlockVector3 position) throws ArrayIndexOutOfBoundsException { final BaseBlock block = getBlock(position); if (block == null) { return new BaseBlock(BlockTypes.AIR); @@ -355,7 +356,7 @@ public class CuboidClipboard { * * @return the origin */ - public Vector getOrigin() { + public BlockVector3 getOrigin() { return clipboard.getMinimumPoint(); } @@ -366,14 +367,14 @@ public class CuboidClipboard { * * @param origin the origin to set */ - public void setOrigin(Vector origin) { + public void setOrigin(BlockVector3 origin) { checkNotNull(origin); setOriginAndOffset(getOffset(), origin); } - public void setOriginAndOffset(Vector offset, Vector min) { - Vector origin = min.subtract(offset); - CuboidRegion region = new CuboidRegion(min, min.add(size).subtract(Vector.ONE)); + public void setOriginAndOffset(BlockVector3 offset, BlockVector3 min) { + BlockVector3 origin = min.subtract(offset); + CuboidRegion region = new CuboidRegion(min, min.add(size).subtract(BlockVector3.ONE)); clipboard.setRegion(region); clipboard.setOrigin(origin); } @@ -386,10 +387,10 @@ public class CuboidClipboard { * * @return the offset the offset */ - public Vector getOffset() { - Vector min = clipboard.getMinimumPoint(); - Vector origin = clipboard.getOrigin(); - Vector offset = min.subtract(origin); + public BlockVector3 getOffset() { + BlockVector3 min = clipboard.getMinimumPoint(); + BlockVector3 origin = clipboard.getOrigin(); + BlockVector3 offset = min.subtract(origin); return offset; } @@ -401,7 +402,7 @@ public class CuboidClipboard { * * @param offset the new offset */ - public void setOffset(Vector offset) { + public void setOffset(BlockVector3 offset) { checkNotNull(offset); setOriginAndOffset(offset, getOrigin()); } @@ -411,7 +412,7 @@ public class CuboidClipboard { * * @return the dimensions, where (1, 1, 1) is 1 wide, 1 across, 1 deep */ - public Vector getSize() { + public BlockVector3 getSize() { return size; } @@ -448,7 +449,7 @@ public class CuboidClipboard { @Deprecated public static CuboidClipboard loadSchematic(File path) throws DataException, IOException { checkNotNull(path); - return new CuboidClipboard((Vector) ClipboardFormat.SCHEMATIC.load(path).getClipboard()); + return new CuboidClipboard((BlockVector3) ClipboardFormat.SCHEMATIC.load(path).getClipboard()); } /** 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 71856a092..0b7d1d7b9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -72,6 +72,7 @@ import com.sk89q.worldedit.function.block.Naturalizer; import com.sk89q.worldedit.function.generator.GardenPatchGenerator; import com.sk89q.worldedit.function.operation.ChangeSetExecutor; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; +import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; @@ -1085,8 +1086,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, public boolean setBlock(int x, int y, int z, Pattern pattern) { this.changes++; try { - mutablebv.setComponents(x, y, z); - return pattern.apply(extent, mutablebv, mutablebv); + BlockVector3 bv = mutablebv.setComponents(x, y, z).toBlockVector3(); + return pattern.apply(extent, bv, bv); } catch (WorldEditException e) { throw new RuntimeException("Unexpected exception", e); } @@ -2225,10 +2226,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } for (int y = 0; y < height; ++y) { - this.setBlock(mutable.setComponents(px + x, py + y, pz + z), block); - this.setBlock(mutable.setComponents(px - x, py + y, pz + z), block); - this.setBlock(mutable.setComponents(px + x, py + y, pz - z), block); - this.setBlock(mutable.setComponents(px - x, py + y, pz - z), block); + this.setBlock(mutable.setComponents(px + x, py + y, pz + z).toBlockVector3(), block); + this.setBlock(mutable.setComponents(px - x, py + y, pz + z).toBlockVector3(), block); + this.setBlock(mutable.setComponents(px + x, py + y, pz - z).toBlockVector3(), block); + this.setBlock(mutable.setComponents(px - x, py + y, pz - z).toBlockVector3(), block); } } } @@ -2259,10 +2260,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } for (int y = 0; y < height; ++y) { - this.setBlock(mutable.setComponents(px + x, py + y, pz + z), block); - this.setBlock(mutable.setComponents(px - x, py + y, pz + z), block); - this.setBlock(mutable.setComponents(px + x, py + y, pz - z), block); - this.setBlock(mutable.setComponents(px - x, py + y, pz - z), block); + this.setBlock(mutable.setComponents(px + x, py + y, pz + z).toBlockVector3(), block); + this.setBlock(mutable.setComponents(px - x, py + y, pz + z).toBlockVector3(), block); + this.setBlock(mutable.setComponents(px + x, py + y, pz - z).toBlockVector3(), block); + this.setBlock(mutable.setComponents(px - x, py + y, pz - z).toBlockVector3(), block); } } } @@ -2336,21 +2337,21 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } if (Math.abs((x) * nx + (y) * ny + (z) * nz) < threshold) - setBlock(mutable.setComponents(px + x, py + y, pz + z), block); + setBlock(mutable.setComponents(px + x, py + y, pz + z).toBlockVector3(), block); if (Math.abs((-x) * nx + (y) * ny + (z) * nz) < threshold) - setBlock(mutable.setComponents(px - x, py + y, pz + z), block); + setBlock(mutable.setComponents(px - x, py + y, pz + z).toBlockVector3(), block); if (Math.abs((x) * nx + (-y) * ny + (z) * nz) < threshold) - setBlock(mutable.setComponents(px + x, py - y, pz + z), block); + setBlock(mutable.setComponents(px + x, py - y, pz + z).toBlockVector3(), block); if (Math.abs((x) * nx + (y) * ny + (-z) * nz) < threshold) - setBlock(mutable.setComponents(px + x, py + y, pz - z), block); + setBlock(mutable.setComponents(px + x, py + y, pz - z).toBlockVector3(), block); if (Math.abs((-x) * nx + (-y) * ny + (z) * nz) < threshold) - setBlock(mutable.setComponents(px - x, py - y, pz + z), block); + setBlock(mutable.setComponents(px - x, py - y, pz + z).toBlockVector3(), block); if (Math.abs((x) * nx + (-y) * ny + (-z) * nz) < threshold) - setBlock(mutable.setComponents(px + x, py - y, pz - z), block); + setBlock(mutable.setComponents(px + x, py - y, pz - z).toBlockVector3(), block); if (Math.abs((-x) * nx + (y) * ny + (-z) * nz) < threshold) - setBlock(mutable.setComponents(px - x, py + y, pz - z), block); + setBlock(mutable.setComponents(px - x, py + y, pz - z).toBlockVector3(), block); if (Math.abs((-x) * nx + (-y) * ny + (-z) * nz) < threshold) - setBlock(mutable.setComponents(px - x, py - y, pz - z), block); + setBlock(mutable.setComponents(px - x, py - y, pz - z).toBlockVector3(), block); } } } @@ -2956,9 +2957,9 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, @Override public BlockStateHolder getMaterial(final int x, final int y, final int z, final BlockStateHolder defaultMaterial) { //TODO Optimize - avoid vector creation (math) - final Vector3 current = mutablev.setComponents(x, y, z); +// 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 = new Vector3(x, y, z); environment.setCurrentBlock(current); final Vector3 scaled = current.subtract(zero).divide(unit); @@ -3472,14 +3473,17 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, boolean containsAny = false; if (cuboid && containsBot1 && containsBot2 && containsTop1 && containsTop2 && conNextX && conNextZ) { containsAny = true; + BlockVector3 mbv = mutable.toBlockVector3(); if (fcs != null) { for (int x = 0; x < 16; x++) { int xx = x + bx; for (int z = 0; z < 16; z++) { int zz = z + bz; for (int y = 0; y < getMaxY() + 1; y++) { - BlockStateHolder block = getFullBlock(mutable.setComponents(xx, y, zz)); - fcs.add(mutable, block, BlockTypes.AIR.getDefaultState()); +// BlockStateHolder block = getFullBlock(mutable.setComponents(xx, y, zz)); + BlockVector3 bv = new BlockVector3(xx, y, zz); + BlockStateHolder block = getFullBlock(bv); + fcs.add(mbv, block, BlockTypes.AIR.getDefaultState()); } } } @@ -3502,17 +3506,18 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, mutable.mutZ(zz); for (int y = 0; y < getMaxY() + 1; y++) { mutable.mutY(y); - boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mutable); + BlockVector3 mbv = new BlockVector3(xx, y, zz); + boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mbv); if (contains) { containsAny = true; if (fcs != null) { - BlockStateHolder block = getFullBlock(mutable.setComponents(xx, y, zz)); - fcs.add(mutable, block, BlockTypes.AIR.getDefaultState()); + BlockStateHolder block = getFullBlock(mbv); + fcs.add(mbv, block, BlockTypes.AIR.getDefaultState()); } } else { - BlockStateHolder block = getFullBlock(mutable.setComponents(xx, y, zz)); + BlockStateHolder block = getFullBlock(mbv); try { - setBlock(mutable, block); + setBlock(mbv, block); } catch (MaxChangedBlocksException e) { throw new RuntimeException(e); } @@ -3602,5 +3607,4 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, return false; } - } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index 288e49995..17b130f71 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -71,6 +71,7 @@ public abstract class LocalConfiguration { public int butcherDefaultRadius = -1; public int butcherMaxRadius = -1; public boolean allowSymlinks = false; + public boolean serverSideCUI = true; /** * Load the configuration. 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 a1292f9e2..b80c5a261 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -40,6 +40,8 @@ import com.sk89q.jchronic.Chronic; import com.sk89q.jchronic.Options; import com.sk89q.jchronic.utils.Span; import com.sk89q.jchronic.utils.Time; +import com.sk89q.jnbt.IntTag; +import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BaseItem; @@ -140,6 +142,7 @@ public class LocalSession implements TextureHolder { // Saved properties private String lastScript; private RegionSelectorType defaultSelector; + private boolean useServerCUI = false; // Save this to not annoy players. /** * Construct the object. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java index 9d2644734..e6e3e0dc7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java @@ -22,6 +22,8 @@ package com.sk89q.worldedit.blocks; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -208,4 +210,5 @@ public class BaseBlock extends BlockState { return getAsString(); } } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java index d7411fe79..cee597288 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java @@ -42,12 +42,9 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.visitor.FlatRegionVisitor; -<<<<<<< HEAD import com.sk89q.worldedit.function.visitor.RegionVisitor; -======= import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.FlatRegion; import com.sk89q.worldedit.regions.Region; @@ -153,54 +150,32 @@ public class BiomeCommands extends MethodCommands { return; } -<<<<<<< HEAD - BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toVector2D()); - biomes[biome.getId()]++; - size = 1; - } else if (args.hasFlag('p')) { - BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toVector2D()); - biomes[biome.getId()]++; - size = 1; -======= BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2()); - biomes.add(biome); - - qualifier = "at line of sight point"; + biomes[biome.getId()]++; + size = 1; } else if (args.hasFlag('p')) { BaseBiome biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2()); - biomes.add(biome); - - qualifier = "at your position"; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + biomes[biome.getId()]++; + size = 1; } else { World world = player.getWorld(); Region region = session.getSelection(world); if (region instanceof FlatRegion) { -<<<<<<< HEAD - for (Vector2D pt : new Fast2DIterator(((FlatRegion) region).asFlatRegion(), editSession)) { + for (BlockVector2 pt : new Fast2DIterator(((FlatRegion) region).asFlatRegion(), editSession)) { biomes[editSession.getBiome(pt).getId()]++; size++; } } else { RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() { @Override - public boolean apply(Vector position) throws WorldEditException { - biomes[editSession.getBiome(position.toVector2D()).getId()]++; + public boolean apply(BlockVector3 position) throws WorldEditException { + biomes[editSession.getBiome(position.toBlockVector2()).getId()]++; return true; } }, editSession); Operations.completeBlindly(visitor); size += visitor.getAffected(); -======= - for (BlockVector2 pt : ((FlatRegion) region).asFlatRegion()) { - biomes.add(world.getBiome(pt)); - } - } else { - for (BlockVector3 pt : region) { - biomes.add(world.getBiome(pt.toBlockVector2())); - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } } 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 1b9122a05..7570f0aa8 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 @@ -24,13 +24,9 @@ import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Logging; +import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; -======= ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player; @@ -79,17 +75,10 @@ public class ChunkCommands { String filename = "c." + Integer.toString(chunkX, 36) + "." + Integer.toString(chunkZ, 36) + ".dat"; -<<<<<<< HEAD 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 Vector2D(chunkX, chunkZ))); -======= - player.print("Chunk: " + chunkX + ", " + chunkZ); - player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename); - player.print("McRegion: region/" + McRegionChunkStore.getFilename( new BlockVector2(chunkX, chunkZ))); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Command( @@ -100,19 +89,11 @@ public class ChunkCommands { max = 0 ) @CommandPermissions("worldedit.listchunks") -<<<<<<< HEAD - public void listChunks(Player player, LocalSession session, CommandContext args) throws WorldEditException { - Set chunks = session.getSelection(player.getWorld()).getChunks(); - - for (Vector2D chunk : chunks) { - player.print(BBC.getPrefix() + LegacyChunkStore.getFilename(chunk)); -======= public void listChunks(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { Set chunks = session.getSelection(player.getWorld()).getChunks(); for (BlockVector2 chunk : chunks) { - player.print(LegacyChunkStore.getFilename(chunk)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + player.print(BBC.getPrefix() + LegacyChunkStore.getFilename(chunk)); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 1d465742d..a11220650 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.command; -<<<<<<< HEAD import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.BBC; @@ -41,7 +40,6 @@ import com.boydti.fawe.util.gui.FormBuilder; import com.boydti.fawe.wrappers.FakePlayer; import com.sk89q.minecraft.util.commands.*; import com.sk89q.worldedit.*; -======= import static com.google.common.base.Preconditions.checkNotNull; import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT; import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION; @@ -53,7 +51,6 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.extent.PasteEvent; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; @@ -127,15 +124,15 @@ public class ClipboardCommands extends MethodCommands { public void lazyCopy(Player player, LocalSession session, EditSession editSession, @Selection final Region region, @Switch('e') boolean skipEntities, @Switch('m') Mask mask, @Switch('b') boolean copyBiomes) throws WorldEditException { - Vector min = region.getMinimumPoint(); - Vector max = region.getMaximumPoint(); + BlockVector3 min = region.getMinimumPoint(); + BlockVector3 max = region.getMaximumPoint(); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); FaweLimit limit = FawePlayer.wrap(player).getLimit(); if (volume >= limit.MAX_CHECKS) { throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); } session.setClipboard(null); - final Vector origin = region.getMinimumPoint(); + final BlockVector3 origin = region.getMinimumPoint(); final int mx = origin.getBlockX(); final int my = origin.getBlockY(); final int mz = origin.getBlockZ(); @@ -167,14 +164,14 @@ public class ClipboardCommands extends MethodCommands { public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession, @Selection Region region, @Switch('e') boolean skipEntities, @Switch('m') Mask mask, CommandContext context, @Switch('b') boolean copyBiomes) throws WorldEditException { - Vector min = region.getMinimumPoint(); - Vector max = region.getMaximumPoint(); + BlockVector3 min = region.getMinimumPoint(); + BlockVector3 max = region.getMaximumPoint(); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); FaweLimit limit = FawePlayer.wrap(player).getLimit(); if (volume >= limit.MAX_CHECKS) { throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); } - Vector pos = session.getPlacementPosition(player); + BlockVector3 pos = session.getPlacementPosition(player); fp.checkConfirmationRegion(() -> { session.setClipboard(null); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); @@ -217,8 +214,8 @@ public class ClipboardCommands extends MethodCommands { public void lazyCut(Player player, LocalSession session, EditSession editSession, @Selection final Region region, @Switch('e') boolean skipEntities, @Switch('m') Mask mask, @Switch('b') boolean copyBiomes) throws WorldEditException { - Vector min = region.getMinimumPoint(); - Vector max = region.getMaximumPoint(); + BlockVector3 min = region.getMinimumPoint(); + BlockVector3 max = region.getMaximumPoint(); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); FaweLimit limit = FawePlayer.wrap(player).getLimit(); if (volume >= limit.MAX_CHECKS) { @@ -228,7 +225,7 @@ public class ClipboardCommands extends MethodCommands { throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES); } session.setClipboard(null); - final Vector origin = region.getMinimumPoint(); + final BlockVector3 origin = region.getMinimumPoint(); final int mx = origin.getBlockX(); final int my = origin.getBlockY(); final int mz = origin.getBlockZ(); @@ -258,8 +255,8 @@ public class ClipboardCommands extends MethodCommands { public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession, @Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean skipEntities, @Switch('m') Mask mask, @Switch('b') boolean copyBiomes, CommandContext context) throws WorldEditException { - Vector min = region.getMinimumPoint(); - Vector max = region.getMaximumPoint(); + BlockVector3 min = region.getMinimumPoint(); + BlockVector3 max = region.getMaximumPoint(); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); FaweLimit limit = FawePlayer.wrap(player).getLimit(); if (volume >= limit.MAX_CHECKS) { @@ -268,7 +265,7 @@ public class ClipboardCommands extends MethodCommands { if (volume >= limit.MAX_CHANGES) { throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES); } - Vector pos = session.getPlacementPosition(player); + BlockVector3 pos = session.getPlacementPosition(player); fp.checkConfirmationRegion(() -> { session.setClipboard(null); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); @@ -481,14 +478,8 @@ public class ClipboardCommands extends MethodCommands { } Clipboard clipboard = holder.getClipboard(); Region region = clipboard.getRegion(); -<<<<<<< HEAD - Vector to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player); +BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player); checkPaste(player, editSession, to, holder, clipboard); - -======= - - BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner Operation operation = holder .createPaste(editSession) .to(to) @@ -499,27 +490,20 @@ public class ClipboardCommands extends MethodCommands { Operations.completeLegacy(operation); if (selectPasted) { -<<<<<<< HEAD - Vector clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); - Vector realTo = to.add(new Vector(holder.getTransform().apply(clipboardOffset))); - Vector max = realTo.add(new Vector(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint())))); - RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo, max); -======= BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); Vector3 realTo = to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3())); Vector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3())); RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo.toBlockPoint(), max.toBlockPoint()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner session.setRegionSelector(player.getWorld(), selector); selector.learnChanges(); selector.explainRegionAdjust(player, session); } - BBC.COMMAND_PASTE.send(player, to.toBlockVector()); + BBC.COMMAND_PASTE.send(player, to); if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_COPYPASTE.or(BBC.TIP_SOURCE_MASK, BBC.TIP_REPLACE_MARKER).send(player, to); } - private void checkPaste(Player player, EditSession editSession, Vector to, ClipboardHolder holder, Clipboard clipboard) { + private void checkPaste(Player player, EditSession editSession, BlockVector3 to, ClipboardHolder holder, Clipboard clipboard) { URI uri = null; if (holder instanceof URIClipboardHolder) uri = ((URIClipboardHolder) holder).getURI(clipboard); PasteEvent event = new PasteEvent(player, clipboard, uri, editSession, to); @@ -550,8 +534,8 @@ public class ClipboardCommands extends MethodCommands { @Switch('s') boolean selectPasted) throws WorldEditException { ClipboardHolder holder = session.getClipboard(); final Clipboard clipboard = holder.getClipboard(); - final Vector origin = clipboard.getOrigin(); - final Vector to = atOrigin ? origin : session.getPlacementPosition(player); + final BlockVector3 origin = clipboard.getOrigin(); + final BlockVector3 to = atOrigin ? origin : session.getPlacementPosition(player); checkPaste(player, editSession, to, holder, clipboard); Schematic schem = new Schematic(clipboard); @@ -559,9 +543,9 @@ public class ClipboardCommands extends MethodCommands { Region region = clipboard.getRegion().clone(); if (selectPasted) { - Vector clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); - Vector realTo = to.add(new Vector(holder.getTransform().apply(clipboardOffset))); - Vector max = realTo.add(new Vector(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint())))); + BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); + BlockVector3 realTo = to.add(holder.getTransform().apply(clipboardOffset.toVector3()).toBlockPoint()); + BlockVector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()).toBlockPoint()); RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo, max); session.setRegionSelector(player.getWorld(), selector); selector.learnChanges(); @@ -605,24 +589,13 @@ public class ClipboardCommands extends MethodCommands { max = 1 ) @CommandPermissions("worldedit.clipboard.flip") -<<<<<<< HEAD - public void flip(Player player, LocalSession session, - @Optional(Direction.AIM) @Direction Vector direction) throws WorldEditException { -======= public void flip(Player player, LocalSession session, EditSession editSession, @Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner ClipboardHolder holder = session.getClipboard(); AffineTransform transform = new AffineTransform(); -<<<<<<< HEAD - transform = transform.scale(direction.positive().multiply(-2).add(1, 1, 1)); + transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3()); holder.setTransform(transform.combine(holder.getTransform())); BBC.COMMAND_FLIPPED.send(player); -======= - transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3()); - holder.setTransform(holder.getTransform().combine(transform)); - player.print("The clipboard copy has been flipped."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Deprecated // See SchematicCommands#clear 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 7eb486f05..100ebe910 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 @@ -19,17 +19,15 @@ package com.sk89q.worldedit.command; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MutableVector; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.CombinedTransform; @@ -82,19 +80,6 @@ public class FlattenedClipboardTransform { transform, new AffineTransform().translate(original.getOrigin())); -<<<<<<< HEAD - // new Vector(minimum.getX(), minimum.getY(), minimum.getZ()) - // new Vector(maximum.getX(), maximum.getY(), maximum.getZ()) - Vector[] corners = new Vector[]{ - minimum, - maximum, - new Vector(maximum.getX(), minimum.getY(), minimum.getZ()), - new Vector(minimum.getX(), maximum.getY(), minimum.getZ()), - new Vector(minimum.getX(), minimum.getY(), maximum.getZ()), - new Vector(minimum.getX(), maximum.getY(), maximum.getZ()), - new Vector(maximum.getX(), minimum.getY(), maximum.getZ()), - new Vector(maximum.getX(), maximum.getY(), minimum.getZ())}; -======= Vector3[] corners = new Vector3[] { minimum, maximum, @@ -104,34 +89,27 @@ public class FlattenedClipboardTransform { maximum.withX(minimum.getX()), maximum.withY(minimum.getY()), maximum.withZ(minimum.getZ()) }; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner for (int i = 0; i < corners.length; i++) { - corners[i] = transformAround.apply(new Vector(corners[i])); + corners[i] = transformAround.apply(new Vector3(corners[i])); } - Vector3 newMinimum = corners[0]; - Vector3 newMaximum = corners[0]; - + MutableVector newMinimum = new MutableVector(corners[0]); + MutableVector newMaximum = new MutableVector(corners[0]); +// MutableVector cbv = new MutableVector(); for (int i = 1; i < corners.length; i++) { - newMinimum = newMinimum.getMinimum(corners[i]); - newMaximum = newMaximum.getMaximum(corners[i]); + MutableVector cbv = new MutableVector(corners[i]); + newMinimum = newMinimum.setComponents(newMinimum.getMinimum(cbv)); + newMaximum = newMaximum.setComponents(newMaximum.getMaximum(cbv)); } // After transformation, the points may not really sit on a block, // so we should expand the region for edge cases -<<<<<<< HEAD newMinimum.mutX(Math.ceil(Math.floor(newMinimum.getX()))); newMinimum.mutY(Math.ceil(Math.floor(newMinimum.getY()))); newMinimum.mutZ(Math.ceil(Math.floor(newMinimum.getZ()))); - return new CuboidRegion(newMinimum, newMaximum); -======= - newMinimum = newMinimum.floor(); - newMaximum = newMaximum.ceil(); - - return new CuboidRegion(newMinimum.toBlockPoint(), newMaximum.toBlockPoint()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + return new CuboidRegion(new BlockVector3(newMinimum.getX(), newMinimum.getY(), newMinimum.getZ()), new BlockVector3(newMaximum.getX(), newMaximum.getY(), newMaximum.getZ())); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index cea409929..688bb216a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -31,16 +31,13 @@ import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Logging; -<<<<<<< HEAD import com.sk89q.worldedit.*; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -======= import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; @@ -49,12 +46,11 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.internal.annotation.Selection; import com.sk89q.worldedit.internal.expression.ExpressionException; -<<<<<<< HEAD import com.sk89q.worldedit.regions.CuboidRegion; -======= +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MutableBlockVector; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator.TreeType; @@ -134,7 +130,7 @@ public class GenerationCommands extends MethodCommands { ) @CommandPermissions("worldedit.generation.image") @Logging(PLACEMENT) - public void image(Player player, LocalSession session, EditSession editSession, String arg, @Optional("true") boolean randomize, @Optional("100") int threshold, @Optional Vector2D dimensions) throws WorldEditException, ParameterException, IOException { + public void image(Player player, LocalSession session, EditSession editSession, String arg, @Optional("true") boolean randomize, @Optional("100") int threshold, @Optional BlockVector2 dimensions) throws WorldEditException, ParameterException, IOException { TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold); URL url = new URL(arg); if (!url.getHost().equalsIgnoreCase("i.imgur.com") && !url.getHost().equalsIgnoreCase("empcraft.com")) { @@ -146,14 +142,16 @@ public class GenerationCommands extends MethodCommands { image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(), RenderingHints.VALUE_INTERPOLATION_BILINEAR, false); } - MutableBlockVector pos1 = new MutableBlockVector(player.getLocation().toVector()); - MutableBlockVector pos2 = new MutableBlockVector(pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1)); +// MutableBlockVector pos1 = new MutableBlockVector(player.getLocation().toVector().toBlockPoint()); +// MutableBlockVector pos2 = new MutableBlockVector(pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1)); + BlockVector3 pos1 = player.getLocation().toVector().toBlockPoint(); + BlockVector3 pos2 = pos1.add(image.getWidth() - 1, 0, image.getHeight() - 1); CuboidRegion region = new CuboidRegion(pos1, pos2); int[] count = new int[1]; final BufferedImage finalImage = image; RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() { @Override - public boolean apply(Vector pos) throws WorldEditException { + public boolean apply(BlockVector3 pos) throws WorldEditException { try { int x = pos.getBlockX() - pos1.getBlockX(); int z = pos.getBlockZ() - pos1.getBlockZ(); @@ -203,17 +201,16 @@ public class GenerationCommands extends MethodCommands { ) @CommandPermissions("worldedit.generation.cylinder") @Logging(PLACEMENT) - public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector2D radius, @Optional("1") int height, @Range(min = 1) @Optional("1") double thickness, CommandContext context) throws WorldEditException, ParameterException { + public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector2 radius, @Optional("1") int height, @Range(min = 1) @Optional("1") double thickness, CommandContext context) throws WorldEditException, ParameterException { double max = MathMan.max(radius.getBlockX(), radius.getBlockZ()); worldEdit.checkMaxRadius(max); - Vector pos = session.getPlacementPosition(player); + BlockVector3 pos = session.getPlacementPosition(player); fp.checkConfirmationRadius(() -> { int affected = editSession.makeHollowCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), thickness - 1); BBC.VISITOR_BLOCK.send(fp, affected); }, getArguments(context), (int) max, context); } -<<<<<<< HEAD @Command( aliases = {"/cyl"}, usage = " [,] [height]", @@ -229,19 +226,14 @@ public class GenerationCommands extends MethodCommands { ) @CommandPermissions("worldedit.generation.cylinder") @Logging(PLACEMENT) - public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector2D radius, @Optional("1") int height, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException { + public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector2 radius, @Optional("1") int height, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException { double max = MathMan.max(radius.getBlockX(), radius.getBlockZ()); worldEdit.checkMaxRadius(max); - Vector pos = session.getPlacementPosition(player); + BlockVector3 pos = session.getPlacementPosition(player); fp.checkConfirmationRadius(() -> { int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow); BBC.VISITOR_BLOCK.send(fp, affected); }, getArguments(context), (int) max, context); -======= - BlockVector3 pos = session.getPlacementPosition(player); - int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow); - player.print(affected + " block(s) have been created."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Command( @@ -258,7 +250,7 @@ public class GenerationCommands extends MethodCommands { ) @CommandPermissions("worldedit.generation.sphere") @Logging(PLACEMENT) - public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector radius, @Optional("false") boolean raised, CommandContext context) throws WorldEditException, ParameterException { + public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector3 radius, @Optional("false") boolean raised, CommandContext context) throws WorldEditException, ParameterException { sphere(fp, player, session, editSession, pattern, radius, raised, true, context); } @@ -277,50 +269,16 @@ public class GenerationCommands extends MethodCommands { ) @CommandPermissions("worldedit.generation.sphere") @Logging(PLACEMENT) -<<<<<<< HEAD - public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector radius, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException { + public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, BlockVector3 radius, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException { double max = MathMan.max(radius.getBlockX(), radius.getBlockY(), radius.getBlockZ()); worldEdit.checkMaxRadius(max); - Vector pos = session.getPlacementPosition(player); - Vector finalPos = raised ? pos.add(0, radius.getY(), 0) : pos; + BlockVector3 pos = session.getPlacementPosition(player); + BlockVector3 finalPos = raised ? pos.add(0, radius.getY(), 0) : pos; fp.checkConfirmationRadius(() -> { int affected = editSession.makeSphere(finalPos, pattern, radius.getX(), radius.getY(), radius.getZ(), !hollow); player.findFreePosition(); BBC.VISITOR_BLOCK.send(fp, affected); }, getArguments(context), (int) max, context); -======= - public void sphere(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("false") boolean raised, @Switch('h') boolean hollow) throws WorldEditException { - String[] radii = radiusString.split(","); - final double radiusX, radiusY, radiusZ; - switch (radii.length) { - case 1: - radiusX = radiusY = radiusZ = Math.max(1, Double.parseDouble(radii[0])); - break; - - case 3: - radiusX = Math.max(1, Double.parseDouble(radii[0])); - radiusY = Math.max(1, Double.parseDouble(radii[1])); - radiusZ = Math.max(1, Double.parseDouble(radii[2])); - break; - - default: - player.printError("You must either specify 1 or 3 radius values."); - return; - } - - worldEdit.checkMaxRadius(radiusX); - worldEdit.checkMaxRadius(radiusY); - worldEdit.checkMaxRadius(radiusZ); - - BlockVector3 pos = session.getPlacementPosition(player); - if (raised) { - pos = pos.add(0, (int) radiusY, 0); - } - - int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow); - player.findFreePosition(); - player.print(affected + " block(s) have been created."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Command( @@ -376,20 +334,16 @@ public class GenerationCommands extends MethodCommands { ) @CommandPermissions("worldedit.generation.pyramid") @Logging(PLACEMENT) -<<<<<<< HEAD public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException { -======= - public void pyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow) throws WorldEditException { BlockVector3 pos = session.getPlacementPosition(player); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner worldEdit.checkMaxRadius(size); - Vector pos = session.getPlacementPosition(player); fp.checkConfirmationRadius(() -> { int affected = editSession.makePyramid(pos, pattern, size, !hollow); player.findFreePosition(); BBC.VISITOR_BLOCK.send(fp, affected); }, getArguments(context), size, context); } + @Command( aliases = {"/generate", "/gen", "/g"}, @@ -419,17 +373,10 @@ public class GenerationCommands extends MethodCommands { @Switch('h') boolean hollow, @Switch('r') boolean useRawCoords, @Switch('o') boolean offset, -<<<<<<< HEAD - @Switch('c') boolean offsetCenter, - CommandContext context) throws WorldEditException, ParameterException { - final Vector zero; - Vector unit; -======= - @Switch('c') boolean offsetCenter) throws WorldEditException { + @Switch('c') boolean offsetCenter, CommandContext context) throws WorldEditException { final Vector3 zero; Vector3 unit; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (useRawCoords) { zero = Vector3.ZERO; @@ -450,20 +397,16 @@ public class GenerationCommands extends MethodCommands { zero = max.add(min).multiply(0.5); unit = max.subtract(zero); -<<<<<<< HEAD - if (unit.getX() == 0) unit.mutX(1); - if (unit.getY() == 0) unit.mutY(1); - if (unit.getZ() == 0) unit.mutZ(1); -======= if (unit.getX() == 0) unit = unit.withX(1.0); if (unit.getY() == 0) unit = unit.withY(1.0); if (unit.getZ() == 0) unit = unit.withZ(1.0); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } + + final Vector3 unit1 = unit; fp.checkConfirmationRegion(() -> { try { - final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow); + final int affected = editSession.makeShape(region, zero, unit1, pattern, expression, hollow); player.findFreePosition(); BBC.VISITOR_BLOCK.send(fp, affected); } catch (ExpressionException e) { @@ -500,16 +443,9 @@ public class GenerationCommands extends MethodCommands { @Switch('h') boolean hollow, @Switch('r') boolean useRawCoords, @Switch('o') boolean offset, -<<<<<<< HEAD - @Switch('c') boolean offsetCenter, - CommandContext context) throws WorldEditException, ParameterException { - final Vector zero; - Vector unit; -======= - @Switch('c') boolean offsetCenter) throws WorldEditException { + @Switch('c') boolean offsetCenter, CommandContext context) throws WorldEditException { final Vector3 zero; Vector3 unit; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (useRawCoords) { zero = Vector3.ZERO; @@ -530,27 +466,16 @@ public class GenerationCommands extends MethodCommands { zero = max.add(min).multiply(0.5); unit = max.subtract(zero); -<<<<<<< HEAD - if (unit.getX() == 0) unit.mutX(1); - if (unit.getY() == 0) unit.mutY(1); - if (unit.getZ() == 0) unit.mutZ(1); -======= if (unit.getX() == 0) unit = unit.withX(1.0); if (unit.getY() == 0) unit = unit.withY(1.0); if (unit.getZ() == 0) unit = unit.withZ(1.0); } - - try { - final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow); - player.findFreePosition(); - player.print("" + affected + " columns affected."); - } catch (ExpressionException e) { - player.printError(e.getMessage()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner - } + + final Vector3 unit1 = unit; + fp.checkConfirmationRegion(() -> { try { - final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow); + final int affected = editSession.makeBiomeShape(region, zero, unit1, target, expression, hollow); player.findFreePosition(); BBC.VISITOR_FLAT.send(fp, affected); } catch (ExpressionException e) { 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 76e734dd0..9798f6c95 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 @@ -39,6 +39,8 @@ import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.worldedit.*; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.command.binding.Range; @@ -112,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 Vector(summary.minX, 0, summary.minZ), new Vector(summary.maxX, 255, summary.maxZ)); + rollback.setDimensions(new BlockVector3(summary.minX, 0, summary.minZ), new BlockVector3(summary.maxX, 255, summary.maxZ)); rollback.setTime(historyFile.lastModified()); RollbackDatabase db = DBHandler.IMP.getDatabase(world); db.logEdit(rollback); @@ -165,10 +167,12 @@ public class HistoryCommands extends MethodCommands { radius = Math.max(Math.min(500, radius), 0); final World world = player.getWorld(); Location origin = player.getLocation(); - Vector bot = origin.toVector().subtract(radius, radius, radius); - bot.mutY(Math.max(0, bot.getY())); - Vector top = origin.toVector().add(radius, radius, radius); - top.mutY(Math.min(255, top.getY())); + BlockVector3 bot = origin.toVector().toBlockPoint().subtract(radius, radius, radius); + bot = bot.withY(Math.max(0, bot.getY())); +// bot.mutY(Math.max(0, bot.getY())); + BlockVector3 top = origin.toVector().toBlockPoint().add(radius, radius, radius); + bot = bot.withY(Math.min(255, top.getY())); +// top.mutY(Math.min(255, top.getY())); RollbackDatabase database = DBHandler.IMP.getDatabase(world); final AtomicInteger count = new AtomicInteger(); final FawePlayer fp = FawePlayer.wrap(player); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java index cdd5bdeb4..e5d82d301 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 @@ -4,7 +4,6 @@ import com.boydti.fawe.object.mask.*; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -13,6 +12,8 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.*; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import com.sk89q.worldedit.session.request.RequestSelection; import com.sk89q.worldedit.util.command.binding.Switch; @@ -129,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 Vector(x, y, z)); + return new OffsetMask(mask, new BlockVector3(x, y, z)); } @Command( @@ -389,7 +390,7 @@ public class MaskCommands extends MethodCommands { max = 1 ) public Mask below(Mask mask) throws ExpressionException { - OffsetMask offsetMask = new OffsetMask(mask, new Vector(0, 1, 0)); + OffsetMask offsetMask = new OffsetMask(mask, new BlockVector3(0, 1, 0)); return new MaskIntersection(offsetMask, Masks.negate(mask)); } @@ -401,7 +402,7 @@ public class MaskCommands extends MethodCommands { max = 1 ) public Mask above(Mask mask) throws ExpressionException { - OffsetMask offsetMask = new OffsetMask(mask, new Vector(0, -1, 0)); + OffsetMask offsetMask = new OffsetMask(mask, new BlockVector3(0, -1, 0)); return new MaskIntersection(offsetMask, Masks.negate(mask)); } @@ -438,7 +439,7 @@ public class MaskCommands extends MethodCommands { ) public Mask expression(Extent extent, String input) throws ExpressionException { Expression exp = Expression.compile(input, "x", "y", "z"); - WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector.ONE, Vector.ZERO); + WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO); exp.setEnvironment(env); return new ExpressionMask(exp); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java index a52446d45..c040a4b12 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java @@ -191,7 +191,7 @@ public class NavigationCommands { pos = player.getSolidBlockTrace(300); } if (pos != null) { - if(args.hasFlag('f')) player.setPosition(pos); else player.findFreePosition(pos); + if(args.hasFlag('f')) player.setPosition(pos.toVector()); else player.findFreePosition(pos); BBC.POOF.send(player); } else { BBC.NO_BLOCK.send(player); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java index b46ffe82e..339656187 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java @@ -22,6 +22,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.RandomPattern; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.command.binding.Range; @@ -426,7 +427,7 @@ public class PatternCommands extends MethodCommands { ) public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException { Expression exp = Expression.compile(input, "x", "y", "z"); - WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector.ONE, Vector.ZERO); + WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO); exp.setEnvironment(env); return new ExpressionPattern(exp); } 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 2a846e11a..9db75d764 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -34,16 +34,13 @@ import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Logging; -<<<<<<< HEAD import com.sk89q.worldedit.*; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -======= import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.function.GroundFunction; @@ -58,6 +55,7 @@ import com.sk89q.worldedit.function.visitor.LayerVisitor; import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.annotation.Selection; import com.sk89q.worldedit.internal.expression.ExpressionException; +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.convolution.GaussianKernel; @@ -122,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 Vector(cx - 8, 0, cz - 8).multiply(16), new Vector(cx + 8, 0, cz + 8).multiply(16)); + selection = new CuboidRegion(new BlockVector3(cx - 8, 0, cz - 8).multiply(16), new BlockVector3(cx + 8, 0, cz + 8).multiply(16)); } int count = FaweAPI.fixLighting(loc.world, selection, FaweQueue.RelightMode.ALL); BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count); @@ -156,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 Vector(cx - 8, 0, cz - 8).multiply(16), new Vector(cx + 8, 0, cz + 8).multiply(16)); + selection = new CuboidRegion(new BlockVector3(cx - 8, 0, cz - 8).multiply(16), new BlockVector3(cx + 8, 0, cz + 8).multiply(16)); } int count = FaweAPI.fixLighting(loc.world, selection, FaweQueue.RelightMode.NONE); BBC.UPDATED_LIGHTING_SELECTION.send(fp, count); @@ -173,7 +171,7 @@ public class RegionCommands extends MethodCommands { BBC.NO_BLOCK.send(player); return; } - CompoundTag nbt = editSession.getBlock(pos.toVector()).getNbtData(); + CompoundTag nbt = editSession.getBlock(pos.toVector().toBlockPoint()).getNbtData(); if (nbt != null) { player.print(nbt.getValue().toString()); } else { @@ -194,11 +192,11 @@ public class RegionCommands extends MethodCommands { final int cx = loc.x >> 4; final int cz = loc.z >> 4; final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false); - for (Vector pt : region) { + for (BlockVector3 pt : region) { queue.setBlockLight((int) pt.getX(), (int) pt.getY(), (int) pt.getZ(), value); } int count = 0; - for (Vector2D chunk : region.getChunks()) { + for (BlockVector2 chunk : region.getChunks()) { queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ())); count++; } @@ -218,11 +216,11 @@ public class RegionCommands extends MethodCommands { final int cx = loc.x >> 4; final int cz = loc.z >> 4; final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false); - for (Vector pt : region) { + for (BlockVector3 pt : region) { queue.setSkyLight((int) pt.getX(), (int) pt.getY(), (int) pt.getZ(), value); } int count = 0; - for (Vector2D chunk : region.getChunks()) { + for (BlockVector2 chunk : region.getChunks()) { queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ())); count++; } @@ -290,14 +288,9 @@ public class RegionCommands extends MethodCommands { } worldEdit.checkMaxRadius(thickness); -<<<<<<< HEAD player.checkConfirmationRegion(() -> { - ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region; - List vectors = new ArrayList(cpregion.getVertices()); -======= ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region; List vectors = new ArrayList<>(cpregion.getVertices()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell); @@ -378,20 +371,19 @@ public class RegionCommands extends MethodCommands { @Logging(REGION) public void lay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException { player.checkConfirmationRegion(() -> { - Vector min = region.getMinimumPoint(); - Vector max = region.getMaximumPoint(); + BlockVector3 min = region.getMinimumPoint(); + BlockVector3 max = region.getMaximumPoint(); int maxY = max.getBlockY(); int width = region.getWidth(); int height = region.getLength(); int bx = min.getBlockX(); int bz = min.getBlockZ(); - Iterable flat = Regions.asFlatRegion(region).asFlatRegion(); - Iterator iter = new Fast2DIterator(flat, editSession).iterator(); + Iterable flat = Regions.asFlatRegion(region).asFlatRegion(); + Iterator iter = new Fast2DIterator(flat, editSession).iterator(); int y = 0; int affected = 0; - MutableBlockVector mutable = new MutableBlockVector(); while (iter.hasNext()) { - Vector2D pos = iter.next(); + BlockVector2 pos = iter.next(); int x = pos.getBlockX(); int z = pos.getBlockZ(); y = editSession.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY); @@ -479,8 +471,8 @@ public class RegionCommands extends MethodCommands { @CommandPermissions("worldedit.region.smoothsnow") @Logging(REGION) public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural, @Switch('s') boolean snow, CommandContext context) throws WorldEditException { - Vector min = region.getMinimumPoint(); - Vector max = region.getMaximumPoint(); + BlockVector3 min = region.getMinimumPoint(); + BlockVector3 max = region.getMaximumPoint(); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); FaweLimit limit = FawePlayer.wrap(player).getLimit(); if (volume >= limit.MAX_CHECKS) { @@ -551,8 +543,7 @@ public class RegionCommands extends MethodCommands { public void move(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, @Optional("1") @Range(min = 1) int count, -<<<<<<< HEAD - @Optional(Direction.AIM) @Direction Vector direction, + @Optional(Direction.AIM) @Direction BlockVector3 direction, @Optional("air") Pattern replace, @Switch('b') boolean copyBiomes, @Switch('e') boolean skipEntities, @@ -571,22 +562,6 @@ public class RegionCommands extends MethodCommands { } catch (RegionOperationException e) { player.sendMessage(BBC.getPrefix() + e.getMessage()); } -======= - @Optional(Direction.AIM) @Direction BlockVector3 direction, - @Optional("air") BlockStateHolder replace, - @Switch('s') boolean moveSelection) throws WorldEditException { - - int affected = editSession.moveRegion(region, direction, count, true, replace); - - if (moveSelection) { - try { - region.shift(direction.multiply(count)); - - session.getRegionSelector(player.getWorld()).learnChanges(); - session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); - } catch (RegionOperationException e) { - player.printError(e.getMessage()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } BBC.VISITOR_BLOCK.send(player, affected); @@ -637,7 +612,6 @@ public class RegionCommands extends MethodCommands { @Optional("1") @Range(min = 1) int count, @Optional(Direction.AIM) @Direction BlockVector3 direction, @Switch('s') boolean moveSelection, -<<<<<<< HEAD @Switch('b') boolean copyBiomes, @Switch('e') boolean skipEntities, @Switch('a') boolean ignoreAirBlocks, @Switch('m') Mask sourceMask, CommandContext context) throws WorldEditException { @@ -649,8 +623,8 @@ public class RegionCommands extends MethodCommands { if (moveSelection) { try { - final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); - Vector shiftVector = new Vector(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count); + 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); region.shift(shiftVector); session.getRegionSelector(player.getWorld()).learnChanges(); @@ -658,22 +632,6 @@ public class RegionCommands extends MethodCommands { } catch (RegionOperationException e) { player.sendMessage(BBC.getPrefix() + e.getMessage()); } -======= - @Switch('a') boolean ignoreAirBlocks) throws WorldEditException { - int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks); - - if (moveSelection) { - try { - final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()); - - final BlockVector3 shiftVector = direction.toVector3().multiply(count * (Math.abs(direction.dot(size)) + 1)).toBlockPoint(); - region.shift(shiftVector); - - session.getRegionSelector(player.getWorld()).learnChanges(); - session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); - } catch (RegionOperationException e) { - player.printError(e.getMessage()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } BBC.VISITOR_BLOCK.send(player, affected); @@ -699,17 +657,10 @@ public class RegionCommands extends MethodCommands { @Selection Region region, @Text String expression, @Switch('r') boolean useRawCoords, -<<<<<<< HEAD @Switch('o') boolean offset, CommandContext context) throws WorldEditException { - final Vector zero; - Vector unit; -======= - @Switch('o') boolean offset) throws WorldEditException { final Vector3 zero; Vector3 unit; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner - if (useRawCoords) { zero = Vector3.ZERO; unit = Vector3.ONE; @@ -723,19 +674,15 @@ public class RegionCommands extends MethodCommands { zero = max.add(min).divide(2); unit = max.subtract(zero); -<<<<<<< HEAD - if (unit.getX() == 0) unit.mutX(1); - if (unit.getY() == 0) unit.mutY(1); - if (unit.getZ() == 0) unit.mutZ(1); -======= if (unit.getX() == 0) unit = unit.withX(1.0); if (unit.getY() == 0) unit = unit.withY(1.0); if (unit.getZ() == 0) unit = unit.withZ(1.0); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } + + final Vector3 unit1 = unit; fp.checkConfirmationRegion(() -> { try { - final int affected = editSession.deformRegion(region, zero, unit, expression); + final int affected = editSession.deformRegion(region, zero, unit1, expression); player.findFreePosition(); BBC.VISITOR_BLOCK.send(fp, affected); } catch (ExpressionException e) { 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 114a5e971..68774b64f 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 @@ -43,12 +43,10 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.clipboard.Clipboard; -<<<<<<< HEAD import com.sk89q.worldedit.function.mask.Mask; -======= import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.regions.RegionSelector; @@ -69,10 +67,7 @@ import com.sk89q.worldedit.util.formatting.StyledFragment; import com.sk89q.worldedit.util.formatting.component.CommandListBox; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; -<<<<<<< HEAD import com.sk89q.worldedit.world.block.BlockState; -======= ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.storage.ChunkStore; import java.io.File; @@ -109,21 +104,20 @@ public class SelectionCommands { ) @Logging(POSITION) @CommandPermissions("worldedit.selection.pos") - public void pos1(Player player, LocalSession session, CommandContext args) throws WorldEditException { - Vector pos; + public void pos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + BlockVector3 pos; if (args.argsLength() == 1) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { String[] coords = args.getString(0).split(","); - pos = new Vector(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2])); + pos = new BlockVector3(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2])); } else { BBC.SELECTOR_INVALID_COORDINATES.send(player, args.getString(0)); return; } } else { - pos = player.getBlockIn().toVector(); + pos = player.getBlockIn().toVector().toBlockPoint(); } -<<<<<<< HEAD pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY()); if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) { BBC.SELECTOR_ALREADY_SET.send(player); @@ -131,16 +125,6 @@ public class SelectionCommands { } session.getRegionSelector(player.getWorld()).explainPrimarySelection(player, session, pos); -======= - - if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) { - player.printError("Position already set."); - return; - } - - session.getRegionSelector(player.getWorld()) - .explainPrimarySelection(player, session, pos.toVector().toBlockPoint()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Command( @@ -152,12 +136,12 @@ public class SelectionCommands { ) @Logging(POSITION) @CommandPermissions("worldedit.selection.pos") - public void pos2(Player player, LocalSession session, CommandContext args) throws WorldEditException { - Vector pos; + public void pos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + BlockVector3 pos; if (args.argsLength() == 1) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { String[] coords = args.getString(0).split(","); - pos = new Vector(Integer.parseInt(coords[0]), + pos = new BlockVector3(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2])); } else { @@ -165,26 +149,16 @@ public class SelectionCommands { return; } } else { - pos = player.getBlockIn().toVector(); + pos = player.getBlockIn().toVector().toBlockPoint(); } -<<<<<<< HEAD pos = pos.clampY(0, player.getWorld().getMaximumPoint().getBlockY()); if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) { BBC.SELECTOR_ALREADY_SET.send(player); -======= - - if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) { - player.printError("Position already set."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner return; } session.getRegionSelector(player.getWorld()) -<<<<<<< HEAD .explainSecondarySelection(player, session, pos); -======= - .explainSecondarySelection(player, session, pos.toVector().toBlockPoint()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Command( @@ -195,26 +169,17 @@ public class SelectionCommands { max = 0 ) @CommandPermissions("worldedit.selection.hpos") - public void hpos1(Player player, LocalSession session, CommandContext args) throws WorldEditException { - Vector pos = player.getBlockTrace(300).toVector(); + public void hpos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + BlockVector3 pos = player.getBlockTrace(300).toVector().toBlockPoint(); if (pos != null) { -<<<<<<< HEAD if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) { BBC.SELECTOR_ALREADY_SET.send(player); -======= - if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) { - player.printError("Position already set."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner return; } session.getRegionSelector(player.getWorld()) -<<<<<<< HEAD .explainPrimarySelection(player, session, pos); -======= - .explainPrimarySelection(player, session, pos.toVector().toBlockPoint()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } else { player.printError("No block in sight!"); } @@ -228,26 +193,17 @@ public class SelectionCommands { max = 0 ) @CommandPermissions("worldedit.selection.hpos") - public void hpos2(Player player, LocalSession session, CommandContext args) throws WorldEditException { - Vector pos = player.getBlockTrace(300).toVector(); + public void hpos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + BlockVector3 pos = player.getBlockTrace(300).toVector().toBlockPoint(); if (pos != null) { -<<<<<<< HEAD if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) { BBC.SELECTOR_ALREADY_SET.send(player); -======= - if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) { - player.printError("Position already set."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner return; } session.getRegionSelector(player.getWorld()) -<<<<<<< HEAD .explainSecondarySelection(player, session, pos); -======= - .explainSecondarySelection(player, session, pos.toVector().toBlockPoint()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } else { player.printError("No block in sight!"); } @@ -271,15 +227,9 @@ public class SelectionCommands { ) @Logging(POSITION) @CommandPermissions("worldedit.selection.chunk") -<<<<<<< HEAD - public void chunk(Player player, LocalSession session, CommandContext args) throws WorldEditException { - final Vector min; - final Vector max; -======= public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { final BlockVector3 min; final BlockVector3 max; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner final World world = player.getWorld(); if (args.hasFlag('s')) { Region region = session.getSelection(world); @@ -336,7 +286,7 @@ public class SelectionCommands { max = 0 ) @CommandPermissions("worldedit.wand") - public void wand(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { player.giveItem(new BaseItemStack(we.getConfiguration().wandItem, 1)); BBC.SELECTION_WAND.send(player); if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) @@ -370,7 +320,7 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.expand") - public void expand(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void expand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { // Special syntax (//expand vert) to expand the selection between // sky and bedrock. if (args.getString(0).equalsIgnoreCase("vert") || args.getString(0).equalsIgnoreCase("vertical")) { @@ -390,12 +340,7 @@ public class SelectionCommands { return; } - -<<<<<<< HEAD - List dirs = new ArrayList(); -======= List dirs = new ArrayList<>(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int change = args.getInteger(0); int reverseChange = 0; @@ -465,14 +410,9 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.contract") -<<<<<<< HEAD - public void contract(Player player, LocalSession session, CommandContext args) throws WorldEditException { - List dirs = new ArrayList(); -======= public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { List dirs = new ArrayList<>(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int change = args.getInteger(0); int reverseChange = 0; @@ -544,14 +484,9 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.shift") -<<<<<<< HEAD - public void shift(Player player, LocalSession session, CommandContext args) throws WorldEditException { - List dirs = new ArrayList(); -======= public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { List dirs = new ArrayList<>(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int change = args.getInteger(0); if (args.argsLength() == 2) { if (args.getString(1).contains(",")) { @@ -596,7 +531,7 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.outset") - public void outset(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void outset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { Region region = session.getSelection(player.getWorld()); region.expand(getChangesForEachDir(args)); session.getRegionSelector(player.getWorld()).learnChanges(); @@ -619,7 +554,7 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.inset") - public void inset(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void inset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { Region region = session.getSelection(player.getWorld()); region.contract(getChangesForEachDir(args)); session.getRegionSelector(player.getWorld()).learnChanges(); @@ -627,13 +562,8 @@ public class SelectionCommands { BBC.SELECTION_INSET.send(player); } -<<<<<<< HEAD - private Vector[] getChangesForEachDir(CommandContext args) { - List changes = new ArrayList(6); -======= private BlockVector3[] getChangesForEachDir(CommandContext args) { List changes = new ArrayList<>(6); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int change = args.getInteger(0); if (!args.hasFlag('h')) { @@ -660,8 +590,7 @@ public class SelectionCommands { max = 0 ) @CommandPermissions("worldedit.selection.size") -<<<<<<< HEAD - public void size(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { if (args.hasFlag('c')) { ClipboardHolder root = session.getClipboard(); // Clipboard clipboard = holder.getClipboard(); @@ -681,8 +610,8 @@ public class SelectionCommands { } Region region = clipboard.getRegion(); - Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(Vector.ONE); - Vector origin = clipboard.getOrigin(); + BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(BlockVector3.ONE); + BlockVector3 origin = clipboard.getOrigin(); String sizeStr = size.getBlockX() + "*" + size.getBlockY() + "*" + size.getBlockZ(); String originStr = origin.getBlockX() + "," + origin.getBlockY() + "," + origin.getBlockZ(); @@ -701,20 +630,19 @@ public class SelectionCommands { // player.print(BBC.getPrefix() + "Offset: " + origin); // player.print(BBC.getPrefix() + "Cuboid distance: " + size.distance(Vector.ONE)); // player.print(BBC.getPrefix() + "# of blocks: " + (int) (size.getX() * size.getY() * size.getZ())); -======= - public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - if (args.hasFlag('c')) { - ClipboardHolder holder = session.getClipboard(); - Clipboard clipboard = holder.getClipboard(); - Region region = clipboard.getRegion(); - BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()); - BlockVector3 origin = clipboard.getOrigin(); - - player.print("Cuboid dimensions (max - min): " + size); - player.print("Offset: " + origin); - player.print("Cuboid distance: " + size.distance(BlockVector3.ONE)); - player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ())); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// public void size(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { +// if (args.hasFlag('c')) { +// ClipboardHolder holder = session.getClipboard(); +// Clipboard clipboard = holder.getClipboard(); +// Region region = clipboard.getRegion(); +// BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()); +// BlockVector3 origin = clipboard.getOrigin(); +// +// player.print("Cuboid dimensions (max - min): " + size); +// player.print("Offset: " + origin); +// player.print("Cuboid distance: " + size.distance(BlockVector3.ONE)); +// player.print("# of blocks: " + (int) (size.getX() * size.getY() * size.getZ())); return; } @@ -723,11 +651,7 @@ public class SelectionCommands { .subtract(region.getMinimumPoint()) .add(1, 1, 1); -<<<<<<< HEAD player.print(BBC.getPrefix() + "Type: " + session.getRegionSelector(player.getWorld()) -======= - player.print("Type: " + session.getRegionSelector(player.getWorld()) ->>>>>>> 399e0ad5... Refactor vector system to be cleaner .getTypeName()); for (String line : session.getRegionSelector(player.getWorld()) @@ -735,15 +659,9 @@ public class SelectionCommands { player.print(BBC.getPrefix() + line); } -<<<<<<< HEAD player.print(BBC.getPrefix() + "Size: " + size); player.print(BBC.getPrefix() + "Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint())); player.print(BBC.getPrefix() + "# of blocks: " + region.getArea()); -======= - player.print("Size: " + size); - player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint())); - player.print("# of blocks: " + region.getArea()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index 38984f420..2404f780c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.command; -<<<<<<< HEAD import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.command.FaweParser; @@ -40,10 +39,8 @@ import com.boydti.fawe.util.gui.FormBuilder; import com.boydti.fawe.util.image.ImageUtil; import com.sk89q.minecraft.util.commands.*; import com.sk89q.worldedit.*; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -======= import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT; import com.google.common.base.Joiner; @@ -57,7 +54,6 @@ import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.command.util.CreatureButcher; import com.sk89q.worldedit.command.util.EntityRemover; import com.sk89q.worldedit.entity.Entity; @@ -260,7 +256,6 @@ public class UtilityCommands extends MethodCommands { BBC.WORLDEDIT_CANCEL_COUNT.send(player, cancelled); } -<<<<<<< HEAD @Command( aliases = {"/fill"}, usage = " [depth] [direction]", @@ -270,17 +265,12 @@ public class UtilityCommands extends MethodCommands { ) @CommandPermissions("worldedit.fill") @Logging(PLACEMENT) - public void fill(Player player, LocalSession session, EditSession editSession, Pattern pattern, double radius, @Optional("1") double depth, @Optional("down") @Direction Vector direction) throws WorldEditException { + public void fill(Player player, LocalSession session, EditSession editSession, Pattern pattern, double radius, @Optional("1") double depth, @Optional("down") @Direction BlockVector3 direction) throws WorldEditException { worldEdit.checkMaxRadius(radius); - Vector pos = session.getPlacementPosition(player); + BlockVector3 pos = session.getPlacementPosition(player); int affected; affected = editSession.fillDirection(pos, pattern, radius, (int) depth, direction); player.print(BBC.getPrefix() + affected + " block(s) have been created."); -======= - BlockVector3 pos = session.getPlacementPosition(player); - int affected = editSession.fillXZ(pos, pattern, radius, depth, false); - player.print(affected + " block(s) have been created."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Command( @@ -292,35 +282,34 @@ public class UtilityCommands extends MethodCommands { ) @CommandPermissions("worldedit.fill.recursive") @Logging(PLACEMENT) -<<<<<<< HEAD public void fillr(Player player, LocalSession session, EditSession editSession, Pattern pattern, double radius, @Optional("-1") double depth) throws WorldEditException { worldEdit.checkMaxRadius(radius); - Vector pos = session.getPlacementPosition(player); + BlockVector3 pos = session.getPlacementPosition(player); if (depth == -1) depth = Integer.MAX_VALUE; int affected = editSession.fillXZ(pos, pattern, radius, (int) depth, true); player.print(BBC.getPrefix() + affected + " block(s) have been created."); -======= - public void fillr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - - ParserContext context = new ParserContext(); - context.setActor(player); - context.setWorld(player.getWorld()); - context.setSession(session); - Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context); - - double radius = Math.max(1, args.getDouble(1)); - we.checkMaxRadius(radius); - int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE; - - BlockVector3 pos = session.getPlacementPosition(player); - int affected = 0; - if (pattern instanceof BlockPattern) { - affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true); - } else { - affected = editSession.fillXZ(pos, pattern, radius, depth, true); - } - player.print(affected + " block(s) have been created."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// public void fillr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { +// +// ParserContext context = new ParserContext(); +// context.setActor(player); +// context.setWorld(player.getWorld()); +// context.setSession(session); +// Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context); +// +// double radius = Math.max(1, args.getDouble(1)); +// we.checkMaxRadius(radius); +// int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE; +// +// BlockVector3 pos = session.getPlacementPosition(player); +// int affected = 0; +// if (pattern instanceof BlockPattern) { +// affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true); +// } else { +// affected = editSession.fillXZ(pos, pattern, radius, depth, true); +// } +// player.print(affected + " block(s) have been created."); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Command( @@ -430,16 +419,10 @@ public class UtilityCommands extends MethodCommands { if (from == null) { from = new ExistingBlockMask(editSession); } -<<<<<<< HEAD - Vector base = session.getPlacementPosition(player); - Vector min = base.subtract(size, size, size); - Vector max = base.add(size, size, size); -======= BlockVector3 base = session.getPlacementPosition(player); - BlockVector3 min = base.subtract(size, size, size); - BlockVector3 max = base.add(size, size, size); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + BlockVector3 min = base.subtract((int)size, (int)size, (int)size); + BlockVector3 max = base.add((int)size, (int)size, (int)size); Region region = new CuboidRegion(player.getWorld(), min, max); int affected = editSession.replaceBlocks(region, from, to); @@ -574,13 +557,8 @@ public class UtilityCommands extends MethodCommands { EditSession editSession = null; if (player != null) { -<<<<<<< HEAD session = worldEdit.getSessionManager().get(player); - Vector center = session.getPlacementPosition(player); -======= - session = we.getSessionManager().get(player); BlockVector3 center = session.getPlacementPosition(player); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner editSession = session.createEditSession(player); List entities; if (radius >= 0) { @@ -639,13 +617,8 @@ public class UtilityCommands extends MethodCommands { EditSession editSession = null; if (player != null) { -<<<<<<< HEAD session = worldEdit.getSessionManager().get(player); - Vector center = session.getPlacementPosition(player); -======= - session = we.getSessionManager().get(player); BlockVector3 center = session.getPlacementPosition(player); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner editSession = session.createEditSession(player); List entities; if (radius >= 0) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java index ff102e56a..b69157a70 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java @@ -3,18 +3,12 @@ package com.sk89q.worldedit.command.tool; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; -<<<<<<< HEAD import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; -======= import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -49,7 +43,6 @@ public class AreaPickaxe implements BlockTool { return true; } -<<<<<<< HEAD EditSession editSession = session.createEditSession(player); editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); @@ -58,24 +51,22 @@ public class AreaPickaxe implements BlockTool { for (int y = oy + range; y >= oy - range; --y) { if (initialType.equals(editSession.getLazyBlock(x, y, z))) { continue; -======= - try (EditSession editSession = session.createEditSession(player)) { - editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); - - try { - for (int x = ox - range; x <= ox + range; ++x) { - for (int y = oy - range; y <= oy + range; ++y) { - for (int z = oz - range; z <= oz + range; ++z) { - BlockVector3 pos = new BlockVector3(x, y, z); - if (editSession.getBlock(pos).getBlockType() != initialType) { - continue; - } - - ((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().toBlockPoint().distanceSq(pos)); - - editSession.setBlock(pos, BlockTypes.AIR.getDefaultState()); - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +// try (EditSession editSession = session.createEditSession(player)) { +// editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); +// +// try { +// for (int x = ox - range; x <= ox + range; ++x) { +// for (int y = oy - range; y <= oy + range; ++y) { +// for (int z = oz - range; z <= oz + range; ++z) { +// BlockVector3 pos = new BlockVector3(x, y, z); +// if (editSession.getBlock(pos).getBlockType() != initialType) { +// continue; +// } +// +// ((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().toBlockPoint().distanceSq(pos)); +// +// editSession.setBlock(pos, BlockTypes.AIR.getDefaultState()); +// } } editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java index 53b954caa..f79f60a0e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java @@ -19,6 +19,12 @@ package com.sk89q.worldedit.command.tool; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import com.google.common.collect.Lists; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -26,13 +32,11 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; -<<<<<<< HEAD -======= import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; /** @@ -44,18 +48,17 @@ public class BlockDataCyler implements DoubleActionBlockTool { public boolean canUse(Actor player) { return player.hasPermission("worldedit.tool.data-cycler"); } + + private Map> selectedProperties = new HashMap<>(); private boolean handleCycle(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, boolean forward) { World world = (World) clicked.getExtent(); -<<<<<<< HEAD - BlockStateHolder block = world.getBlock(clicked.toVector()); -======= +// BlockStateHolder block = world.getBlock(clicked.toVector()); BlockVector3 blockPoint = clicked.toVector().toBlockPoint(); BlockState block = world.getBlock(blockPoint); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (!config.allowedDataCycleBlocks.isEmpty() && !player.hasPermission("worldedit.override.data-cycler") @@ -64,61 +67,45 @@ public class BlockDataCyler implements DoubleActionBlockTool { return true; } - if (block.getBlockType().getProperties().isEmpty()) { - player.printError("That block's data cannot be cycled!"); + if (block.getStates().keySet().isEmpty()) { + player.printError("That block's data cannot be cycled!"); } else { -<<<<<<< HEAD - BlockStateHolder newBlock = block; - - // TODO Forward = cycle value, Backward = Next property - // int increment = forward ? 1 : -1; - // BaseBlock newBlock = new BaseBlock(type, BlockData.cycle(type, data, increment)); - EditSession editSession = session.createEditSession(player); - - try { - editSession.setBlock(clicked.toVector(), newBlock); - } catch (MaxChangedBlocksException e) { - player.printError("Max blocks change limit reached."); - } finally { - session.remember(editSession); -======= - Property currentProperty = selectedProperties.get(player.getUniqueId()); - - if (currentProperty == null || (forward && block.getState(currentProperty) == null)) { - currentProperty = block.getStates().keySet().stream().findFirst().get(); - selectedProperties.put(player.getUniqueId(), currentProperty); - } - - if (forward) { - block.getState(currentProperty); - int index = currentProperty.getValues().indexOf(block.getState(currentProperty)); - index = (index + 1) % currentProperty.getValues().size(); - BlockState newBlock = block.with(currentProperty, currentProperty.getValues().get(index)); - - try (EditSession editSession = session.createEditSession(player)) { - editSession.disableBuffering(); - - try { - editSession.setBlock(blockPoint, newBlock); - player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString()); - } catch (MaxChangedBlocksException e) { - player.printError("Max blocks change limit reached."); - } finally { - session.remember(editSession); - } - } - } else { - List> properties = Lists.newArrayList(block.getStates().keySet()); - int index = properties.indexOf(currentProperty); - index = (index + 1) % properties.size(); - currentProperty = properties.get(index); - selectedProperties.put(player.getUniqueId(), currentProperty); - player.print("Now cycling " + currentProperty.getName()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner - } + Property currentProperty = selectedProperties.get(player.getUniqueId()); + + if (currentProperty == null || (forward && block.getState(currentProperty) == null)) { + currentProperty = block.getStates().keySet().stream().findFirst().get(); + selectedProperties.put(player.getUniqueId(), currentProperty); + } + + if (forward) { + block.getState(currentProperty); + int index = currentProperty.getValues().indexOf(block.getState(currentProperty)); + index = (index + 1) % currentProperty.getValues().size(); + @SuppressWarnings("unchecked") + Property objProp = (Property) currentProperty; + BlockState newBlock = block.with(objProp, currentProperty.getValues().get(index)); + + try { + EditSession editSession = session.createEditSession(player); + try { + editSession.setBlock(blockPoint, newBlock); + player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString()); + } catch (MaxChangedBlocksException e) { + player.printError("Max blocks change limit reached."); + } finally { + session.remember(editSession); + } + }catch (Exception e) {} + } else { + List> properties = Lists.newArrayList(block.getStates().keySet()); + int index = properties.indexOf(currentProperty); + index = (index + 1) % properties.size(); + currentProperty = properties.get(index); + selectedProperties.put(player.getUniqueId(), currentProperty); + player.print("Now cycling " + currentProperty.getName()); + } } - - return true; + return true; } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java index 174f21921..6fca7840b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java @@ -58,22 +58,10 @@ public class BlockReplacer implements DoubleActionBlockTool { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { BlockBag bag = session.getBlockBag(player); -<<<<<<< HEAD EditSession editSession = session.createEditSession(player); try { - editSession.setBlock(clicked.toVector(), pattern); -======= - try (EditSession editSession = session.createEditSession(player)) { - try { - editSession.disableBuffering(); - BlockVector3 position = clicked.toVector().toBlockPoint(); - editSession.setBlock(position, pattern.apply(position)); - } catch (MaxChangedBlocksException ignored) { - } finally { - session.remember(editSession); - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + editSession.setBlock(clicked.toVector().toBlockPoint(), pattern); } finally { if (bag != null) { bag.flushChanges(); @@ -87,13 +75,9 @@ public class BlockReplacer implements DoubleActionBlockTool { @Override public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { -<<<<<<< HEAD EditSession editSession = session.createEditSession(player); - BlockStateHolder targetBlock = (editSession).getBlock(clicked.toVector()); + BlockStateHolder targetBlock = (editSession).getBlock(clicked.toVector().toBlockPoint()); BlockType type = targetBlock.getBlockType(); -======= - BlockStateHolder targetBlock = player.getWorld().getBlock(clicked.toVector().toBlockPoint()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (type != null) { this.pattern = targetBlock; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 5ab140b8a..ee0686790 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -24,6 +24,8 @@ import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.worldedit.*; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.internal.expression.Expression; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.command.tool.brush.Brush; @@ -379,19 +381,19 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool this.range = range; } - public Vector getPosition(EditSession editSession, Player player) { + public BlockVector3 getPosition(EditSession editSession, Player player) { Location loc = player.getLocation(); switch (targetMode) { case TARGET_BLOCK_RANGE: - return offset(new MutableBlockVector(trace(editSession, player, getRange(), true)), loc.toVector()); + return offset(trace(editSession, player, getRange(), true), loc.toVector()).toBlockPoint(); case FOWARD_POINT_PITCH: { int d = 0; float pitch = loc.getPitch(); pitch = 23 - (pitch / 4); d += (int) (Math.sin(Math.toRadians(pitch)) * 50); - final Vector vector = loc.getDirection().setY(0).normalize().multiply(d); - vector.add(loc.getX(), loc.getY(), loc.getZ()).toBlockVector(); - return offset(new MutableBlockVector(vector), loc.toVector()); + final Vector3 vector = loc.getDirection().withY(0).normalize().multiply(d).add(loc.getX(), loc.getY(), loc.getZ()); +// vector = vector.add(loc.getX(), loc.getY(), loc.getZ()); + return offset(vector, loc.toVector()).toBlockPoint(); } case TARGET_POINT_HEIGHT: { final int height = loc.getBlockY(); @@ -405,34 +407,33 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool } } final int distance = (height - y) + 8; - return offset(new MutableBlockVector(trace(editSession, player, distance, true)), loc.toVector()); + return offset(trace(editSession, player, distance, true), loc.toVector()).toBlockPoint(); } case TARGET_FACE_RANGE: - return offset(new MutableBlockVector(trace(editSession, player, getRange(), true)), loc.toVector()); + return offset(trace(editSession, player, getRange(), true), loc.toVector()).toBlockPoint(); default: return null; } } - private Vector offset(Vector target, Vector playerPos) { + private Vector3 offset(Vector3 target, Vector3 playerPos) { if (targetOffset == 0) return target; return target.subtract(target.subtract(playerPos).normalize().multiply(targetOffset)); } - private Vector trace(EditSession editSession, Player player, int range, boolean useLastBlock) { + private Vector3 trace(EditSession editSession, Player player, int range, boolean useLastBlock) { Mask mask = targetMask == null ? new SolidBlockMask(editSession) : targetMask; new MaskTraverser(mask).reset(editSession); MaskedTargetBlock tb = new MaskedTargetBlock(mask, player, range, 0.2); - return TaskManager.IMP.sync(new RunnableVal() { + return TaskManager.IMP.sync(new RunnableVal() { @Override - public void run(Vector value) { + public void run(Vector3 value) { Location result = tb.getMaskedTargetBlock(useLastBlock); this.value = result.toVector(); } }); } -<<<<<<< HEAD public boolean act(BrushAction action, Platform server, LocalConfiguration config, Player player, LocalSession session) { switch (action) { case PRIMARY: @@ -454,7 +455,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool return false; } - Vector target = getPosition(editSession, player); + BlockVector3 target = getPosition(editSession, player); if (target == null) { editSession.cancel(); @@ -475,14 +476,14 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool MaskIntersection newMask = new MaskIntersection(existingMask); newMask.add(mask); editSession.setMask(newMask); -======= - try { - brush.build(editSession, target.toVector().toBlockPoint(), material, size); - } catch (MaxChangedBlocksException e) { - player.printError("Max blocks change limit reached."); - } finally { - session.remember(editSession); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// try { +// brush.build(editSession, target.toVector().toBlockPoint(), material, size); +// } catch (MaxChangedBlocksException e) { +// player.printError("Max blocks change limit reached."); +// } finally { +// session.remember(editSession); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } Mask sourceMask = current.getSourceMask(); @@ -622,7 +623,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool .combineStages(false) .build(); VisualExtent newVisualExtent = new VisualExtent(editSession.getExtent(), editSession.getQueue()); - Vector position = getPosition(editSession, player); + BlockVector3 position = getPosition(editSession, player); if (position != null) { editSession.setExtent(newVisualExtent); switch (mode) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java index 53a0d0b4b..d1859ba49 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java @@ -75,24 +75,8 @@ public class FloatingTreeRemover implements BlockTool { player.printError("That's not a tree."); return true; } - -<<<<<<< HEAD final EditSession editSession = session.createEditSession(player); - - try { - final Set blockSet = bfs(world, clicked.toVector()); - if (blockSet == null) { - player.printError("That's not a floating tree."); - return true; - } - - for (Vector blockVector : blockSet) { - final BlockState otherState = editSession.getBlock(blockVector); - if (isTreeBlock(otherState.getBlockType())) { - editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState()); -======= - try (EditSession editSession = session.createEditSession(player)) { - try { + try /*(EditSession editSession = session.createEditSession(player))*/ { final Set blockSet = bfs(world, clicked.toVector().toBlockPoint()); if (blockSet == null) { player.printError("That's not a floating tree."); @@ -104,9 +88,7 @@ public class FloatingTreeRemover implements BlockTool { if (isTreeBlock(otherState.getBlockType())) { editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState()); } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } - } } catch (MaxChangedBlocksException e) { player.printError("Max blocks change limit reached."); } finally { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java index e7f663119..07f31c289 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java @@ -19,14 +19,11 @@ package com.sk89q.worldedit.command.tool; -<<<<<<< HEAD import com.sk89q.worldedit.*; -======= import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.MaxChangedBlocksException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; @@ -62,12 +59,8 @@ public class FloodFillTool implements BlockTool { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { World world = (World) clicked.getExtent(); -<<<<<<< HEAD - BlockType initialType = world.getBlockType(clicked.toVector()); -======= BlockVector3 origin = clicked.toVector().toBlockPoint(); BlockType initialType = world.getBlock(origin).getBlockType(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (initialType.getMaterial().isAir()) { return true; @@ -77,38 +70,22 @@ public class FloodFillTool implements BlockTool { return true; } -<<<<<<< HEAD EditSession editSession = session.createEditSession(player); -======= - try (EditSession editSession = session.createEditSession(player)) { - try { - recurse(editSession, origin, origin, range, initialType, new HashSet<>()); - } catch (MaxChangedBlocksException e) { - player.printError("Max blocks change limit reached."); - } finally { - session.remember(editSession); - } - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner - try { - recurse(editSession, clicked.toVector().toBlockVector(), - clicked.toVector(), range, initialType, new HashSet()); - } catch (WorldEditException e) { - throw new RuntimeException(e); + recurse(editSession, origin, origin, range, initialType, new HashSet<>()); + } catch (MaxChangedBlocksException e) { + player.printError("Max blocks change limit reached."); + } finally { + session.remember(editSession); } + editSession.flushQueue(); session.remember(editSession); return true; } -<<<<<<< HEAD - private void recurse(EditSession editSession, BlockVector pos, Vector origin, int size, BlockType initialType, - Set visited) throws WorldEditException { -======= private void recurse(EditSession editSession, BlockVector3 pos, BlockVector3 origin, int size, BlockType initialType, Set visited) throws MaxChangedBlocksException { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (origin.distance(pos) > size || visited.contains(pos)) { return; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java index 7da08e369..dbd37b095 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java @@ -56,11 +56,9 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) { Location pos = getTargetFace(player); if (pos == null) return false; -<<<<<<< HEAD EditSession eS = session.createEditSession(player); -======= - try (EditSession eS = session.createEditSession(player)) { - eS.disableBuffering(); + try { +// eS.disableBuffering(); BlockVector3 blockPoint = pos.toVector().toBlockPoint(); BlockStateHolder applied = secondary.apply(blockPoint); if (applied.getBlockType().getMaterial().isAir()) { @@ -73,31 +71,16 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo // one block? eat it } return false; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner - - BlockStateHolder applied = secondary.apply(pos.toVector()); - if (applied.getBlockType().getMaterial().isAir()) { - eS.setBlock(pos.toVector(), secondary); - } else { - eS.setBlock(pos.add(pos.getDirection()), secondary); - } - return true; } @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { Location pos = getTargetFace(player); if (pos == null) return false; -<<<<<<< HEAD EditSession eS = session.createEditSession(player); - BlockStateHolder applied = primary.apply(pos.toVector()); - if (applied.getBlockType().getMaterial().isAir()) { - eS.setBlock(pos.toVector(), primary); - } else { - eS.setBlock(pos.add(pos.getDirection()), primary); -======= - try (EditSession eS = session.createEditSession(player)) { - eS.disableBuffering(); + + try { +// eS.disableBuffering(); BlockVector3 blockPoint = pos.toVector().toBlockPoint(); BlockStateHolder applied = primary.apply(blockPoint); if (applied.getBlockType().getMaterial().isAir()) { @@ -108,7 +91,6 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo return true; } catch (MaxChangedBlocksException e) { // one block? eat it ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java index 22dca7ef1..50f2d41ba 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java @@ -1,11 +1,11 @@ package com.sk89q.worldedit.command.tool; -<<<<<<< HEAD +import java.util.Set; + import com.boydti.fawe.object.mask.IdMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; @@ -13,7 +13,6 @@ import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; -======= import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -22,9 +21,9 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; /** @@ -46,14 +45,11 @@ public class RecursivePickaxe implements BlockTool { @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { World world = (World) clicked.getExtent(); - final Vector pos = clicked.toVector(); + final BlockVector3 pos = clicked.toVector().toBlockPoint(); -<<<<<<< HEAD EditSession editSession = session.createEditSession(player); -======= BlockVector3 origin = clicked.toVector().toBlockPoint(); BlockType initialType = world.getBlock(origin).getBlockType(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner BlockStateHolder block = editSession.getBlock(pos); if (block.getBlockType().getMaterial().isAir()) { @@ -66,7 +62,7 @@ public class RecursivePickaxe implements BlockTool { editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); -<<<<<<< HEAD +//<<<<<<< HEAD final int radius = (int) range; final BlockReplace replace = new BlockReplace(editSession, (editSession.nullBlock)); editSession.setMask((Mask) null); @@ -76,54 +72,51 @@ public class RecursivePickaxe implements BlockTool { editSession.flushQueue(); session.remember(editSession); -======= - try { - recurse(server, editSession, world, clicked.toVector().toBlockPoint(), - clicked.toVector().toBlockPoint(), range, initialType, new HashSet<>()); - } catch (MaxChangedBlocksException e) { - player.printError("Max blocks change limit reached."); - } finally { - session.remember(editSession); - } - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// try { +// recurse(server, editSession, world, clicked.toVector().toBlockPoint(), +// clicked.toVector().toBlockPoint(), range, initialType, new HashSet<>()); +// } catch (MaxChangedBlocksException e) { +// player.printError("Max blocks change limit reached."); +// } finally { +// session.remember(editSession); +// } +// } +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner return true; } -<<<<<<< HEAD -======= - private static void recurse(Platform server, EditSession editSession, World world, BlockVector3 pos, - BlockVector3 origin, double size, BlockType initialType, Set visited) throws MaxChangedBlocksException { - - final double distanceSq = origin.distanceSq(pos); - if (distanceSq > size*size || visited.contains(pos)) { - return; - } - - visited.add(pos); - - if (editSession.getBlock(pos).getBlockType() != initialType) { - return; - } - - world.queueBlockBreakEffect(server, pos, initialType, distanceSq); - - editSession.setBlock(pos, BlockTypes.AIR.getDefaultState()); - - recurse(server, editSession, world, pos.add(1, 0, 0), - origin, size, initialType, visited); - recurse(server, editSession, world, pos.add(-1, 0, 0), - origin, size, initialType, visited); - recurse(server, editSession, world, pos.add(0, 0, 1), - origin, size, initialType, visited); - recurse(server, editSession, world, pos.add(0, 0, -1), - origin, size, initialType, visited); - recurse(server, editSession, world, pos.add(0, 1, 0), - origin, size, initialType, visited); - recurse(server, editSession, world, pos.add(0, -1, 0), - origin, size, initialType, visited); - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +// private static void recurse(Platform server, EditSession editSession, World world, BlockVector3 pos, +// BlockVector3 origin, double size, BlockType initialType, Set visited) throws MaxChangedBlocksException { +// +// final double distanceSq = origin.distanceSq(pos); +// if (distanceSq > size*size || visited.contains(pos)) { +// return; +// } +// +// visited.add(pos); +// +// if (editSession.getBlock(pos).getBlockType() != initialType) { +// return; +// } +// +// world.queueBlockBreakEffect(server, pos, initialType, distanceSq); +// +// editSession.setBlock(pos, BlockTypes.AIR.getDefaultState()); +// +// recurse(server, editSession, world, pos.add(1, 0, 0), +// origin, size, initialType, visited); +// recurse(server, editSession, world, pos.add(-1, 0, 0), +// origin, size, initialType, visited); +// recurse(server, editSession, world, pos.add(0, 0, 1), +// origin, size, initialType, visited); +// recurse(server, editSession, world, pos.add(0, 0, -1), +// origin, size, initialType, visited); +// recurse(server, editSession, world, pos.add(0, 1, 0), +// origin, size, initialType, visited); +// recurse(server, editSession, world, pos.add(0, -1, 0), +// origin, size, initialType, visited); +// } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java index bc53b0e37..c37369352 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.command.tool; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; @@ -42,30 +43,20 @@ public class SinglePickaxe implements BlockTool { @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { - World world = (World) clicked.getExtent(); -<<<<<<< HEAD - final BlockType blockType = world.getLazyBlock(clicked.toVector()).getBlockType(); - if (blockType == BlockTypes.BEDROCK && !player.canDestroyBedrock()) { - return true; - } - - EditSession editSession = session.createEditSession(player); - editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop); -======= + World world = (World) clicked.getExtent(); BlockVector3 blockPoint = clicked.toVector().toBlockPoint(); final BlockType blockType = world.getBlock(blockPoint).getBlockType(); if (blockType == BlockTypes.BEDROCK && !player.canDestroyBedrock()) { return true; } - - try (EditSession editSession = session.createEditSession(player)) { + final EditSession editSession = session.createEditSession(player); + try { editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop); editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState()); } catch (MaxChangedBlocksException e) { player.printError("Max blocks change limit reached."); } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner try { if (editSession.setBlock(clicked.getBlockX(), clicked.getBlockY(), clicked.getBlockZ(), EditSession.nullBlock)) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java index c36f0d691..d15ce9a20 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java @@ -50,23 +50,14 @@ public class TreePlanter implements BlockTool { EditSession editSession = session.createEditSession(player); -<<<<<<< HEAD try { boolean successful = false; - - for (int i = 0; i < 10; i++) { - if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0))) { - successful = true; - break; -======= for (int i = 0; i < 10; i++) { if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0).toBlockPoint())) { successful = true; break; } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } - } if (!successful) { player.printError("A tree can't go there."); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java index eb69ef189..2af7db173 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java @@ -20,13 +20,9 @@ package com.sk89q.worldedit.event.extent; import com.sk89q.worldedit.EditSession; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.event.Cancellable; -======= ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.Extent; @@ -59,11 +55,7 @@ import static com.sk89q.worldedit.EditSession.Stage; * is set to {@link Stage#BEFORE_HISTORY}, then you can drop (or log) changes * before the change has reached the history, reordering, and actual change * extents, but that means that any changes made with -<<<<<<< HEAD - * {@link EditSession#rawSetBlock(Vector, BaseBlock)} will skip your -======= * {@link EditSession#rawSetBlock(BlockVector3, BlockStateHolder)} will skip your ->>>>>>> 399e0ad5... Refactor vector system to be cleaner * custom {@link Extent} because that method bypasses history (and reorder). * It is thus recommended that loggers intercept at {@link Stage#BEFORE_CHANGE} * and block interceptors intercept at BOTH {@link Stage#BEFORE_CHANGE} and diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java index f004f8621..386a2d80e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java @@ -19,12 +19,13 @@ package com.sk89q.worldedit.event.extent; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.Cancellable; import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.math.BlockVector3; + import java.net.URI; @@ -35,11 +36,11 @@ public class PasteEvent extends Event implements Cancellable { private final Player player; private final Clipboard clipboard; private final URI uri; - private final Vector to; + private final BlockVector3 to; private final Extent extent; private boolean cancelled; - public PasteEvent(Player player, Clipboard clipboard, URI uri, Extent extent, Vector to) { + public PasteEvent(Player player, Clipboard clipboard, URI uri, Extent extent, BlockVector3 to) { this.player = player; this.clipboard = clipboard; this.uri = uri; @@ -59,7 +60,7 @@ public class PasteEvent extends Event implements Cancellable { return uri; } - public Vector getPosition() { + public BlockVector3 getPosition() { return to; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java index af4533d0d..c98ea0609 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.extension.factory; -<<<<<<< HEAD import com.boydti.fawe.command.SuggestInputParseException; import com.boydti.fawe.jnbt.JSON2NBT; import com.boydti.fawe.jnbt.NBTException; @@ -31,13 +30,10 @@ import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BaseItem; -======= import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.blocks.MobSpawnerBlock; import com.sk89q.worldedit.blocks.SignBlock; import com.sk89q.worldedit.blocks.SkullBlock; @@ -52,11 +48,8 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.SlottableBlockBag; import com.sk89q.worldedit.internal.registry.InputParser; -<<<<<<< HEAD -======= import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; @@ -211,11 +204,7 @@ public class DefaultBlockParser extends InputParser { int index = Integer.parseInt(typeString.replaceAll("[a-z]+", "")); // Get the block type from the "primary position" final World world = context.requireWorld(); -<<<<<<< HEAD - final Vector primaryPosition; -======= final BlockVector3 primaryPosition; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner try { primaryPosition = context.requireSession().getRegionSelector(world).getVerticies().get(index - 1); } catch (IncompleteRegionException e) { 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 9fd0152c4..1875b9f30 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 @@ -1,15 +1,12 @@ package com.sk89q.worldedit.extension.factory; -<<<<<<< HEAD import com.boydti.fawe.command.FaweParser; import com.boydti.fawe.command.SuggestInputParseException; import com.boydti.fawe.config.BBC; import com.boydti.fawe.util.StringMan; import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.CommandLocals; -======= import com.sk89q.worldedit.IncompleteRegionException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.command.MaskCommands; import com.sk89q.worldedit.extension.input.InputParseException; @@ -20,11 +17,9 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.BlockMaskBuilder; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.MaskIntersection; -<<<<<<< HEAD import com.sk89q.worldedit.function.mask.MaskUnion; import com.sk89q.worldedit.internal.command.ActorAuthorizer; import com.sk89q.worldedit.internal.command.WorldEditBinding; -======= import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.mask.NoiseFilter; import com.sk89q.worldedit.function.mask.OffsetMask; @@ -37,7 +32,6 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.noise.RandomNoise; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.command.Dispatcher; import com.sk89q.worldedit.util.command.SimpleDispatcher; @@ -169,10 +163,10 @@ public class DefaultMaskParser extends FaweParser { } } } else { -<<<<<<< HEAD - List args = entry.getValue(); - String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " ")); - try { +//<<<<<<< HEAD + List args = entry.getValue(); + String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " ")); + try { mask = (Mask) dispatcher.call(command + cmdArgs, locals, new String[0]); } catch (SuggestInputParseException rethrow) { throw rethrow; @@ -198,55 +192,55 @@ public class DefaultMaskParser extends FaweParser { throw new InputParseException(e2.getMessage()); } }); -======= - throw new NoMatchException("Unrecognized mask '" + component + '\''); - } - - case '>': - case '<': - Mask submask; - if (component.length() > 1) { - submask = getBlockMaskComponent(masks, component.substring(1), context); - } else { - submask = new ExistingBlockMask(extent); - } - OffsetMask offsetMask = new OffsetMask(submask, new BlockVector3(0, firstChar == '>' ? -1 : 1, 0)); - return new MaskIntersection(offsetMask, Masks.negate(submask)); - - case '$': - Set biomes = new HashSet<>(); - String[] biomesList = component.substring(1).split(","); - BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() - .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); - List knownBiomes = biomeRegistry.getBiomes(); - for (String biomeName : biomesList) { - BaseBiome biome = Biomes.findBiomeByName(knownBiomes, biomeName, biomeRegistry); - if (biome == null) { - throw new InputParseException("Unknown biome '" + biomeName + '\''); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// throw new NoMatchException("Unrecognized mask '" + component + '\''); +// } +// +// case '>': +// case '<': +// Mask submask; +// if (component.length() > 1) { +// submask = getBlockMaskComponent(masks, component.substring(1), context); +// } else { +// submask = new ExistingBlockMask(extent); +// } +// OffsetMask offsetMask = new OffsetMask(submask, new BlockVector3(0, firstChar == '>' ? -1 : 1, 0)); +// return new MaskIntersection(offsetMask, Masks.negate(submask)); +// +// case '$': +// Set biomes = new HashSet<>(); +// String[] biomesList = component.substring(1).split(","); +// BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() +// .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); +// List knownBiomes = biomeRegistry.getBiomes(); +// for (String biomeName : biomesList) { +// BaseBiome biome = Biomes.findBiomeByName(knownBiomes, biomeName, biomeRegistry); +// if (biome == null) { +// throw new InputParseException("Unknown biome '" + biomeName + '\''); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } -<<<<<<< HEAD +//<<<<<<< HEAD if (pe.and) { masks.add(new ArrayList<>()); -======= - - return Masks.asMask(new BiomeMask2D(context.requireExtent(), biomes)); - - case '%': - int i = Integer.parseInt(component.substring(1)); - return new NoiseFilter(new RandomNoise(), ((double) i) / 100); - - case '=': - try { - Expression exp = Expression.compile(component.substring(1), "x", "y", "z"); - WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment( - Request.request().getEditSession(), Vector3.ONE, Vector3.ZERO); - exp.setEnvironment(env); - return new ExpressionMask(exp); - } catch (ExpressionException e) { - throw new InputParseException("Invalid expression: " + e.getMessage()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// +// return Masks.asMask(new BiomeMask2D(context.requireExtent(), biomes)); +// +// case '%': +// int i = Integer.parseInt(component.substring(1)); +// return new NoiseFilter(new RandomNoise(), ((double) i) / 100); +// +// case '=': +// try { +// Expression exp = Expression.compile(component.substring(1), "x", "y", "z"); +// WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment( +// Request.request().getEditSession(), Vector3.ONE, Vector3.ZERO); +// exp.setEnvironment(env); +// return new ExpressionMask(exp); +// } catch (ExpressionException e) { +// throw new InputParseException("Invalid expression: " + e.getMessage()); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } masks.get(masks.size() - 1).add(mask); } 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 4ee50469a..2d781077d 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 @@ -22,10 +22,8 @@ package com.sk89q.worldedit.extension.platform; import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.PlayerDirection; import com.sk89q.worldedit.WorldEditException; -<<<<<<< HEAD import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockMaterial; -======= import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.cui.CUIEvent; @@ -35,8 +33,6 @@ import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.auth.AuthorizationException; -import com.sk89q.worldedit.world.block.BaseBlock; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -127,13 +123,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (free == 2) { if (y - 1 != origY) { -<<<<<<< HEAD - final Vector pos = new Vector(x, y - 2, z); + final BlockVector3 pos = new BlockVector3(x, y - 2, z); final BlockStateHolder state = world.getBlock(pos); - setPosition(new Vector(x + 0.5, y - 2 + BlockType.centralTopLimit(state), z + 0.5)); -======= - setPosition(new Vector3(x + 0.5, y - 2 + 1, z + 0.5)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + 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)); } return; @@ -151,17 +144,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { int z = searchPos.getBlockZ(); while (y >= 0) { -<<<<<<< HEAD - final Vector pos = new Vector(x, y, z); - final BlockStateHolder id = world.getBlock(pos); - if (id.getBlockType().getMaterial().isMovementBlocker()) { - setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id), z + 0.5)); -======= final BlockVector3 pos = new BlockVector3(x, y, z); final BlockState id = world.getBlock(pos); if (id.getBlockType().getMaterial().isMovementBlocker()) { - setPosition(new Vector3(x + 0.5, y + 1, z + 0.5)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + setPosition(new Vector3(x + 0.5, y + + BlockType.centralTopLimit(id), z + 0.5)); return; } @@ -185,8 +171,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { int maxY = world.getMaxY(); if (y >= maxY) return false; -<<<<<<< HEAD - BlockMaterial initialMaterial = world.getBlockType(new Vector(x, y, z)).getMaterial(); + BlockMaterial initialMaterial = world.getBlockType(new BlockVector3(x, y, z)).getMaterial(); boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube(); @@ -196,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 Vector(x, level, z)); + else state = world.getBlock(new BlockVector3(x, level, z)); BlockTypes type = state.getBlockType(); BlockMaterial material = type.getMaterial(); @@ -204,29 +189,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (!lastState) { lastState = BlockType.centralBottomLimit(state) != 1; continue; -======= - while (y <= world.getMaximumPoint().getY() + 2) { - if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { - ++free; - } else { - free = 0; - } - - if (free == 2) { - ++spots; - if (spots == 2) { - final BlockVector3 platform = new BlockVector3(x, y - 2, z); - final BlockStateHolder block = world.getBlock(platform); - final com.sk89q.worldedit.world.block.BlockType type = block.getBlockType(); - - // Don't get put in lava! - if (type == BlockTypes.LAVA) { - return false; - } - - setPosition(platform.toVector3().add(0.5, 1, 0.5)); - return true; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } if (freeStart == -1) { freeStart = level + BlockType.centralTopLimit(state); @@ -234,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 Vector(x + 0.5, freeStart, z + 0.5)); + setPosition(new Vector3(x + 0.5, freeStart, z + 0.5)); return true; } // Not enough room, reset the free position @@ -258,9 +220,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { final int z = pos.getBlockZ(); final Extent world = pos.getExtent(); - BlockMaterial initialMaterial = world.getBlockType(new Vector(x, y, z)).getMaterial(); + BlockMaterial initialMaterial = world.getBlockType(new BlockVector3(x, y, z)).getMaterial(); -<<<<<<< HEAD boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube(); double height = 1.85; @@ -272,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 Vector(x, level, z)); + else state = world.getBlock(new BlockVector3(x, level, z)); BlockTypes type = state.getBlockType(); BlockMaterial material = type.getMaterial(); @@ -288,29 +249,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { double freeStart = level + topLimit; double space = freeEnd - freeStart; if (space >= height) { - setPosition(new Vector(x + 0.5, freeStart, z + 0.5)); -======= - while (y >= 1) { - if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { - ++free; - } else { - free = 0; - } - - if (free == 2) { - // So we've found a spot, but we have to drop the player - // lightly and also check to see if there's something to - // stand upon - while (y >= 0) { - final BlockVector3 platform = new BlockVector3(x, y, z); - final BlockStateHolder block = world.getBlock(platform); - final BlockType type = block.getBlockType(); - - // Don't want to end up in lava - if (!type.getMaterial().isAir() && type != BlockTypes.LAVA) { - // Found a block! - setPosition(platform.toVector3().add(0.5, 1, 0.5)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + setPosition(new Vector3(x + 0.5, freeStart, z + 0.5)); return true; } // Not enough room, reset the free position @@ -392,41 +331,25 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public void floatAt(int x, int y, int z, boolean alwaysGlass) { -<<<<<<< HEAD - Vector spot = new Vector(x, y - 1, z); - if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) { - try { - getLocation().getExtent().setBlock(new Vector(x, y - 1, z), BlockTypes.GLASS.getDefaultState()); - } catch (WorldEditException e) { - e.printStackTrace(); -======= try { BlockVector3 spot = new BlockVector3(x, y - 1, z); if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) { getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } + }catch (WorldEditException e) { + e.printStackTrace(); } setPosition(new Vector3(x + 0.5, y, z + 0.5)); } @Override public Location getBlockIn() { -<<<<<<< HEAD - Location loc = getLocation(); - return new Location(loc.getExtent(), loc.toBlockVector(), loc.getDirection()); -======= return getLocation().setPosition(getLocation().toVector().floor()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Override public Location getBlockOn() { -<<<<<<< HEAD - return getLocation().setY(getLocation().getY() - 1); -======= return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Override @@ -607,12 +530,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { return false; } -<<<<<<< HEAD -} -======= @Override public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) { } } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index ec952810e..12c960118 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.extension.platform; -<<<<<<< HEAD import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.brush.visualization.VirtualWorld; @@ -30,9 +29,7 @@ import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; import com.boydti.fawe.wrappers.PlayerWrapper; import com.boydti.fawe.wrappers.WorldWrapper; import com.sk89q.worldedit.*; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.command.tool.*; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.LocalConfiguration; @@ -43,7 +40,6 @@ import com.sk89q.worldedit.command.tool.DoubleActionBlockTool; import com.sk89q.worldedit.command.tool.DoubleActionTraceTool; import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.command.tool.TraceTool; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.*; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; @@ -305,12 +301,11 @@ public class PlatformManager { public void handleBlockInteract(BlockInteractEvent event) { // Create a proxy actor with a potentially different world for // making changes to the world -<<<<<<< HEAD Request.reset(); final Actor actor = createProxyActor(event.getCause()); try { final Location location = event.getLocation(); - final Vector vector = location.toVector(); + final BlockVector3 vector = location.toVector().toBlockPoint(); // At this time, only handle interaction from players if (actor instanceof Player) { @@ -322,12 +317,6 @@ public class PlatformManager { virtual.handleBlockInteract(playerActor, vector, event); if (event.isCancelled()) return; } -======= - Actor actor = createProxyActor(event.getCause()); - - Location location = event.getLocation(); - Vector3 vector = location.toVector(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (event.getType() == Interaction.HIT) { if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().equals(getConfiguration().wandItem)) { @@ -340,7 +329,7 @@ public class PlatformManager { fp.runAction(new Runnable() { @Override public void run() { - if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) { + if (selector.selectPrimary(vector, ActorSelectorLimits.forActor(player))) { selector.explainPrimarySelection(actor, session, vector); } } @@ -364,7 +353,7 @@ public class PlatformManager { return; } } -<<<<<<< HEAD +//<<<<<<< HEAD final Tool tool = session.getTool(playerActor); if (tool != null && tool instanceof DoubleActionBlockTool) { if (tool.canUse(playerActor)) { @@ -379,14 +368,14 @@ public class PlatformManager { event.setCancelled(true); return; } -======= - - RegionSelector selector = session.getRegionSelector(player.getWorld()); - - BlockVector3 blockPoint = vector.toBlockPoint(); - if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) { - selector.explainPrimarySelection(actor, session, blockPoint); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// +// RegionSelector selector = session.getRegionSelector(player.getWorld()); +// +// BlockVector3 blockPoint = vector.toBlockPoint(); +// if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) { +// selector.explainPrimarySelection(actor, session, blockPoint); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } else if (event.getType() == Interaction.OPEN) { if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().equals(getConfiguration().wandItem)) { @@ -410,7 +399,7 @@ public class PlatformManager { return; } -<<<<<<< HEAD +//<<<<<<< HEAD final Tool tool = session.getTool(playerActor); if (tool != null && tool instanceof BlockTool) { if (tool.canUse(playerActor)) { @@ -431,23 +420,23 @@ public class PlatformManager { return; } } -======= - RegionSelector selector = session.getRegionSelector(player.getWorld()); - BlockVector3 blockPoint = vector.toBlockPoint(); - if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) { - selector.explainSecondarySelection(actor, session, blockPoint); - } - - event.setCancelled(true); - return; - } - - Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); - if (tool instanceof BlockTool) { - if (tool.canUse(player)) { - ((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location); - event.setCancelled(true); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// RegionSelector selector = session.getRegionSelector(player.getWorld()); +// BlockVector3 blockPoint = vector.toBlockPoint(); +// if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) { +// selector.explainSecondarySelection(actor, session, blockPoint); +// } +// +// event.setCancelled(true); +// return; +// } +// +// Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); +// if (tool instanceof BlockTool) { +// if (tool.canUse(player)) { +// ((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location); +// event.setCancelled(true); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } } 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 4da1c5a86..99bddddd6 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 @@ -51,7 +51,7 @@ import javax.annotation.Nullable; public class AbstractDelegateExtent implements LightingExtent { private transient final Extent extent; - private MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); +// private MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); /** * Create a new instance. @@ -126,10 +126,10 @@ public class AbstractDelegateExtent implements LightingExtent { @Override public BlockState getLazyBlock(int x, int y, int z) { - mutable.mutX(x); - mutable.mutY(y); - mutable.mutZ(z); - return extent.getLazyBlock(mutable); +// mutable.mutX(x); +// mutable.mutY(y); +// mutable.mutZ(z); + return extent.getLazyBlock(new BlockVector3(x, y, z)); } @Override @@ -139,10 +139,10 @@ public class AbstractDelegateExtent implements LightingExtent { @Override public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException { - mutable.mutX(x); - mutable.mutY(y); - mutable.mutZ(z); - return setBlock(mutable, block); +// mutable.mutX(x); +// mutable.mutY(y); +// mutable.mutZ(z); + return setBlock(new BlockVector3(x, y, z), block); } public BlockState getBlock(BlockVector3 position) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java index 083369b1d..748f3d50a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java @@ -19,16 +19,12 @@ package com.sk89q.worldedit.extent; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.WorldEditException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.history.change.BlockChange; @@ -38,13 +34,9 @@ import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; -<<<<<<< HEAD import javax.annotation.Nullable; -======= -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import java.util.ArrayList; import java.util.List; @@ -71,15 +63,9 @@ public class ChangeSetExtent extends AbstractDelegateExtent { } @Override -<<<<<<< HEAD - public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException { - BlockStateHolder previous = getBlock(location); - changeSet.add(new BlockChange(location.toBlockVector(), previous, block)); -======= public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { - BaseBlock previous = getFullBlock(location); + BlockStateHolder previous = getBlock(location); changeSet.add(new BlockChange(location, previous, block)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner return super.setBlock(location, block); } 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 0c6c2c622..6e4aa0560 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 @@ -19,23 +19,15 @@ package com.sk89q.worldedit.extent; -<<<<<<< HEAD -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.function.mask.Mask; -<<<<<<< HEAD import com.sk89q.worldedit.world.biome.BaseBiome; -======= +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -47,7 +39,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class MaskingExtent extends AbstractDelegateExtent { private Mask mask; - private MutableBlockVector mutable = new MutableBlockVector(); +// private MutableBlockVector mutable = new MutableBlockVector(); /** * Create a new instance. @@ -86,13 +78,13 @@ public class MaskingExtent extends AbstractDelegateExtent { } @Override - public boolean setBiome(Vector2D position, BaseBiome biome) { - return mask.test(mutable.setComponents(position.getBlockX(), 0, position.getBlockZ())) && super.setBiome(position, biome); + public boolean setBiome(BlockVector2 position, BaseBiome biome) { + return mask.test(position.toBlockVector3()) && super.setBiome(position, biome); } @Override public boolean setBiome(int x, int y, int z, BaseBiome biome) { - return mask.test(mutable.setComponents(x, y, z)) && super.setBiome(x, y, z, biome); + return mask.test(new BlockVector3(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 97a9f377a..fd7d501e1 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 @@ -20,35 +20,27 @@ package com.sk89q.worldedit.extent; import com.sk89q.worldedit.WorldEditException; -<<<<<<< HEAD import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.LazyBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.operation.Operation; -======= import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.biome.BaseBiome; -<<<<<<< HEAD -======= -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import javax.annotation.Nullable; import java.util.Collections; @@ -60,13 +52,10 @@ import java.util.List; */ public class NullExtent implements Extent { -<<<<<<< HEAD - private final Vector nullPoint = new Vector(0, 0, 0); + private final BlockVector3 nullPoint = new BlockVector3(0, 0, 0); public static final NullExtent INSTANCE = new NullExtent(); -======= ->>>>>>> 399e0ad5... Refactor vector system to be cleaner @Override public BlockVector3 getMinimumPoint() { return BlockVector3.ZERO; @@ -98,19 +87,13 @@ public class NullExtent implements Extent { return BlockTypes.AIR.getDefaultState(); } - @Override -<<<<<<< HEAD - public BlockState getLazyBlock(Vector position) { + public BlockState getLazyBlock(BlockVector3 position) { return BlockTypes.AIR.getDefaultState(); } @Override - public BlockState getFullBlock(Vector position) { + public BlockState getFullBlock(BlockVector3 position) { return new BaseBlock(getBlock(position)); -======= - public BaseBlock getFullBlock(BlockVector3 position) { - return getBlock(position).toBaseBlock(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Nullable 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 08ee58487..502ede4db 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 @@ -19,25 +19,20 @@ package com.sk89q.worldedit.extent.clipboard; -<<<<<<< HEAD import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard; import com.boydti.fawe.object.clipboard.FaweClipboard; +import com.boydti.fawe.object.clipboard.FaweClipboard.ClipboardEntity; import com.boydti.fawe.object.clipboard.MemoryOptimizedClipboard; import com.boydti.fawe.object.extent.LightingExtent; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.WorldEditException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.operation.Operation; @@ -46,11 +41,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BaseBiome; -<<<<<<< HEAD -======= -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; import java.io.Closeable; @@ -69,16 +60,16 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable { -<<<<<<< HEAD - private Region region; + private Region region; + private BlockVector3 origin; public FaweClipboard IMP; - private Vector size; + private BlockVector3 size; private int mx; private int my; private int mz; - private Vector origin; - private MutableBlockVector mutable = new MutableBlockVector(); - + private BlockStateHolder[][][] blocks; + private final List entities = new ArrayList<>(); + public BlockArrayClipboard(Region region) { checkNotNull(region); this.region = region.clone(); @@ -88,13 +79,8 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable this.mx = origin.getBlockX(); this.my = origin.getBlockY(); this.mz = origin.getBlockZ(); + this.blocks = new BlockStateHolder[size.getBlockX()][size.getBlockY()][size.getBlockZ()]; } -======= - private final Region region; - private BlockVector3 origin; - private final BlockStateHolder[][][] blocks; - private final List entities = new ArrayList<>(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner /** * Create a new instance. @@ -112,9 +98,9 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable this.mx = origin.getBlockX(); this.my = origin.getBlockY(); this.mz = origin.getBlockZ(); + this.blocks = new BlockStateHolder[size.getBlockX()][size.getBlockY()][size.getBlockZ()]; } -<<<<<<< HEAD public BlockArrayClipboard(Region region, FaweClipboard clipboard) { checkNotNull(region); this.region = region.clone(); @@ -124,6 +110,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable this.my = origin.getBlockY(); this.mz = origin.getBlockZ(); this.IMP = clipboard; + this.blocks = new BlockStateHolder[size.getBlockX()][size.getBlockY()][size.getBlockZ()]; } public void init(Region region, FaweClipboard fc) { @@ -136,6 +123,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable this.mx = origin.getBlockX(); this.my = origin.getBlockY(); this.mz = origin.getBlockZ(); + this.blocks = new BlockStateHolder[size.getBlockX()][size.getBlockY()][size.getBlockZ()]; } @Override @@ -146,10 +134,6 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable @Override public void close() { IMP.close(); -======= - BlockVector3 dimensions = getDimensions(); - blocks = new BlockStateHolder[dimensions.getBlockX()][dimensions.getBlockY()][dimensions.getBlockZ()]; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Override @@ -189,15 +173,9 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable @Override public List getEntities(Region region) { -<<<<<<< HEAD - List filtered = new ArrayList(); - for (Entity entity : getEntities()) { - if (region.contains(entity.getLocation().toVector())) { -======= List filtered = new ArrayList<>(); - for (Entity entity : entities) { + for (Entity entity : getEntities()) { if (region.contains(entity.getLocation().toVector().toBlockPoint())) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner filtered.add(entity); } } @@ -218,18 +196,18 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable @Override public BlockState getBlock(BlockVector3 position) { if (region.contains(position)) { -<<<<<<< HEAD +//<<<<<<< HEAD int x = position.getBlockX() - mx; int y = position.getBlockY() - my; int z = position.getBlockZ() - mz; return IMP.getBlock(x, y, z); -======= - BlockVector3 v = position.subtract(region.getMinimumPoint()); - BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()]; - if (block != null) { - return block.toImmutableState(); - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// BlockVector3 v = position.subtract(region.getMinimumPoint()); +// BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()]; +// if (block != null) { +// return block.toImmutableState(); +// } +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } return EditSession.nullBlock; } @@ -239,43 +217,42 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable } @Override -<<<<<<< HEAD - public BlockState getLazyBlock(Vector position) { +//<<<<<<< HEAD + public BlockState getLazyBlock(BlockVector3 position) { return getBlock(position); } -======= - public BaseBlock getFullBlock(BlockVector3 position) { - if (region.contains(position)) { - BlockVector3 v = position.subtract(region.getMinimumPoint()); - BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()]; - if (block != null) { - return block.toBaseBlock(); - } - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// public BaseBlock getFullBlock(BlockVector3 position) { +// if (region.contains(position)) { +// BlockVector3 v = position.subtract(region.getMinimumPoint()); +// BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()]; +// if (block != null) { +// return block.toBaseBlock(); +// } +// } +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner @Override - public BlockState getFullBlock(Vector position) { + public BlockState getFullBlock(BlockVector3 position) { return getLazyBlock(position); } @Override -<<<<<<< HEAD - public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException { + public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { if (region.contains(location)) { final int x = location.getBlockX(); final int y = location.getBlockY(); final int z = location.getBlockZ(); return setBlock(x, y, z, block); -======= - public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException { - if (region.contains(position)) { - BlockVector3 v = position.subtract(region.getMinimumPoint()); - blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = block; - return true; - } else { - return false; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException { +// if (region.contains(position)) { +// BlockVector3 v = position.subtract(region.getMinimumPoint()); +// blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = block; +// return true; +// } else { +// return false; +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } return false; } @@ -296,28 +273,18 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable } @Override -<<<<<<< HEAD - public BaseBiome getBiome(Vector2D position) { + public BaseBiome getBiome(BlockVector2 position) { int x = position.getBlockX() - mx; int z = position.getBlockZ() - mz; return IMP.getBiome(x, z); } @Override - public boolean setBiome(Vector2D position, BaseBiome biome) { + public boolean setBiome(BlockVector2 position, BaseBiome biome) { int x = position.getBlockX() - mx; int z = position.getBlockZ() - mz; IMP.setBiome(x, z, biome.getId()); return true; -======= - public BaseBiome getBiome(BlockVector2 position) { - return new BaseBiome(0); - } - - @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { - return false; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Nullable @@ -345,17 +312,11 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable @Override public int getOpacity(int x, int y, int z) { - mutable.mutX(x); - mutable.mutY(y); - mutable.mutZ(z); - return getBlock(mutable).getBlockType().getMaterial().getLightOpacity(); + return getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().getLightOpacity(); } @Override public int getBrightness(int x, int y, int z) { - mutable.mutX(x); - mutable.mutY(y); - mutable.mutZ(z); - return getBlock(mutable).getBlockType().getMaterial().getLightValue(); + return getBlock(new BlockVector3(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/ClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java index 0415b5ed2..419e28310 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java @@ -38,12 +38,12 @@ import com.google.gson.Gson; import com.sk89q.jnbt.*; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.block.BlockTypes; @@ -304,7 +304,7 @@ public enum ClipboardFormat { // summary // blocks HashMap map = new HashMap(); - Vector dimensions = clipboard.getDimensions(); + BlockVector3 dimensions = clipboard.getDimensions(); map.put("width", dimensions.getX()); map.put("height", dimensions.getY()); map.put("length", dimensions.getZ()); 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 f278595a0..c74132127 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 @@ -31,6 +31,7 @@ import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -225,7 +226,7 @@ public class MCEditSchematicReader extends NBTSchematicReader { try { if (state != null) { if (tileEntitiesMap.containsKey(pt)) { - clipboard.setBlock(region.getMinimumPoint().add(pt), state.toBaseBlock(new CompoundTag(tileEntitiesMap.get(pt)))); + clipboard.setBlock(region.getMinimumPoint().add(pt), /*state.toBaseBlock(new CompoundTag(tileEntitiesMap.get(pt)))*/new BaseBlock(state, new CompoundTag(tileEntitiesMap.get(pt)))); } else { clipboard.setBlock(region.getMinimumPoint().add(pt), state); } 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 6fb964435..2de82f502 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 @@ -42,12 +42,7 @@ import com.sk89q.jnbt.NamedTag; import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; -<<<<<<< HEAD -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.Vector; -======= import com.sk89q.worldedit.WorldEdit; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.entity.BaseEntity; @@ -108,68 +103,214 @@ public class SpongeSchematicReader extends NBTSchematicReader { return read(UUID.randomUUID()); } -<<<<<<< HEAD @Override public Clipboard read(UUID uuid) throws IOException { return readVersion1(uuid); } -======= - private Clipboard readVersion1(Map schematic) throws IOException { - BlockVector3 origin; - Region region; - - Map metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner - +// private Clipboard readVersion1(Map schematic) throws IOException { +// BlockVector3 origin; +// Region region; +// +// Map metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue(); +// } private int width, height, length; private int offsetX, offsetY, offsetZ; private char[] palette; - private Vector min; + private BlockVector3 min; private FaweClipboard fc; private FaweClipboard setupClipboard(int size, UUID uuid) { if (fc != null) { if (fc.getDimensions().getX() == 0) { - fc.setDimensions(new Vector(size, 1, 1)); + fc.setDimensions(new BlockVector3(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); } else { return fc = new MemoryOptimizedClipboard(size, 1, 1); -======= - - BlockVector3 min = new BlockVector3(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 = new BlockVector3(offsetX, offsetY, offsetZ); - origin = min.subtract(offset); - region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); - } else { - origin = min; - region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE)); - } - - int paletteMax = requireTag(schematic, "PaletteMax", IntTag.class).getValue(); - Map paletteObject = requireTag(schematic, "Palette", CompoundTag.class).getValue(); - if (paletteObject.size() != paletteMax) { - throw new IOException("Differing given palette size to actual size"); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } } +// BlockVector3 min = new BlockVector3(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 = new BlockVector3(offsetX, offsetY, offsetZ); +// origin = min.subtract(offset); +// region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); +// } else { +// origin = min; +// region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE)); +// } +// +// int paletteMax = requireTag(schematic, "PaletteMax", IntTag.class).getValue(); +// Map paletteObject = requireTag(schematic, "Palette", CompoundTag.class).getValue(); +// if (paletteObject.size() != paletteMax) { +// throw new IOException("Differing given palette size to actual size"); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner +// private Clipboard readVersion1(UUID uuid) throws IOException { +// width = height = length = offsetX = offsetY = offsetZ = Integer.MIN_VALUE; +// +// final BlockArrayClipboard clipboard = new BlockArrayClipboard(new CuboidRegion(new Vector(0, 0, 0), new Vector(0, 0, 0)), fc); +// FastByteArrayOutputStream blocksOut = new FastByteArrayOutputStream(); +// FastByteArrayOutputStream biomesOut = new FastByteArrayOutputStream(); +// +// NBTStreamer streamer = new NBTStreamer(inputStream); +// 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 BlockVector(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); +// streamer.addReader("Schematic.Palette", (BiConsumer>) (i, v) -> { +// palette = new char[v.size()]; +// for (Map.Entry entry : v.entrySet()) { +// BlockState state = BlockState.get(entry.getKey()); +// int index = ((IntTag) entry.getValue()).getValue(); +// palette[index] = (char) state.getOrdinal(); +// } +//<<<<<<< HEAD +// }); +// streamer.addReader("Schematic.BlockData.#", new NBTStreamer.LazyReader() { +// @Override +// public void accept(Integer arrayLen, DataInputStream dis) { +// try (FaweOutputStream blocks = new FaweOutputStream(new LZ4BlockOutputStream(blocksOut))) { +// IOUtil.copy(dis, blocks, arrayLen); +// } 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(new BlockVector3(pos[0], pos[1], pos[2]), tileEntity); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner +// } +// }); +// streamer.addReader("Schematic.Biomes.#", new NBTStreamer.LazyReader() { +// @Override +// public void accept(Integer arrayLen, DataInputStream dis) { +// try (FaweOutputStream biomes = new FaweOutputStream(new LZ4BlockOutputStream(biomesOut))) { +// IOUtil.copy(dis, biomes, arrayLen); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// }); +// streamer.addReader("Schematic.TileEntities.#", new BiConsumer() { +// @Override +// public void accept(Integer index, CompoundTag value) { +// if (fc == null) { +// setupClipboard(0, uuid); +// } +// int[] pos = value.getIntArray("Pos"); +// int x = pos[0]; +// int y = pos[1]; +// int z = pos[2]; +// fc.setTile(x, y, z, value); +// } +// }); +// streamer.addReader("Schematic.Entities.#", new BiConsumer() { +// @Override +// public void accept(Integer index, CompoundTag compound) { +// if (fc == null) { +// setupClipboard(0, uuid); +// } +// String id = compound.getString("id"); +// if (id.isEmpty()) { +// return; +// } +// ListTag positionTag = compound.getListTag("Pos"); +// ListTag directionTag = compound.getListTag("Rotation"); +// EntityType type = EntityTypes.parse(id); +// if (type != null) { +// compound.getValue().put("Id", new StringTag(type.getId())); +// BaseEntity state = new BaseEntity(type, compound); +// fc.createEntity(clipboard, positionTag.asDouble(0), positionTag.asDouble(1), positionTag.asDouble(2), (float) directionTag.asDouble(0), (float) directionTag.asDouble(1), state); +// } else { +// Fawe.debug("Invalid entity: " + id); +// } +// } +//<<<<<<< HEAD +// }); +// streamer.readFully(); +// if (fc == null) setupClipboard(length * width * height, uuid); +// Vector origin = min; +// CuboidRegion region; +// if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) { +// origin = origin.subtract(new Vector(offsetX, offsetY, offsetZ)); +// region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE)); +// } else { +// region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE)); +// } +// if (blocksOut.getSize() != 0) { +// try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(blocksOut.toByteArrays())))) { +// int volume = width * height * length; +// if (palette.length < 128) { +// 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 = new BlockVector3(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); +// } +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner +// } +// } else { +// for (int index = 0; index < volume; index++) { +// BlockState state = BlockTypes.states[palette[fis.readVarInt()]]; +// fc.setBlock(index, state); +// } +// } +// } +// } +// if (biomesOut.getSize() != 0) { +// try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(biomesOut.toByteArrays())))) { +// int volume = width * length; +// for (int index = 0; index < volume; index++) { +// fc.setBiome(index, fis.read()); +// } +// } +// } +// fc.setDimensions(new Vector(width, height, length)); +// clipboard.init(region, fc); +// clipboard.setOrigin(origin); +// return clipboard; +// } + private Clipboard readVersion1(UUID uuid) throws IOException { width = height = length = offsetX = offsetY = offsetZ = Integer.MIN_VALUE; - final BlockArrayClipboard clipboard = new BlockArrayClipboard(new CuboidRegion(new Vector(0, 0, 0), new Vector(0, 0, 0)), fc); + final BlockArrayClipboard clipboard = new BlockArrayClipboard(new CuboidRegion(new BlockVector3(0, 0, 0), new BlockVector3(0, 0, 0)), fc); FastByteArrayOutputStream blocksOut = new FastByteArrayOutputStream(); FastByteArrayOutputStream biomesOut = new FastByteArrayOutputStream(); @@ -177,7 +318,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 BlockVector(v[0], v[1], v[2])); + streamer.addReader("Schematic.Offset", (BiConsumer) (i, v) -> min = new BlockVector3(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); @@ -188,7 +329,6 @@ 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 @@ -198,23 +338,6 @@ 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(new BlockVector3(pos[0], pos[1], pos[2]), tileEntity); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } }); streamer.addReader("Schematic.Biomes.#", new NBTStreamer.LazyReader() { @@ -261,17 +384,16 @@ public class SpongeSchematicReader extends NBTSchematicReader { Fawe.debug("Invalid entity: " + id); } } -<<<<<<< HEAD }); streamer.readFully(); if (fc == null) setupClipboard(length * width * height, uuid); - Vector origin = min; + BlockVector3 origin = min; CuboidRegion region; if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) { - origin = origin.subtract(new Vector(offsetX, offsetY, offsetZ)); - region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE)); + origin = origin.subtract(new BlockVector3(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(Vector.ONE)); + region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE)); } if (blocksOut.getSize() != 0) { try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(blocksOut.toByteArrays())))) { @@ -280,21 +402,6 @@ 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 = new BlockVector3(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); - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } } else { for (int index = 0; index < volume; index++) { @@ -312,12 +419,13 @@ public class SpongeSchematicReader extends NBTSchematicReader { } } } - fc.setDimensions(new Vector(width, height, length)); + fc.setDimensions(new BlockVector3(width, height, length)); clipboard.init(region, fc); clipboard.setOrigin(origin); return clipboard; } + @Override public void close() throws IOException { inputStream.close(); 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 8a4a3345b..0c99deb7e 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 @@ -27,23 +27,14 @@ import com.sk89q.jnbt.NBTConstants; import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; -<<<<<<< HEAD -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; -======= ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; -<<<<<<< HEAD import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import net.jpountz.lz4.LZ4BlockInputStream; import net.jpountz.lz4.LZ4BlockOutputStream; -======= -import com.sk89q.worldedit.world.block.BaseBlock; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -83,15 +74,9 @@ public class SpongeSchematicWriter implements ClipboardWriter { public void write1(Clipboard clipboard) throws IOException { // metadata Region region = clipboard.getRegion(); -<<<<<<< HEAD - Vector origin = clipboard.getOrigin(); - BlockVector min = region.getMinimumPoint().toBlockVector(); - Vector offset = min.subtract(origin); -======= BlockVector3 origin = clipboard.getOrigin(); BlockVector3 min = region.getMinimumPoint(); BlockVector3 offset = min.subtract(origin); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int width = region.getWidth(); int height = region.getHeight(); int length = region.getLength(); @@ -104,7 +89,7 @@ public class SpongeSchematicWriter implements ClipboardWriter { if (length > MAX_SIZE) { throw new IllegalArgumentException("Length of region too large for a .schematic"); } -<<<<<<< HEAD +//<<<<<<< HEAD // output final DataOutput rawStream = outputStream.getOutputStream(); outputStream.writeLazyCompoundTag("Schematic", out -> { @@ -157,49 +142,49 @@ public class SpongeSchematicWriter implements ClipboardWriter { })); numTiles[0]++; tilesOut.writeTagPayload(tile); -======= - - Map schematic = new HashMap<>(); - schematic.put("Version", new IntTag(1)); - - Map metadata = new HashMap<>(); - metadata.put("WEOffsetX", new IntTag(offset.getBlockX())); - metadata.put("WEOffsetY", new IntTag(offset.getBlockY())); - metadata.put("WEOffsetZ", new IntTag(offset.getBlockZ())); - - schematic.put("Metadata", new CompoundTag(metadata)); - - schematic.put("Width", new ShortTag((short) width)); - schematic.put("Height", new ShortTag((short) height)); - schematic.put("Length", new ShortTag((short) length)); - - // The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin' - schematic.put("Offset", new IntArrayTag(new int[]{ - min.getBlockX(), - min.getBlockY(), - min.getBlockZ(), - })); - - int paletteMax = 0; - Map palette = new HashMap<>(); - - List tileEntities = new ArrayList<>(); - - ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length); - - for (int y = 0; y < height; y++) { - int y0 = min.getBlockY() + y; - for (int z = 0; z < length; z++) { - int z0 = min.getBlockZ() + z; - for (int x = 0; x < width; x++) { - int x0 = min.getBlockX() + x; - BlockVector3 point = new BlockVector3(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 +//======= +// +// Map schematic = new HashMap<>(); +// schematic.put("Version", new IntTag(1)); +// +// Map metadata = new HashMap<>(); +// metadata.put("WEOffsetX", new IntTag(offset.getBlockX())); +// metadata.put("WEOffsetY", new IntTag(offset.getBlockY())); +// metadata.put("WEOffsetZ", new IntTag(offset.getBlockZ())); +// +// schematic.put("Metadata", new CompoundTag(metadata)); +// +// schematic.put("Width", new ShortTag((short) width)); +// schematic.put("Height", new ShortTag((short) height)); +// schematic.put("Length", new ShortTag((short) length)); +// +// // The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin' +// schematic.put("Offset", new IntArrayTag(new int[]{ +// min.getBlockX(), +// min.getBlockY(), +// min.getBlockZ(), +// })); +// +// int paletteMax = 0; +// Map palette = new HashMap<>(); +// +// List tileEntities = new ArrayList<>(); +// +// ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length); +// +// for (int y = 0; y < height; y++) { +// int y0 = min.getBlockY() + y; +// for (int z = 0; z < length; z++) { +// int z0 = min.getBlockZ() + z; +// for (int x = 0; x < width; x++) { +// int x0 = min.getBlockX() + x; +// BlockVector3 point = new BlockVector3(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 } int ordinal = block.getOrdinal(); char value = palette[ordinal]; @@ -221,7 +206,7 @@ public class SpongeSchematicWriter implements ClipboardWriter { if (clipboard instanceof BlockArrayClipboard) { ((BlockArrayClipboard) clipboard).IMP.forEach(reader, true); } else { - for (Vector pt : region) { + for (BlockVector3 pt : region) { BlockState block = clipboard.getBlock(pt); int x = pt.getBlockX() - min.getBlockX(); int y = pt.getBlockY() - min.getBlockY(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java index 68b19e927..4a87a75aa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java @@ -1,18 +1,14 @@ package com.sk89q.worldedit.extent.inventory; -<<<<<<< HEAD import com.boydti.fawe.object.exception.FaweException; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; -======= import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -90,15 +86,15 @@ public class BlockBagExtent extends AbstractDelegateExtent { } @Override -<<<<<<< HEAD - public boolean setBlock(Vector pos, BlockStateHolder block) throws WorldEditException { +//<<<<<<< HEAD + public boolean setBlock(BlockVector3 pos, BlockStateHolder block) throws WorldEditException { return setBlock(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), block); } -======= - public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException { - if (blockBag != null) { - BlockState existing = getExtent().getBlock(position); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException { +// if (blockBag != null) { +// BlockState existing = getExtent().getBlock(position); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner @Override public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/logging/AbstractLoggingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/logging/AbstractLoggingExtent.java index 2037be7e2..e00d88054 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/logging/AbstractLoggingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/logging/AbstractLoggingExtent.java @@ -19,11 +19,11 @@ package com.sk89q.worldedit.extent.logging; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -47,11 +47,11 @@ public abstract class AbstractLoggingExtent extends AbstractDelegateExtent { * @param position the position * @param newBlock the new block to replace the old one */ - protected void onBlockChange(Vector position, BlockStateHolder newBlock) { + protected void onBlockChange(BlockVector3 position, BlockStateHolder newBlock) { } @Override - public final boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException { + public final boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException { onBlockChange(position, block); return super.setBlock(position, block); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java index ba0d77070..145f5214a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java @@ -19,13 +19,8 @@ package com.sk89q.worldedit.extent.reorder; -<<<<<<< HEAD import com.google.common.collect.Iterators; -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.Vector; -======= import com.google.common.collect.Iterables; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.Blocks; import com.sk89q.worldedit.extent.AbstractDelegateExtent; @@ -34,11 +29,8 @@ import com.sk89q.worldedit.function.operation.BlockMapEntryPlacer; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.OperationQueue; import com.sk89q.worldedit.function.operation.RunContext; -<<<<<<< HEAD -======= import com.sk89q.worldedit.function.operation.SetLocatedBlocks; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.collection.TupleArrayList; import com.sk89q.worldedit.world.block.BlockCategories; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index 82db00bd2..2af13b11a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -1,13 +1,10 @@ package com.sk89q.worldedit.extent.transform; -<<<<<<< HEAD import com.boydti.fawe.object.extent.ResettableExtent; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.Extent; @@ -15,25 +12,20 @@ import com.sk89q.worldedit.internal.helper.MCDirections; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.registry.state.AbstractProperty; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.Sets; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.registry.state.BooleanProperty; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.registry.state.DirectionalProperty; import com.sk89q.worldedit.util.Direction; -<<<<<<< HEAD import com.sk89q.worldedit.world.biome.BaseBiome; -======= -import com.sk89q.worldedit.world.block.BaseBlock; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; @@ -43,6 +35,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; /** * Transforms blocks themselves (but not their position) according to a @@ -77,71 +70,12 @@ public class BlockTransformExtent extends ResettableExtent { case ROTATION: -<<<<<<< HEAD case AXIS: case FACING: case SHAPE: -======= - @Override - public BlockState getBlock(BlockVector3 position) { - return transformBlock(super.getBlock(position), false); - } - - @Override - public BaseBlock getFullBlock(BlockVector3 position) { - return transformBlock(super.getFullBlock(position), false); - } - - @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { - return super.setBlock(location, transformBlock(block, true)); - } - - - /** - * Transform the given block using the given transform. - * - *

The provided block is modified.

- * - * @param block the block - * @param transform the transform - * @return the same block - */ - public static T transform(T block, Transform transform) { - return transform(block, transform, block); - } - - private static final Set directionNames = Sets.newHashSet("north", "south", "east", "west"); - - /** - * Transform the given block using the given transform. - * - * @param block the block - * @param transform the transform - * @param changedBlock the block to change - * @return the changed block - */ - private static T transform(T block, Transform transform, T changedBlock) { - checkNotNull(block); - checkNotNull(transform); - - List properties = block.getBlockType().getProperties(); - - for (Property property : properties) { - if (property instanceof DirectionalProperty) { - Direction value = (Direction) block.getState(property); - if (value != null) { - Vector3 newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector()); - if (newValue != null) { - changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL)); - } - } - } - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner - + case NORTH: case EAST: case SOUTH: @@ -150,21 +84,79 @@ public class BlockTransformExtent extends ResettableExtent { } return null; } +// @Override +// public BlockState getBlock(BlockVector3 position) { +// return transformBlock(super.getBlock(position), false); +// } +// +// @Override +// public BaseBlock getFullBlock(BlockVector3 position) { +// return transformBlock(super.getFullBlock(position), false); +// } + +// @Override +// public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { +// return super.setBlock(location, transformBlock(block, true)); +// } + + +// /** +// * Transform the given block using the given transform. +// * +// *

The provided block is modified.

+// * +// * @param block the block +// * @param transform the transform +// * @return the same block +// */ +// public static T transform(T block, Transform transform) { +// return transform(block, transform, block); +// } + + private static final Set directionNames = Sets.newHashSet("north", "south", "east", "west"); + +// /** +// * Transform the given block using the given transform. +// * +// * @param block the block +// * @param transform the transform +// * @param changedBlock the block to change +// * @return the changed block +// */ +// private static T transform(T block, Transform transform, T changedBlock) { +// checkNotNull(block); +// checkNotNull(transform); +// +// List properties = block.getBlockType().getProperties(); +// +// for (Property property : properties) { +// if (property instanceof DirectionalProperty) { +// Direction value = (Direction) block.getState(property); +// if (value != null) { +// Vector3 newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector()); +// if (newValue != null) { +// changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL)); +// } +// } +// } +// } + + @Nullable -<<<<<<< HEAD +//<<<<<<< HEAD private static Integer getNewStateIndex(Transform transform, List directions, int oldIndex) { Direction oldDirection = directions.get(oldIndex); - Vector oldVector = oldDirection.toVector(); - Vector newVector = transform.apply(oldVector).subtract(transform.apply(Vector.ZERO)).normalize(); + Vector3 oldVector = oldDirection.toVector(); + Vector3 newVector = transform.apply(oldVector).subtract(transform.apply(Vector3.ZERO)).normalize(); int newIndex = oldIndex; - double closest = oldVector.toVector().normalize().dot(newVector); -======= - private static Vector3 getNewStateValue(DirectionalProperty state, Transform transform, Vector3 oldDirection) { - Vector3 newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector3.ZERO)).normalize(); - Vector3 newValue = null; - double closest = -2; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + double closest = oldVector.normalize().dot(newVector); +//======= +// private static Vector3 getNewStateValue(DirectionalProperty state, Transform transform, Vector3 oldDirection) { +// Vector3 newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector3.ZERO)).normalize(); +// Vector3 newValue = null; +// double closest = -2; +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner boolean found = false; for (int i = 0; i < directions.size(); i++) { @@ -265,13 +257,10 @@ public class BlockTransformExtent extends ResettableExtent { Direction direction = MCDirections.fromRotation(rot); if (direction != null) { - Vector applyAbsolute = transform.apply(direction.toVector()); - Vector applyOrigin = transform.apply(Vector.ZERO); - applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX()); - applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY()); - applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ()); + Vector3 applyAbsolute = transform.apply(direction.toVector()); + Vector3 applyOrigin = transform.apply(Vector3.ZERO); - Direction newDirection = Direction.findClosest(applyAbsolute, Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL); + Direction newDirection = Direction.findClosest(applyAbsolute.subtract(applyOrigin), Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL); if (newDirection != null) { Map values = ReflectionUtils.getMap(tag.getValue()); @@ -294,13 +283,10 @@ public class BlockTransformExtent extends ResettableExtent { Direction direction = MCDirections.fromRotation(rot); if (direction != null) { - Vector applyAbsolute = transformInverse.apply(direction.toVector()); - Vector applyOrigin = transformInverse.apply(Vector.ZERO); - applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX()); - applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY()); - applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ()); + Vector3 applyAbsolute = transformInverse.apply(direction.toVector()); + Vector3 applyOrigin = transformInverse.apply(Vector3.ZERO); - Direction newDirection = Direction.findClosest(applyAbsolute, Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL); + Direction newDirection = Direction.findClosest(applyAbsolute.subtract(applyOrigin), Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL); if (newDirection != null) { Map values = ReflectionUtils.getMap(tag.getValue()); @@ -319,17 +305,17 @@ public class BlockTransformExtent extends ResettableExtent { } @Override - public BlockState getLazyBlock(Vector position) { + public BlockState getLazyBlock(BlockVector3 position) { return transformFast(super.getLazyBlock(position)); } @Override - public BlockState getBlock(Vector position) { + public BlockState getBlock(BlockVector3 position) { return transformFast(super.getBlock(position)); } @Override - public BaseBiome getBiome(Vector2D position) { + public BaseBiome getBiome(BlockVector2 position) { return super.getBiome(position); } @@ -340,7 +326,7 @@ public class BlockTransformExtent extends ResettableExtent { @Override - public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException { + public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { return super.setBlock(location, transformFastInverse((BlockState) block)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java index 0589c1508..795d1bbd1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java @@ -25,13 +25,10 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; -<<<<<<< HEAD import static com.google.common.base.Preconditions.checkArgument; -======= import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner /** * Limits the number of blocks that can be changed before a diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java index c2c84e2c3..f9650e14b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.extent.validation; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java index 9bb136469..6899f8a0c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java @@ -22,13 +22,10 @@ package com.sk89q.worldedit.extent.world; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.WorldEditException; -<<<<<<< HEAD -======= import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java index aec39eaa2..e3099214b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.extent.world; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; 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 339a049ef..d374017fa 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 @@ -19,13 +19,8 @@ package com.sk89q.worldedit.extent.world; -<<<<<<< HEAD -import com.sk89q.worldedit.BlockVector2D; -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; 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 bfb3db93b..530df4894 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 @@ -19,13 +19,8 @@ package com.sk89q.worldedit.extent.world; -<<<<<<< HEAD -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; @@ -98,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(MutableBlockVector.get(x, y, z)); + world.simulateBlockMine(new BlockVector3(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/FlatRegionMaskingFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java index d909779b6..831ecc8b2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.math.BlockVector2; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java index cbd607f04..debdf1298 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java index 7ce1c437b..00ce92250 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java @@ -19,9 +19,9 @@ package com.sk89q.worldedit.function; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; @@ -53,7 +53,7 @@ public class RegionMaskTestFunction implements RegionFunction { } @Override - public boolean apply(Vector position) throws WorldEditException { + public boolean apply(BlockVector3 position) throws WorldEditException { if (mask.test(position)) { return pass.apply(position); } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java index 954fda239..09346a1f5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java index 88d616ef6..1266c408e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function.biome; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.FlatRegionFunction; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java index 8bcac8efb..bb66085d0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function.block; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.RegionFunction; @@ -56,13 +52,15 @@ public class BlockReplace implements RegionFunction { } @Override -<<<<<<< HEAD - public boolean apply(Vector position) throws WorldEditException { - return pattern.apply(extent, position, position); -======= +//<<<<<<< HEAD +// public boolean apply(Vector position) throws WorldEditException { +// return pattern.apply(extent, position, position); +//======= +// public boolean apply(BlockVector3 position) throws WorldEditException { +// return extent.setBlock(position, pattern.apply(position)); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner public boolean apply(BlockVector3 position) throws WorldEditException { - return extent.setBlock(position, pattern.apply(position)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + return pattern.apply(extent, position, position); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java index 629cb310f..2e07f2ce7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java @@ -22,16 +22,12 @@ package com.sk89q.worldedit.function.block; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.CompoundTag; -<<<<<<< HEAD import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -======= import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.worldedit.WorldEditException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.internal.helper.MCDirections; @@ -40,16 +36,13 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction.Flag; -<<<<<<< HEAD import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; -======= -import com.sk89q.worldedit.world.block.BaseBlock; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//import com.sk89q.worldedit.world.block.BaseBlock; /** * Copies blocks from one extent to another. @@ -85,16 +78,16 @@ public class ExtentBlockCopy implements RegionFunction { } @Override -<<<<<<< HEAD - public boolean apply(Vector position) throws WorldEditException { - Vector orig = position.subtract(from); - Vector transformed = transform.apply(orig); -======= +//<<<<<<< HEAD public boolean apply(BlockVector3 position) throws WorldEditException { - BaseBlock block = source.getFullBlock(position); BlockVector3 orig = position.subtract(from); BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// public boolean apply(BlockVector3 position) throws WorldEditException { +// BaseBlock block = source.getFullBlock(position); +// BlockVector3 orig = position.subtract(from); +// BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint(); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner // Apply transformations to NBT data if necessary BlockStateHolder block = transformNbtData(source.getBlock(position)); @@ -119,18 +112,18 @@ public class ExtentBlockCopy implements RegionFunction { Direction direction = MCDirections.fromRotation(rot); if (direction != null) { -<<<<<<< HEAD - Vector applyAbsolute = transform.apply(direction.toVector()); - Vector applyOrigin = transform.apply(Vector.ZERO); - applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX()); - applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY()); - applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ()); -======= +//<<<<<<< HEAD +// Vector applyAbsolute = transform.apply(direction.toVector()); +// Vector applyOrigin = transform.apply(Vector.ZERO); +// applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX()); +// applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY()); +// applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ()); +//======= Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize(); Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner - Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL); +// Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL); if (newDirection != null) { Map values = ReflectionUtils.getMap(tag.getValue()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java index d348f7b23..14d3124b4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java @@ -29,13 +29,10 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.function.LayerFunction; import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.mask.Mask; -<<<<<<< HEAD import static com.google.common.base.Preconditions.checkNotNull; -======= import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockTypes; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner /** * Makes a layer of grass on top, three layers of dirt below, and smooth stone 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 6960e81dd..2cfa5720d 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 @@ -22,15 +22,11 @@ package com.sk89q.worldedit.function.entity; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.CompoundTag; -<<<<<<< HEAD import com.sk89q.jnbt.FloatTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.Vector; -======= import com.sk89q.jnbt.CompoundTagBuilder; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -105,19 +101,19 @@ public class ExtentEntityCopy implements EntityFunction { Location newLocation; Location location = entity.getLocation(); -<<<<<<< HEAD - Vector pivot = from.round().add(0.5, 0.5, 0.5); - Vector newPosition = transform.apply(location.toVector().subtract(pivot)); - Vector newDirection; - if (transform.isIdentity()) { - newDirection = entity.getLocation().getDirection(); - newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); - } else { - newDirection = new Vector(transform.apply(location.getDirection())).subtract(transform.apply(Vector.ZERO)).normalize(); - newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); - state = transformNbtData(state); - } -======= +//<<<<<<< HEAD +// Vector pivot = from.round().add(0.5, 0.5, 0.5); +// Vector newPosition = transform.apply(location.toVector().subtract(pivot)); +// Vector newDirection; +// if (transform.isIdentity()) { +// newDirection = entity.getLocation().getDirection(); +// newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); +// } else { +// newDirection = new Vector(transform.apply(location.getDirection())).subtract(transform.apply(Vector.ZERO)).normalize(); +// newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); +// state = transformNbtData(state); +// } +//======= Vector3 pivot = from.round().add(0.5, 0.5, 0.5); Vector3 newPosition = transform.apply(location.toVector().subtract(pivot)); Vector3 newDirection; @@ -129,7 +125,7 @@ public class ExtentEntityCopy implements EntityFunction { // Some entities store their position data in NBT state = transformNbtData(state); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner boolean success = destination.createEntity(newLocation, state) != null; @@ -167,14 +163,14 @@ 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); -======= +// 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")); BlockVector3 newTilePosition = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner values.put("TileX", new IntTag(newTilePosition.getBlockX())); values.put("TileY", new IntTag(newTilePosition.getBlockY())); @@ -213,10 +209,10 @@ public class ExtentEntityCopy implements EntityFunction { double pitch = Math.toRadians(rotation.getFloat(1)); double xz = Math.cos(pitch); - Vector direction = new Vector(-xz * Math.sin(yaw), -Math.sin(pitch), xz * Math.cos(yaw)); + Vector3 direction = new Vector3(-xz * Math.sin(yaw), -Math.sin(pitch), xz * Math.cos(yaw)); direction = transform.apply(direction); - FloatTag yawTag = new FloatTag(direction.toYaw()); - FloatTag pitchTag = new FloatTag(direction.toPitch()); + FloatTag yawTag = new FloatTag((float)direction.toYaw()); + FloatTag pitchTag = new FloatTag((float)direction.toPitch()); values.put("Rotation", new ListTag(FloatTag.class, Arrays.asList(yawTag, pitchTag))); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java index 2bed641d2..59762c606 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java @@ -27,12 +27,9 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.RandomPattern; -<<<<<<< HEAD -======= import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner /** * Generates flora (which may include tall grass, flowers, etc.). diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java index 85800201e..2fdb7fcb6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java @@ -21,12 +21,9 @@ package com.sk89q.worldedit.function.generator; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEditException; -<<<<<<< HEAD -======= import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.TreeGenerator; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java index 5bc169486..4a653d8ea 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java @@ -25,11 +25,8 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; -<<<<<<< HEAD -======= import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java index ba25165b7..1c456b088 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.world.biome.BaseBiome; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index 5eb276c53..83d4e000c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -1,22 +1,18 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD import com.boydti.fawe.object.collection.FastBitSet; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.StringMan; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -82,7 +78,6 @@ public class BlockMask extends AbstractExtentMask { } @Override -<<<<<<< HEAD public Mask optimize() { Map states = new HashMap<>(); int indexFound = -1; @@ -102,13 +97,6 @@ public class BlockMask extends AbstractExtentMask { } else { return this; } -======= - public boolean test(BlockVector3 vector) { - BlockStateHolder block = getExtent().getBlock(vector); - for (BlockStateHolder testBlock : blocks) { - if (testBlock.equalsFuzzy(block)) { - return true; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } // Only types, no states if (indexFound == -1) { @@ -138,6 +126,12 @@ public class BlockMask extends AbstractExtentMask { return mask; } } +// public boolean test(BlockVector3 vector) { +// BlockStateHolder block = getExtent().getBlock(vector); +// for (BlockStateHolder testBlock : blocks) { +// if (testBlock.equalsFuzzy(block)) { +// return true; + private Mask getOptimizedMask(BlockType type, long[] bitSet) { boolean single = true; @@ -233,7 +227,7 @@ public class BlockMask extends AbstractExtentMask { } @Override - public boolean test(Vector vector) { + public boolean test(BlockVector3 vector) { BlockStateHolder block = getExtent().getBlock(vector); long[] bitSet = bitSets[block.getInternalBlockTypeId()]; if (bitSet == null) return false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java index 58c4890dc..c15c3d354 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java @@ -1,11 +1,7 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockType; @@ -15,6 +11,8 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import javax.annotation.Nullable; + import static com.google.common.base.Preconditions.checkNotNull; public class BlockTypeMask extends AbstractExtentMask { @@ -81,18 +79,16 @@ public class BlockTypeMask extends AbstractExtentMask { } @Override -<<<<<<< HEAD - public boolean test(Vector vector) { - return types[getExtent().getBlockType(vector).getInternalId()]; -======= public boolean test(BlockVector3 vector) { - return blocks.contains(getExtent().getBlock(vector).getBlockType()); + return types[getExtent().getBlockType(vector).getInternalId()]; } +// public boolean test(BlockVector3 vector) { +// return blocks.contains(getExtent().getBlock(vector).getBlockType()); +// } @Nullable @Override public Mask2D toMask2D() { return null; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java index 5ba97737e..194b36f2b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkArgument; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java index 54e434209..ac4d24452 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java @@ -20,11 +20,7 @@ package com.sk89q.worldedit.function.mask; import com.sk89q.worldedit.extent.Extent; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import javax.annotation.Nullable; @@ -44,13 +40,8 @@ public class ExistingBlockMask extends AbstractExtentMask { } @Override -<<<<<<< HEAD - public boolean test(Vector vector) { - return !getExtent().getBlock(vector).getMaterial().isAir(); -======= public boolean test(BlockVector3 vector) { return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java index 54969e71e..7d36b71f4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java index f86bfdc44..283835f54 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java index 675a9b4f8..3999dfc44 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java @@ -1,9 +1,9 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.Vector; - import javax.annotation.Nullable; +import com.sk89q.worldedit.math.BlockVector3; + public class InverseMask extends AbstractMask { private final Mask mask; @@ -12,7 +12,7 @@ public class InverseMask extends AbstractMask { } @Override - public boolean test(Vector vector) { + public boolean test(BlockVector3 vector) { return !mask.test(vector); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java index 80e258e62..b998aaceb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java @@ -19,14 +19,11 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD import com.google.common.base.Function; -import com.sk89q.worldedit.Vector; -======= + import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import javax.annotation.Nullable; import java.util.*; @@ -172,17 +169,12 @@ public class MaskIntersection extends AbstractMask { } @Override -<<<<<<< HEAD - public boolean test(Vector vector) { - for (Mask mask : masksArray) { -======= public boolean test(BlockVector3 vector) { if (masks.isEmpty()) { return false; } for (Mask mask : masks) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (!mask.test(vector)) { return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java index f4dea45eb..61d7c6355 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector2; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import java.util.Arrays; import java.util.Collection; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java index 9cfaef8dd..5d4fe065b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD import com.google.common.base.Function; -import com.sk89q.worldedit.Vector; -======= import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -58,17 +54,12 @@ public class MaskUnion extends MaskIntersection { } @Override -<<<<<<< HEAD public Function, Mask> pairingFunction() { return input -> input.getKey().or(input.getValue()); } -======= - public boolean test(BlockVector3 vector) { - Collection masks = getMasks(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner @Override - public boolean test(Vector vector) { + public boolean test(BlockVector3 vector) { for (Mask mask : getMasksArray()) { if (mask.test(vector)) { return true; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java index 9bd01639a..4279d2fde 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java @@ -1,14 +1,9 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import javax.annotation.Nullable; @@ -57,36 +52,36 @@ public final class Masks { * @param finalMask the mask * @return a new mask */ -<<<<<<< HEAD +//<<<<<<< HEAD public static Mask negate(final Mask finalMask) { return finalMask.inverse(); -======= - public static Mask negate(final Mask mask) { - if (mask instanceof AlwaysTrue) { - return ALWAYS_FALSE; - } else if (mask instanceof AlwaysFalse) { - return ALWAYS_TRUE; - } - - checkNotNull(mask); - return new AbstractMask() { - @Override - public boolean test(BlockVector3 vector) { - return !mask.test(vector); - } - - @Nullable - @Override - public Mask2D toMask2D() { - Mask2D mask2d = mask.toMask2D(); - if (mask2d != null) { - return negate(mask2d); - } else { - return null; - } - } - }; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// public static Mask negate(final Mask mask) { +// if (mask instanceof AlwaysTrue) { +// return ALWAYS_FALSE; +// } else if (mask instanceof AlwaysFalse) { +// return ALWAYS_TRUE; +// } +// +// checkNotNull(mask); +// return new AbstractMask() { +// @Override +// public boolean test(BlockVector3 vector) { +// return !mask.test(vector); +// } +// +// @Nullable +// @Override +// public Mask2D toMask2D() { +// Mask2D mask2d = mask.toMask2D(); +// if (mask2d != null) { +// return negate(mask2d); +// } else { +// return null; +// } +// } +// }; +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java index e79300f1b..4fb74dc19 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java @@ -19,14 +19,10 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.math.noise.NoiseGenerator; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java index 0bfdd59ad..ef4f7f104 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java @@ -19,14 +19,10 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector2; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.math.noise.NoiseGenerator; import static com.google.common.base.Preconditions.checkArgument; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java index c6b70f4e6..b5e149dd5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java @@ -1,14 +1,9 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import javax.annotation.Nullable; @@ -21,12 +16,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class OffsetMask extends AbstractMask { private Mask mask; -<<<<<<< HEAD - private Vector offset; - private MutableBlockVector mutable = new MutableBlockVector(); -======= private BlockVector3 offset; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner /** * Create a new instance. @@ -80,16 +70,8 @@ public class OffsetMask extends AbstractMask { } @Override -<<<<<<< HEAD - public boolean test(Vector vector) { - mutable.mutX((vector.getX() + offset.getX())); - mutable.mutY((vector.getY() + offset.getY())); - mutable.mutZ((vector.getZ() + offset.getZ())); - return getMask().test(mutable); -======= public boolean test(BlockVector3 vector) { return getMask().test(vector.add(offset)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java index 5086beafe..9418f8c89 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector2; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java index 074632762..a622aaf98 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.regions.Region; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateBitMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateBitMask.java index 30128f523..24da28c8f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateBitMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateBitMask.java @@ -1,7 +1,7 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; public class SingleBlockStateBitMask extends AbstractExtentMask { private final int bitMask; @@ -12,7 +12,7 @@ public class SingleBlockStateBitMask extends AbstractExtentMask { } @Override - public boolean test(Vector vector) { + public boolean test(BlockVector3 vector) { int internalId = getExtent().getBlock(vector).getInternalId(); return (internalId & bitMask) == internalId; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java index c92f9c86d..e8514dafc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java @@ -1,7 +1,7 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -18,7 +18,7 @@ public class SingleBlockStateMask extends AbstractExtentMask { } @Override - public boolean test(Vector vector) { + public boolean test(BlockVector3 vector) { return state.equals(getExtent().getBlock(vector)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java index 0c3a4aee5..2f26b1aed 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java @@ -1,7 +1,7 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -15,7 +15,7 @@ public class SingleBlockTypeMask extends AbstractExtentMask { } @Override - public boolean test(Vector vector) { + public boolean test(BlockVector3 vector) { return getExtent().getBlockType(vector).getInternalId() == internalId; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java index 428aab881..ac6f0a1bb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java @@ -1,11 +1,8 @@ package com.sk89q.worldedit.function.mask; -<<<<<<< HEAD import com.sk89q.worldedit.blocks.BaseBlock; -======= import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.extent.Extent; @@ -23,16 +20,14 @@ public class SolidBlockMask extends BlockTypeMask { return types; } -<<<<<<< HEAD public SolidBlockMask(Extent extent) { super(extent, getTypes()); -======= + } @Override public boolean test(BlockVector3 vector) { Extent extent = getExtent(); BlockState block = extent.getBlock(vector); return block.getBlockType().getMaterial().isMovementBlocker(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Nullable 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 16bf2aec5..75487bc3e 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 @@ -1,10 +1,10 @@ package com.sk89q.worldedit.function.operation; -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.RegionFunction; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; @@ -16,11 +16,11 @@ public class BackwardsExtentBlockCopy implements Operation { private final Extent destination; private final Extent source; private final RegionFunction function; - private final Vector origin; + private final BlockVector3 origin; - private Vector mutable = new MutableBlockVector(); +// private Vector mutable = new MutableBlockVector(); - public BackwardsExtentBlockCopy(Extent source, Region region, Extent destination, Vector origin, Transform transform, RegionFunction function) { + public BackwardsExtentBlockCopy(Extent source, Region region, Extent destination, BlockVector3 origin, Transform transform, RegionFunction function) { this.source = source; this.region = region; this.destination = destination; @@ -33,8 +33,8 @@ public class BackwardsExtentBlockCopy implements Operation { public Operation resume(RunContext run) throws WorldEditException { CuboidRegion destRegion = transform(this.transform, this.region); Transform inverse = this.transform.inverse(); - for (Vector pt : destRegion) { - Vector copyFrom = transform(inverse, pt); + for (BlockVector3 pt : destRegion) { + BlockVector3 copyFrom = transform(inverse, pt); if (region.contains(copyFrom)) { function.apply(pt); } @@ -43,31 +43,32 @@ public class BackwardsExtentBlockCopy implements Operation { } private CuboidRegion transform(Transform transform, Region region) { - Vector min = new MutableBlockVector(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - Vector max = new MutableBlockVector(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); - Vector pos1 = region.getMinimumPoint(); - Vector pos2 = region.getMaximumPoint(); + 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 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() }) { - Vector pt = transform(transform, new Vector(x, y, z)).toBlockVector(); - min = Vector.getMinimum(min, pt); - max = Vector.getMaximum(max, pt); + BlockVector3 pt = transform(transform, new BlockVector3(x, y, z)); + min = min.getMinimum(pt); + max = max.getMaximum(pt); } } } return new CuboidRegion(min, max); } - private Vector transform(Transform transform, Vector pt) { - mutable.mutX(((pt.getBlockX() - origin.getBlockX()))); - mutable.mutY(((pt.getBlockY() - origin.getBlockY()))); - mutable.mutZ(((pt.getBlockZ() - origin.getBlockZ()))); - Vector tmp = transform.apply(mutable); - tmp.mutX((tmp.getBlockX() + origin.getBlockX())); - tmp.mutY((tmp.getBlockY() + origin.getBlockY())); - tmp.mutZ((tmp.getBlockZ() + origin.getBlockZ())); - return tmp; + private BlockVector3 transform(Transform transform, BlockVector3 pt) { +// mutable.mutX(((pt.getBlockX() - origin.getBlockX()))); +// mutable.mutY(((pt.getBlockY() - origin.getBlockY()))); +// mutable.mutZ(((pt.getBlockZ() - origin.getBlockZ()))); +// BlockVector3 tmp = transform.apply(new Vector3(pt.getBlockX() - origin.getBlockX(), pt.getBlockY() - origin.getBlockY(), pt.getBlockZ() - origin.getBlockZ())).toBlockPoint(); +// tmp.mutX((tmp.getBlockX() + origin.getBlockX())); +// 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()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BlockMapEntryPlacer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BlockMapEntryPlacer.java index 78577b2e9..0271b7895 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BlockMapEntryPlacer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BlockMapEntryPlacer.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.function.operation; -import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import java.util.Iterator; import java.util.List; @@ -40,7 +40,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class BlockMapEntryPlacer implements Operation { private final Extent extent; - private final Iterator> iterator; + private final Iterator> iterator; /** * Create a new instance. @@ -48,7 +48,7 @@ public class BlockMapEntryPlacer implements Operation { * @param extent the extent to set the blocks on * @param iterator the iterator */ - public BlockMapEntryPlacer(Extent extent, Iterator> iterator) { + public BlockMapEntryPlacer(Extent extent, Iterator> iterator) { checkNotNull(extent); checkNotNull(iterator); this.extent = extent; @@ -58,7 +58,7 @@ public class BlockMapEntryPlacer implements Operation { @Override public Operation resume(RunContext run) throws WorldEditException { while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); + Map.Entry entry = iterator.next(); extent.setBlock(entry.getKey(), entry.getValue()); } 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 df6f6f414..b2b5e5451 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 @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.operation; -<<<<<<< HEAD import com.boydti.fawe.example.MappedFaweQueue; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.extent.BlockTranslateExtent; @@ -29,14 +28,10 @@ import com.boydti.fawe.object.function.block.CombinedBlockCopy; import com.boydti.fawe.object.function.block.SimpleBlockCopy; import com.boydti.fawe.util.MaskTraverser; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.Lists; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.Extent; @@ -51,12 +46,9 @@ import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.visitor.EntityVisitor; import com.sk89q.worldedit.function.visitor.IntersectRegionFunction; import com.sk89q.worldedit.function.visitor.RegionVisitor; -<<<<<<< HEAD import com.sk89q.worldedit.math.transform.AffineTransform; -======= import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.math.transform.Identity; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.Region; @@ -279,9 +271,9 @@ public class ForwardExtentCopy implements Operation { } Extent finalDest = destination; - Vector translation = to.subtract(from); + BlockVector3 translation = to.subtract(from); - if (!translation.equals(Vector.ZERO)) { + if (!translation.equals(BlockVector3.ZERO)) { finalDest = new BlockTranslateExtent(finalDest, translation.getBlockX(), translation.getBlockY(), translation.getBlockZ()); } @@ -318,30 +310,28 @@ public class ForwardExtentCopy implements Operation { RegionFunction maskFunc = null; if (sourceFunction != null) { - Vector disAbs = translation.positive(); - Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); + BlockVector3 disAbs = translation.abs(); + BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); boolean overlap = (disAbs.getBlockX() < size.getBlockX() && disAbs.getBlockY() < size.getBlockY() && disAbs.getBlockZ() < size.getBlockZ()); RegionFunction copySrcFunc = sourceFunction; if (overlap && translation.length() != 0) { - MutableBlockVector mutable = new MutableBlockVector(); int x = translation.getBlockX(); int y = translation.getBlockY(); int z = translation.getBlockZ(); -<<<<<<< HEAD maskFunc = position -> { - mutable.setComponents(position.getBlockX() + x, position.getBlockY() + y, position.getBlockZ() + z); - if (region.contains(mutable)) { - return sourceFunction.apply(mutable); + BlockVector3 bv = new BlockVector3(position.getBlockX() + x, position.getBlockY() + y, position.getBlockZ() + z); + if (region.contains(bv)) { + return sourceFunction.apply(bv); } return false; }; copySrcFunc = position -> { - mutable.setComponents(position.getBlockX() - x, position.getBlockY() - y, position.getBlockZ() - z); - if (!region.contains(mutable)) { + BlockVector3 bv = new BlockVector3(position.getBlockX() - x, position.getBlockY() - y, position.getBlockZ() - z); + if (!region.contains(bv)) { return sourceFunction.apply(position); } return false; @@ -371,11 +361,9 @@ public class ForwardExtentCopy implements Operation { Operations.completeBlindly(blockCopy); if (!entities.isEmpty()) { - ExtentEntityCopy entityCopy = new ExtentEntityCopy(from, destination, to, currentTransform); -======= - if (copyingEntities) { ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), destination, to.toVector3(), currentTransform); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +// if (copyingEntities) { +// ExtentEntityCopy entityCopy = new ExtentEntityCopy(from.toVector3(), destination, to.toVector3(), currentTransform); entityCopy.setRemoving(removingEntities); EntityVisitor entityVisitor = new EntityVisitor(entities.iterator(), entityCopy); Operations.completeBlindly(entityVisitor); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java index d5ce9f3d3..5761007a8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java @@ -1,22 +1,10 @@ package com.sk89q.worldedit.function.pattern; -<<<<<<< HEAD -import com.boydti.fawe.FaweCache; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockState; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BaseBlock; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; - -import static com.google.common.base.Preconditions.checkNotNull; - /** * @deprecated Just use BaseBlock directly */ @@ -29,11 +17,6 @@ public class BlockPattern implements Pattern { this.block = block; } - @Override - public BlockStateHolder apply(Vector position) { - return block; - } - /** * Get the block. * @@ -52,13 +35,10 @@ public class BlockPattern implements Pattern { checkNotNull(block); this.block = block; } -<<<<<<< HEAD -======= @Override public BlockStateHolder apply(BlockVector3 position) { return block; } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } 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 7bbf74cef..ed255cb5c 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 @@ -1,14 +1,9 @@ package com.sk89q.worldedit.function.pattern; -<<<<<<< HEAD -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -22,13 +17,9 @@ import static com.google.common.base.Preconditions.checkNotNull; public class ClipboardPattern extends AbstractPattern { private final Clipboard clipboard; -<<<<<<< HEAD private final int sx, sy, sz; - private final Vector min; - private MutableBlockVector mutable = new MutableBlockVector(); -======= - private final BlockVector3 size; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + private final BlockVector3 min; +// private final BlockVector3 size; /** * Create a new clipboard pattern. @@ -38,7 +29,7 @@ public class ClipboardPattern extends AbstractPattern { public ClipboardPattern(Clipboard clipboard) { checkNotNull(clipboard); this.clipboard = clipboard; - Vector size = clipboard.getMaximumPoint().subtract(clipboard.getMinimumPoint()).add(1, 1, 1); + BlockVector3 size = clipboard.getMaximumPoint().subtract(clipboard.getMinimumPoint()).add(1, 1, 1); this.sx = size.getBlockX(); this.sy = size.getBlockY(); this.sz = size.getBlockZ(); @@ -46,26 +37,23 @@ public class ClipboardPattern extends AbstractPattern { } @Override -<<<<<<< HEAD - public BlockStateHolder apply(Vector position) { +//<<<<<<< HEAD + public BlockStateHolder apply(BlockVector3 position) { int xp = position.getBlockX() % sx; int yp = position.getBlockY() % sy; int zp = position.getBlockZ() % sz; if (xp < 0) xp += sx; if (yp < 0) yp += sy; if (zp < 0) zp += sz; - mutable.mutX((min.getX() + xp)); - mutable.mutY((min.getY() + yp)); - mutable.mutZ((min.getZ() + zp)); - return clipboard.getBlock(mutable); -======= - public BlockStateHolder apply(BlockVector3 position) { - int xp = Math.abs(position.getBlockX()) % size.getBlockX(); - int yp = Math.abs(position.getBlockY()) % size.getBlockY(); - int zp = Math.abs(position.getBlockZ()) % size.getBlockZ(); - - return clipboard.getFullBlock(clipboard.getMinimumPoint().add(xp, yp, zp)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + return clipboard.getBlock(new BlockVector3(min.getX() + xp, min.getY() + yp, min.getZ() + zp)); +//======= +// public BlockStateHolder apply(BlockVector3 position) { +// int xp = Math.abs(position.getBlockX()) % size.getBlockX(); +// int yp = Math.abs(position.getBlockY()) % size.getBlockY(); +// int zp = Math.abs(position.getBlockZ()) % size.getBlockZ(); +// +// return clipboard.getFullBlock(clipboard.getMinimumPoint().add(xp, yp, zp)); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java index 9030c2bf0..e9ee2af4f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java @@ -1,11 +1,11 @@ package com.sk89q.worldedit.function.pattern; import com.sk89q.minecraft.util.commands.Link; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.UtilityCommands; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.NullExtent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; @@ -17,7 +17,7 @@ import com.sk89q.worldedit.world.block.BlockState; public interface FawePattern extends Pattern { @Deprecated - default BlockStateHolder apply(Vector position) { + default BlockStateHolder apply(BlockVector3 position) { throw new UnsupportedOperationException("Please use apply(extent, get, set)"); } @@ -27,6 +27,6 @@ public interface FawePattern extends Pattern { * @return a block */ @Override - boolean apply(Extent extent, Vector get, Vector set) throws WorldEditException; + boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java index 73e19e91f..372a8cf2d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java @@ -1,19 +1,15 @@ package com.sk89q.worldedit.function.pattern; -<<<<<<< HEAD import com.boydti.fawe.object.collection.RandomCollection; import com.boydti.fawe.object.random.SimpleRandom; import com.boydti.fawe.object.random.TrueRandom; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.HashMap; @@ -60,24 +56,24 @@ public class RandomPattern extends AbstractPattern { this.patterns.add(pattern); } -<<<<<<< HEAD +//<<<<<<< HEAD public Set getPatterns() { return patterns; -======= - @Override - public BlockStateHolder apply(BlockVector3 position) { - double r = random.nextDouble(); - double offset = 0; - - for (Chance chance : patterns) { - if (r <= (offset + chance.getChance()) / max) { - return chance.getPattern().apply(position); - } - offset += chance.getChance(); - } - - throw new RuntimeException("ProportionalFillPattern"); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// @Override +// public BlockStateHolder apply(BlockVector3 position) { +// double r = random.nextDouble(); +// double offset = 0; +// +// for (Chance chance : patterns) { +// if (r <= (offset + chance.getChance()) / max) { +// return chance.getPattern().apply(position); +// } +// offset += chance.getChance(); +// } +// +// throw new RuntimeException("ProportionalFillPattern"); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } public RandomCollection getCollection() { @@ -85,12 +81,12 @@ public class RandomPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(Vector get) { + public BlockStateHolder apply(BlockVector3 get) { return collection.next(get.getBlockX(), get.getBlockY(), get.getBlockZ()).apply(get); } @Override - public boolean apply(Extent extent, Vector set, Vector get) throws WorldEditException { + public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException { return collection.next(get.getBlockX(), get.getBlockY(), get.getBlockZ()).apply(extent, set, get); } 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 2f987d602..87f7a2fb4 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 @@ -19,14 +19,10 @@ package com.sk89q.worldedit.function.pattern; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; @@ -97,10 +93,10 @@ 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)); -======= +//<<<<<<< HEAD +// return extent.getBlock(new Vector(x, y, z)); +//======= return extent.getFullBlock(new BlockVector3(x, y, z)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java index 544c79405..8c83568c0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function.util; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.math.BlockVector2; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java index b30cd00d2..7d618f712 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function.util; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector3; 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 10b8a6a1f..cad3e5bb7 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 MutableBlockVector(0, -1, 0)); - DEFAULT_DIRECTIONS[1] = (new MutableBlockVector(0, 1, 0)); - DEFAULT_DIRECTIONS[2] = (new MutableBlockVector(-1, 0, 0)); - DEFAULT_DIRECTIONS[3] = (new MutableBlockVector(1, 0, 0)); - DEFAULT_DIRECTIONS[4] = (new MutableBlockVector(0, 0, -1)); - DEFAULT_DIRECTIONS[5] = (new MutableBlockVector(0, 0, 1)); - List list = new ArrayList<>(); + 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)); + 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) { - MutableBlockVector pos = new MutableBlockVector(x, y, z); + BlockVector3 pos = new BlockVector3(x, y, z); if (!list.contains(pos)) { list.add(pos); } @@ -184,7 +184,7 @@ public abstract class BreadthFirstSearch implements Operation { @Override public Operation resume(RunContext run) throws WorldEditException { MutableBlockVector mutable = new MutableBlockVector(); - MutableBlockVector mutable2 = new MutableBlockVector(); +// MutableBlockVector mutable2 = new MutableBlockVector(); boolean shouldTrim = false; IntegerTrio[] dirs = getIntDirections(); BlockVectorSet tempQueue = new BlockVectorSet(); @@ -223,10 +223,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)) { - mutable2.mutX(x); - mutable2.mutY(y); - mutable2.mutZ(z); - if (isVisitable(from, mutable2)) { + if (isVisitable(from, new BlockVector3(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 7aa209756..f74c7c4ae 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 @@ -50,7 +50,7 @@ public class DirectionalVisitor extends RecursiveVisitor { super(mask, function, distance, hasFaweQueue); checkNotNull(mask); this.origin = origin; - this.dirVec = new MutableBlockVector(direction); + this.dirVec = direction; final Collection directions = this.getDirections(); directions.clear(); directions.add(new BlockVector3(1, 0, 0)); 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 a902c2ba2..17f7f3769 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 @@ -19,19 +19,15 @@ package com.sk89q.worldedit.function.visitor; -<<<<<<< HEAD import com.boydti.fawe.object.HasFaweQueue; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import java.util.Collection; @@ -63,12 +59,8 @@ public class DownwardVisitor extends RecursiveVisitor { super(mask, function, depth, hasFaweQueue); checkNotNull(mask); this.baseY = baseY; -<<<<<<< HEAD - final Collection directions = this.getDirections(); -======= Collection directions = getDirections(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner directions.clear(); directions.add(new BlockVector3(1, 0, 0)); directions.add(new BlockVector3(-1, 0, 0)); @@ -78,15 +70,9 @@ public class DownwardVisitor extends RecursiveVisitor { } @Override -<<<<<<< HEAD - public boolean isVisitable(final Vector from, final Vector to) { - final int fromY = from.getBlockY(); - return ((fromY == this.baseY) || (to.getBlockY() - from.getBlockY() < 0)) && super.isVisitable(from, to); -======= protected boolean isVisitable(BlockVector3 from, BlockVector3 to) { int fromY = from.getBlockY(); return (fromY == baseY || to.subtract(from).getBlockY() < 0) && super.isVisitable(from, to); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java index 82777b06e..5d86ad0c9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java @@ -19,23 +19,20 @@ package com.sk89q.worldedit.function.visitor; -<<<<<<< HEAD import com.boydti.fawe.config.BBC; import com.boydti.fawe.example.MappedFaweQueue; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.object.visitor.Fast2DIterator; -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.regions.FlatRegion; import java.util.List; @@ -50,7 +47,7 @@ public class FlatRegionVisitor implements Operation { private final FlatRegionFunction function; private MappedFaweQueue queue; private int affected = 0; - private final Iterable iterator; + private final Iterable iterator; /** * Create a new visitor. @@ -84,21 +81,21 @@ public class FlatRegionVisitor implements Operation { } @Override -<<<<<<< HEAD +//<<<<<<< HEAD public Operation resume(final RunContext run) throws WorldEditException { if (this.queue != null) { - for (final Vector2D pt : new Fast2DIterator(this.iterator, queue)) { + for (final BlockVector2 pt : new Fast2DIterator(this.iterator, queue)) { if (this.function.apply(pt)) affected++; } } else { - for (final Vector2D pt : this.iterator) { + for (final BlockVector2 pt : this.iterator) { if (this.function.apply(pt)) affected++; -======= - public Operation resume(RunContext run) throws WorldEditException { - for (BlockVector2 pt : flatRegion.asFlatRegion()) { - if (function.apply(pt)) { - affected++; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// public Operation resume(RunContext run) throws WorldEditException { +// for (BlockVector2 pt : flatRegion.asFlatRegion()) { +// if (function.apply(pt)) { +// affected++; +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } return null; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/IntersectRegionFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/IntersectRegionFunction.java index b08c4a223..8d0f5ea10 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/IntersectRegionFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/IntersectRegionFunction.java @@ -1,8 +1,8 @@ package com.sk89q.worldedit.function.visitor; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; +import com.sk89q.worldedit.math.BlockVector3; public class IntersectRegionFunction implements RegionFunction { private final RegionFunction[] functions; @@ -13,7 +13,7 @@ public class IntersectRegionFunction implements RegionFunction { @Override - public boolean apply(Vector position) throws WorldEditException { + public boolean apply(BlockVector3 position) throws WorldEditException { boolean ret = false; for (RegionFunction function : functions) { if (!function.apply(position)) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java index de59b9ccf..7293d2b26 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java @@ -19,14 +19,9 @@ package com.sk89q.worldedit.function.visitor; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.LayerFunction; import com.sk89q.worldedit.function.mask.Mask2D; @@ -58,7 +53,7 @@ public class LayerVisitor implements Operation { private Mask2D mask = Masks.alwaysTrue2D(); private final int minY; private final int maxY; - private final Iterable iterator; + private final Iterable iterator; /** * Create a new visitor. @@ -100,36 +95,21 @@ public class LayerVisitor implements Operation { } @Override -<<<<<<< HEAD public Operation resume(final RunContext run) throws WorldEditException { - for (final Vector2D column : this.iterator) { + for (final BlockVector2 column : this.iterator) { if (!this.mask.test(column)) { -======= - public Operation resume(RunContext run) throws WorldEditException { - for (BlockVector2 column : flatRegion.asFlatRegion()) { - if (!mask.test(column)) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner continue; } // Abort if we are underground -<<<<<<< HEAD - if (this.function.isGround(column.toVector(this.maxY + 1))) { -======= if (function.isGround(column.toBlockVector3(maxY + 1))) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner return null; } boolean found = false; int groundY = 0; -<<<<<<< HEAD - for (int y = this.maxY; y >= this.minY; --y) { - final Vector test = column.toVector(y); -======= for (int y = maxY; y >= minY; --y) { BlockVector3 test = column.toBlockVector3(y); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (!found) { if (this.function.isGround(test)) { found = true; 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 268467a54..5acf895a2 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 @@ -19,17 +19,13 @@ package com.sk89q.worldedit.function.visitor; -<<<<<<< HEAD import com.boydti.fawe.object.HasFaweQueue; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; -======= import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import java.util.Collection; /** @@ -45,17 +41,12 @@ public class NonRisingVisitor extends RecursiveVisitor { */ public NonRisingVisitor(Mask mask, RegionFunction function) { -<<<<<<< HEAD this(mask, function, Integer.MAX_VALUE, null); } public NonRisingVisitor(Mask mask, RegionFunction function, int depth, HasFaweQueue hasFaweQueue) { super(mask, function, depth, hasFaweQueue); - final Collection directions = this.getDirections(); -======= - super(mask, function); Collection directions = getDirections(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner directions.clear(); directions.add(new BlockVector3(1, 0, 0)); directions.add(new BlockVector3(-1, 0, 0)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java index f0ee91a36..be44fb32b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.function.visitor; -<<<<<<< HEAD import com.boydti.fawe.object.HasFaweQueue; -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; @@ -62,13 +58,8 @@ public class RecursiveVisitor extends BreadthFirstSearch { } @Override -<<<<<<< HEAD - public boolean isVisitable(final Vector from, final Vector to) { - return this.mask.test(to); -======= protected boolean isVisitable(BlockVector3 from, BlockVector3 to) { return mask.test(to); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java index 7b1c32c9a..c03cb93e6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java @@ -19,24 +19,15 @@ package com.sk89q.worldedit.history.change; -<<<<<<< HEAD -import com.sk89q.worldedit.BlockVector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.history.UndoContext; -<<<<<<< HEAD - -import static com.google.common.base.Preconditions.checkNotNull; -======= import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner /** * Represents a block change that may be undone or replayed. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java index fd537fde8..10ba092a3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java @@ -22,13 +22,9 @@ package com.sk89q.worldedit.internal.command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.Logging; -<<<<<<< HEAD -import com.sk89q.worldedit.*; -======= import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.math.Vector3; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java index 27e2461c7..e1692338a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java @@ -28,11 +28,8 @@ import com.sk89q.worldedit.PlayerDirection; import com.sk89q.worldedit.UnknownDirectionException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; -<<<<<<< HEAD import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -======= ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.NoMatchException; @@ -56,7 +53,6 @@ import com.sk89q.worldedit.util.command.parametric.ParameterException; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.Biomes; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -310,17 +306,10 @@ public class WorldEditBinding extends BindingHelper { * @throws UnknownDirectionException on an unknown direction */ @BindingMatch(classifier = Direction.class, -<<<<<<< HEAD - type = Vector.class, - behavior = BindingBehavior.CONSUMES, - consumedCount = 1) - public Vector getDirection(ArgumentStack context, Direction direction) -======= type = BlockVector3.class, behavior = BindingBehavior.CONSUMES, consumedCount = 1) public BlockVector3 getDirection(ArgumentStack context, Direction direction) ->>>>>>> 399e0ad5... Refactor vector system to be cleaner throws ParameterException, UnknownDirectionException { Player sender = getPlayer(context); return worldEdit.getDirection(sender, context.next()); 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 87191eed9..e685c7fe3 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 @@ -19,12 +19,8 @@ package com.sk89q.worldedit.internal.expression.runtime; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -======= ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.runtime.Function.Dynamic; import com.sk89q.worldedit.math.Vector3; 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 4aead808c..bb3093e47 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 @@ -1,10 +1,21 @@ package com.sk89q.worldedit.math; import com.boydti.fawe.util.MathMan; +import com.google.common.collect.ComparisonChain; +import com.sk89q.worldedit.math.transform.AffineTransform; + +import static com.google.common.base.Preconditions.checkArgument; + import java.io.IOException; import java.io.Serializable; +import java.util.Comparator; -public class MutableBlockVector extends BlockVector3 implements Serializable { +/** + * A mutable rendition of WorldEdit's BlockVector3 class. + * This class should ONLY be used locally for efficient vector manipulation. + */ + +public class MutableBlockVector implements Serializable { private transient int x, y, z; private static ThreadLocal MUTABLE_CACHE = new ThreadLocal() { @@ -23,26 +34,50 @@ public class MutableBlockVector extends BlockVector3 implements Serializable { } public MutableBlockVector(int x, int y, int z) { - super(0, 0, 0); this.x = x; this.y = y; this.z = z; } public MutableBlockVector() { - super(0, 0, 0); + this(0, 0, 0); + } + + public static final MutableBlockVector ZERO = new MutableBlockVector(0, 0, 0); + public static final MutableBlockVector UNIT_X = new MutableBlockVector(1, 0, 0); + public static final MutableBlockVector UNIT_Y = new MutableBlockVector(0, 1, 0); + public static final MutableBlockVector UNIT_Z = new MutableBlockVector(0, 0, 1); + public static final MutableBlockVector ONE = new MutableBlockVector(1, 1, 1); + + // thread-safe initialization idiom + private static final class YzxOrderComparator { + private static final Comparator YZX_ORDER = (a, b) -> { + return ComparisonChain.start() + .compare(a.y, b.y) + .compare(a.z, b.z) + .compare(a.x, b.x) + .result(); + }; + } + + /** + * Returns a comparator that sorts vectors first by Y, then Z, then X. + * + *

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

Components < 0.5 are rounded down, otherwise up.

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

Components < 0.5 are rounded down, otherwise up.

+ * + * @return a new vector + */ + public MutableBlockVector2D round() { + // already rounded, kept for feature parity with Vector2 + return this; + } + + /** + * Returns a vector with the absolute values of the components of + * this vector. + * + * @return a new vector + */ + public MutableBlockVector2D abs() { + x = Math.abs(x); + z = Math.abs(z); + return this; + } + + /** + * Perform a 2D transformation on this vector. + * + * @param angle in degrees + * @param aboutX about which x coordinate to rotate + * @param aboutZ about which z coordinate to rotate + * @param translateX what to add after rotation + * @param translateZ what to add after rotation + * @return a new vector + * @see AffineTransform another method to transform vectors + */ + public MutableBlockVector2D transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { + angle = Math.toRadians(angle); + double x = this.x - aboutX; + double z = this.z - aboutZ; + double cos = Math.cos(angle); + double sin = Math.sin(angle); + double x2 = x * cos - z * sin; + double z2 = x * sin + z * cos; + this.x = (int) Math.floor(x2 + aboutX + translateX); + this.z = (int) Math.floor(z2 + aboutZ + translateZ); + return this; + } + + /** + * Gets the minimum components of two vectors. + * + * @param v2 the second vector + * @return minimum + */ + public MutableBlockVector2D getMinimum(MutableBlockVector2D v2) { + x = Math.min(x, v2.x); + z = Math.min(z, v2.z); + return this; + } + + /** + * Gets the maximum components of two vectors. + * + * @param v2 the second vector + * @return maximum + */ + public MutableBlockVector2D getMaximum(MutableBlockVector2D v2) { + x = Math.max(x, v2.x); + z = Math.max(z, v2.z); + return this; + } + + /** + * Creates a 2D vector from this vector. + * + * @return a new vector + */ + public Vector2 toVector2() { + return new Vector2(x, z); + } + + /** + * Creates a 3D vector by adding a zero Y component to this vector. + * + * @return a new vector + */ + public Vector3 toVector3() { + return toVector3(0); + } + + /** + * Creates a 3D vector by adding the specified Y component to this vector. + * + * @param y the Y component + * @return a new vector + */ + public Vector3 toVector3(double y) { + return new Vector3(x, y, z); + } + + /** + * Creates a 3D vector by adding a zero Y component to this vector. + * + * @return a new vector + */ + public BlockVector3 toBlockVector3() { + return toBlockVector3(0); + } + + /** + * Creates a 3D vector by adding the specified Y component to this vector. + * + * @param y the Y component + * @return a new vector + */ + public BlockVector3 toBlockVector3(int y) { + return new BlockVector3(x, y, z); + } + + /** + * Creates a 2D vector from this vector. + * + * @return a new vector + */ + public BlockVector2 toBlockVector2() { + return new BlockVector2(x, z); } @Override - public int getBlockZ() { - return z; + public boolean equals(Object obj) { + if (!(obj instanceof MutableBlockVector2D)) { + return false; + } + + MutableBlockVector2D other = (MutableBlockVector2D) obj; + return other.x == this.x && other.z == this.z; + + } + + @Override + public int hashCode() { + int hash = 17; + hash = 31 * hash + Integer.hashCode(x); + hash = 31 * hash + Integer.hashCode(z); + return hash; + } + + @Override + public String toString() { + return "Mutable (" + x + ", " + z + ")"; } public MutableBlockVector2D setComponents(int x, int z) { 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 77d1b0175..df952ed71 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 @@ -1,10 +1,18 @@ package com.sk89q.worldedit.math; -import com.boydti.fawe.util.MathMan; +import com.sk89q.worldedit.math.transform.AffineTransform; + +import static com.google.common.base.Preconditions.checkArgument; + import java.io.IOException; import java.io.Serializable; -public class MutableVector extends Vector3 implements Serializable { +/** + * A mutable rendition of WorldEdit's Vector3 class. + * This class should ONLY be used locally for efficient vector manipulation. + */ + +public class MutableVector implements Serializable { private transient double x, y, z; private static ThreadLocal MUTABLE_CACHE = new ThreadLocal() { @@ -14,7 +22,7 @@ public class MutableVector extends Vector3 implements Serializable { } }; - public static MutableVector get(int x, int y, int z) { + public static MutableVector get(double x, double y, double z) { return MUTABLE_CACHE.get().setComponents(x, y, z); } @@ -23,26 +31,27 @@ public class MutableVector extends Vector3 implements Serializable { } public MutableVector(double x, double y, double z) { - super(0, 0, 0); this.x = x; this.y = y; this.z = z; } public MutableVector() { - super(0, 0, 0); + this(0, 0, 0); } - public MutableVector setComponents(BlockVector3 other) { - return setComponents(other.getBlockX(), other.getBlockY(), other.getBlockZ()); + public MutableVector setComponents(Vector3 other) { + return setComponents(other.getX(), other.getY(), other.getZ()); + } + + public MutableVector setComponents(MutableVector mutable) { + return setComponents(mutable.getX(), mutable.getY(), mutable.getZ()); } -// @Override public MutableVector setComponents(int x, int y, int z) { return this.setComponents((double) x, (double) y, (double) z); } -// @Override public MutableVector setComponents(double x, double y, double z) { this.mutX(x); this.mutY(y); @@ -50,50 +59,513 @@ public class MutableVector extends Vector3 implements Serializable { return this; } -// @Override public final void mutX(double x) { this.x = y; } -// @Override public final void mutY(double y) { - this.y =y; + this.y = y; } -// @Override public final void mutZ(double z) { this.z = y; } -// @Override public final void mutX(int x) { this.x = (double)x; } -// @Override public final void mutY(int y) { this.y = (double)y; } -// @Override public final void mutZ(int z) { this.z = (double)z; } - @Override public final double getX() { return x; } - @Override public final double getY() { return y; } - @Override public final double getZ() { return z; } + + /** + * Add another vector to this vector and return the result as a new vector. + * + * @param other the other vector + * @return a new vector + */ + public MutableVector add(MutableVector other) { + return add(other.x, other.y, other.z); + } + + /** + * Add another vector to this vector and return the result as a new vector. + * + * @param x the value to add + * @param y the value to add + * @param z the value to add + * @return a new vector + */ + public MutableVector add(double x, double y, double z) { + this.x += x; + this.y += y; + this.z += z; + return this; + } + + /** + * Add a list of vectors to this vector and return the + * result as a new vector. + * + * @param others an array of vectors + * @return a new vector + */ + public MutableVector add(MutableVector... others) { + + for (MutableVector other : others) { + x += other.x; + y += other.y; + z += other.z; + } + + return this; + } + + /** + * Subtract another vector from this vector and return the result + * as a new vector. + * + * @param other the other vector + * @return a new vector + */ + public MutableVector subtract(MutableVector other) { + return subtract(other.x, other.y, other.z); + } + + /** + * Subtract another vector from this vector and return the result + * as a new vector. + * + * @param x the value to subtract + * @param y the value to subtract + * @param z the value to subtract + * @return a new vector + */ + public MutableVector subtract(double x, double y, double z) { + this.x -= x; + this.y -= y; + this.z -= z; + return this; + } + + /** + * Subtract a list of vectors from this vector and return the result + * as a new vector. + * + * @param others an array of vectors + * @return a new vector + */ + public MutableVector subtract(MutableVector... others) { + + for (MutableVector other : others) { + x -= other.x; + y -= other.y; + z -= other.z; + } + + return this; + } + + /** + * Multiply this vector by another vector on each component. + * + * @param other the other vector + * @return a new vector + */ + public MutableVector multiply(MutableVector other) { + return multiply(other.x, other.y, other.z); + } + + /** + * Multiply this vector by another vector on each component. + * + * @param x the value to multiply + * @param y the value to multiply + * @param z the value to multiply + * @return a new vector + */ + public MutableVector multiply(double x, double y, double z) { + this.x *= x; + this.y *= y; + this.z *= z; + return this; + } + + /** + * Multiply this vector by zero or more vectors on each component. + * + * @param others an array of vectors + * @return a new vector + */ + public MutableVector multiply(MutableVector... others) { + + for (MutableVector other : others) { + x *= other.x; + y *= other.y; + z *= other.z; + } + + return this; + } + + /** + * Perform scalar multiplication and return a new vector. + * + * @param n the value to multiply + * @return a new vector + */ + public MutableVector multiply(double n) { + return multiply(n, n, n); + } + + /** + * Divide this vector by another vector on each component. + * + * @param other the other vector + * @return a new vector + */ + public MutableVector divide(MutableVector other) { + return divide(other.x, other.y, other.z); + } + + /** + * Divide this vector by another vector on each component. + * + * @param x the value to divide by + * @param y the value to divide by + * @param z the value to divide by + * @return a new vector + */ + public MutableVector divide(double x, double y, double z) { + this.x /= x; + this.y /= y; + this.z /= z; + return this; + } + + /** + * Perform scalar division and return a new vector. + * + * @param n the value to divide by + * @return a new vector + */ + public MutableVector divide(double n) { + return divide(n, n, n); + } + + /** + * Get the length of the vector. + * + * @return length + */ + public double length() { + return Math.sqrt(lengthSq()); + } + + /** + * Get the length, squared, of the vector. + * + * @return length, squared + */ + public double lengthSq() { + return x * x + y * y + z * z; + } + + /** + * Get the distance between this vector and another vector. + * + * @param other the other vector + * @return distance + */ + public double distance(Vector3 other) { + return Math.sqrt(distanceSq(other)); + } + + /** + * Get the distance between this vector and another vector, squared. + * + * @param other the other vector + * @return distance + */ + public double distanceSq(Vector3 other) { + double dx = other.getX() - x; + double dy = other.getY() - y; + double dz = other.getZ() - z; + return dx * dx + dy * dy + dz * dz; + } + + /** + * Get the normalized vector, which is the vector divided by its + * length, as a new vector. + * + * @return a new vector + */ + public MutableVector normalize() { + return divide(length()); + } + + /** + * Gets the dot product of this and another vector. + * + * @param other the other vector + * @return the dot product of this and the other vector + */ + public double dot(MutableVector other) { + return x * other.x + y * other.y + z * other.z; + } + + /** + * Gets the cross product of this and another vector. + * + * @param other the other vector + * @return the cross product of this and the other vector + */ + public Vector3 cross(MutableVector other) { + return new Vector3( + y * other.z - z * other.y, + z * other.x - x * other.z, + x * other.y - y * other.x + ); + } + + /** + * Checks to see if a vector is contained with another. + * + * @param min the minimum point (X, Y, and Z are the lowest) + * @param max the maximum point (X, Y, and Z are the lowest) + * @return true if the vector is contained + */ + public boolean containedWithin(MutableVector min, MutableVector max) { + return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z; + } + + /** + * Clamp the Y component. + * + * @param min the minimum value + * @param max the maximum value + * @return a new vector + */ + public MutableVector clampY(int min, int max) { + checkArgument(min <= max, "minimum cannot be greater than maximum"); + if (y < min) { + y = min; + } + if (y > max) { + y = max; + } + return this; + } + + /** + * Floors the values of all components. + * + * @return a new vector + */ + public MutableVector floor() { + x = Math.floor(x); + y = Math.floor(y); + z = Math.floor(z); + return this; + } + + /** + * Rounds all components up. + * + * @return a new vector + */ + public MutableVector ceil() { + x = Math.ceil(x); + y = Math.ceil(y); + z = Math.ceil(z); + return this; + } + + /** + * Rounds all components to the closest integer. + * + *

Components < 0.5 are rounded down, otherwise up.

+ * + * @return a new vector + */ + public MutableVector round() { + x = Math.floor(x + 0.5); + y = Math.floor(y + 0.5); + z = Math.floor(z + 0.5); + return this; + } + + /** + * Returns a vector with the absolute values of the components of + * this vector. + * + * @return a new vector + */ + public MutableVector abs() { + x = Math.abs(x); + y = Math.abs(y); + z = Math.abs(z); + return this; + } + + /** + * Perform a 2D transformation on this vector and return a new one. + * + * @param angle in degrees + * @param aboutX about which x coordinate to rotate + * @param aboutZ about which z coordinate to rotate + * @param translateX what to add after rotation + * @param translateZ what to add after rotation + * @return a new vector + * @see AffineTransform another method to transform vectors + */ + public MutableVector transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { + angle = Math.toRadians(angle); + double x = this.x - aboutX; + double z = this.z - aboutZ; + double cos = Math.cos(angle); + double sin = Math.sin(angle); + double x2 = x * cos - z * sin; + double z2 = x * sin + z * cos; + this.x = x2 + aboutX + translateX; + this.z = z2 + aboutZ + translateZ; + return this; + } + + /** + * Get this vector's pitch as used within the game. + * + * @return pitch in radians + */ + public double toPitch() { + double x = getX(); + double z = getZ(); + + if (x == 0 && z == 0) { + return getY() > 0 ? -90 : 90; + } else { + double x2 = x * x; + double z2 = z * z; + double xz = Math.sqrt(x2 + z2); + return Math.toDegrees(Math.atan(-getY() / xz)); + } + } + + /** + * Get this vector's yaw as used within the game. + * + * @return yaw in radians + */ + public double toYaw() { + double x = getX(); + double z = getZ(); + + double t = Math.atan2(-x, z); + double tau = 2 * Math.PI; + + return Math.toDegrees(((t + tau) % tau)); + } + + /** + * Gets the minimum components of two vectors. + * + * @param v2 the second vector + * @return minimum + */ + public MutableVector getMinimum(MutableVector v2) { + x = Math.min(x, v2.x); + y = Math.min(y, v2.y); + z = Math.min(z, v2.z); + return this; + } + + /** + * Gets the maximum components of two vectors. + * + * @param v2 the second vector + * @return maximum + */ + public MutableVector getMaximum(MutableVector v2) { + x = Math.max(x, v2.x); + y = Math.max(y, v2.y); + z = Math.max(z, v2.z); + return this; + } + + /** + * Create a new {@code BlockVector} using the given components. + * + * @param x the X coordinate + * @param y the Y coordinate + * @param z the Z coordinate + * @return a new {@code BlockVector} + */ + public static BlockVector3 toBlockPoint(double x, double y, double z) { + return new BlockVector3(x, y, z); + } + + /** + * Create a new {@code BlockVector} from this vector. + * + * @return a new {@code BlockVector} + */ + public BlockVector3 toBlockPoint() { + return toBlockPoint(x, y, z); + } + + /** + * Creates a 2D vector by dropping the Y component from this vector. + * + * @return a new {@link Vector2} + */ + public Vector2 toVector2() { + return new Vector2(x, z); + } + + public Vector3 toVector3() { + return new Vector3(x, y, z); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof MutableVector)) { + return false; + } + + MutableVector other = (MutableVector) obj; + return other.x == this.x && other.y == this.y && other.z == this.z; + } + + @Override + public int hashCode() { + int hash = 17; + hash = 31 * hash + Double.hashCode(x); + hash = 31 * hash + Double.hashCode(y); + hash = 31 * hash + Double.hashCode(z); + return hash; + } + + @Override + public String toString() { + return "Mutable (" + x + ", " + y + ", " + z + ")"; + } private void writeObject(java.io.ObjectOutputStream stream) throws IOException { stream.writeDouble(x); 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 1bb3fd1ad..46581b271 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 @@ -3,15 +3,10 @@ package com.sk89q.worldedit.math.convolution; import com.boydti.fawe.object.visitor.Fast2DIterator; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -<<<<<<< HEAD -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.blocks.BaseBlock; -======= +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Regions; @@ -74,16 +69,15 @@ public class HeightMap { invalid = new boolean[data.length]; if (layers) { - Vector min = region.getMinimumPoint(); - Vector max = region.getMaximumPoint(); + BlockVector3 min = region.getMinimumPoint(); + BlockVector3 max = region.getMaximumPoint(); int bx = min.getBlockX(); int bz = min.getBlockZ(); - Iterable flat = Regions.asFlatRegion(region).asFlatRegion(); - Iterator iter = new Fast2DIterator(flat, session).iterator(); + Iterable flat = Regions.asFlatRegion(region).asFlatRegion(); + Iterator iter = new Fast2DIterator(flat, session).iterator(); int layer = 0; - MutableBlockVector mutable = new MutableBlockVector(); while (iter.hasNext()) { - Vector2D pos = iter.next(); + BlockVector2 pos = iter.next(); int x = pos.getBlockX(); int z = pos.getBlockZ(); layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY); @@ -186,7 +180,7 @@ public class HeightMap { // Depending on growing or shrinking we need to start at the bottom or top if (newHeight > curHeight) { // Set the top block of the column to be the same type (this might go wrong with rounding) -<<<<<<< HEAD +//<<<<<<< HEAD BlockStateHolder existing = session.getBlock(xr, curBlock, zr); // Skip water/lava @@ -206,33 +200,33 @@ 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)); - - // Skip water/lava - if (existing.getBlockType() != BlockTypes.WATER && existing.getBlockType() != BlockTypes.LAVA) { - session.setBlock(new BlockVector3(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 +//======= +// BlockState existing = session.getBlock(new BlockVector3(xr, curHeight, zr)); +// +// // Skip water/lava +// if (existing.getBlockType() != BlockTypes.WATER && existing.getBlockType() != BlockTypes.LAVA) { +// session.setBlock(new BlockVector3(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 ++blocksChanged; } } } else if (curHeight > newHeight) { -<<<<<<< HEAD +//<<<<<<< HEAD // Fill rest with air for (int y = newBlock + 1; y <= ((curHeight + 15) >> 4); ++y) { session.setBlock(xr, y, zr, fillerAir); -======= - // 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 +//======= +// // 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 ++blocksChanged; } // Set the top block of the column to be the same type @@ -256,7 +250,7 @@ public class HeightMap { public int apply(int[] data) throws MaxChangedBlocksException { checkNotNull(data); - Vector minY = region.getMinimumPoint(); + BlockVector3 minY = region.getMinimumPoint(); int originX = minY.getBlockX(); int originY = minY.getBlockY(); int originZ = minY.getBlockZ(); @@ -300,20 +294,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) -<<<<<<< HEAD session.setBlock(xr, newHeight, zr, session.getBlock(xr, curHeight, zr)); -======= - session.setBlock(new BlockVector3(xr, newHeight, zr), session.getBlock(new BlockVector3(xr, curHeight, zr))); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner ++blocksChanged; // Fill rest with air for (int y = newHeight + 1; y <= curHeight; ++y) { -<<<<<<< HEAD session.setBlock(xr, y, zr, fillerAir); -======= - session.setBlock(new BlockVector3(xr, y, zr), fillerAir); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner ++blocksChanged; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java index 795a5bcf9..d4818004e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java @@ -21,13 +21,9 @@ package com.sk89q.worldedit.math.interpolation; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import java.util.List; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java index b99ddbce5..8e3c0b24d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java @@ -21,13 +21,9 @@ package com.sk89q.worldedit.math.interpolation; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import java.util.List; import java.util.Map.Entry; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java index fcb752d53..ca33d9444 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.math.transform; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import java.util.ArrayList; import java.util.Arrays; 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 08ebbbb41..ccd9ea3d1 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 @@ -1,11 +1,11 @@ package com.sk89q.worldedit.math.transform; -import com.sk89q.worldedit.MutableBlockVector; -import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; public class RoundedTransform implements Transform{ private final Transform transform; - private MutableBlockVector mutable = new MutableBlockVector(); +// private MutableBlockVector mutable = new MutableBlockVector(); public RoundedTransform(Transform transform) { this.transform = transform; @@ -17,12 +17,12 @@ public class RoundedTransform implements Transform{ } @Override - public Vector apply(Vector input) { - Vector val = transform.apply(input); - 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 mutable; + public Vector3 apply(Vector3 input) { + Vector3 val = transform.apply(input); +// 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)); } @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 8b0b84350..b56d58ebf 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 @@ -19,14 +19,10 @@ package com.sk89q.worldedit.regions; -<<<<<<< HEAD import com.sk89q.worldedit.*; -import com.sk89q.worldedit.Vector; -======= import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.regions.iterator.RegionIterator; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.ChunkStore; 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 e2b3b92c4..aa645a0d4 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 @@ -329,7 +329,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public BlockVector2 next() { - BlockVector2 result = pos; + MutableBlockVector2D result = pos; // calc next pos.setComponents(pos.getX() - 1, pos.getZ()); if (pos.getX() <= minX) { @@ -339,7 +339,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { pos.setComponents(maxX, pos.getZ() - 1); } } - return result; + return result.toBlockVector2(); } @Override @@ -484,7 +484,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { x = tx; y = ty; hasNext = false; - return mutable; + return mutable.toBlockVector3(); } } else { z = cbz; @@ -503,7 +503,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { x = cbx; } } - return mutable; + return mutable.toBlockVector3(); } }; } @@ -549,7 +549,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } } } - return mutable; + return mutable.toBlockVector3(); } }; } @@ -574,7 +574,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public BlockVector2 next() { if (!hasNext()) throw new java.util.NoSuchElementException(); - BlockVector2 answer = mutable.setComponents(nextX, nextZ); +// BlockVector2 answer = mutable.setComponents(nextX, nextZ); + BlockVector2 answer = new BlockVector2(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 a7408266e..e2a1b1028 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 @@ -19,15 +19,8 @@ package com.sk89q.worldedit.regions; -<<<<<<< HEAD -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.BlockVector2D; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector2; @@ -48,14 +41,9 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class CylinderRegion extends AbstractRegion implements FlatRegion { -<<<<<<< HEAD - private BlockVector2D center; - private BlockVector2D radius; - private Vector2D radiusInverse; -======= private BlockVector2 center; private Vector2 radius; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + private Vector2 radiusInverse; private int minY; private int maxY; private boolean hasY = false; @@ -117,24 +105,9 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { hasY = region.hasY; } - @Override -<<<<<<< HEAD - public Vector getCenter() { - return center.toVector((getMaximumY() + getMinimumY()) / 2); - } - - /** - * Sets the main center point of the region - * - * @deprecated replaced by {@link #setCenter(Vector2D)} - */ - @Deprecated - public void setCenter(Vector center) { - setCenter(center.toVector2D()); -======= + @Override public Vector3 getCenter() { return center.toVector3((maxY + minY) / 2); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } /** @@ -142,13 +115,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { * * @param center the center point */ -<<<<<<< HEAD - public void setCenter(Vector2D center) { - this.center = new BlockVector2D(center); -======= public void setCenter(BlockVector2 center) { this.center = center; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } /** @@ -165,14 +133,9 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { * * @param radius the radius along the X and Z axes */ -<<<<<<< HEAD - public void setRadius(Vector2D radius) { - this.radius = radius.add(0.5, 0.5).toBlockVector2D(); - this.radiusInverse = Vector2D.ONE.divide(radius); -======= public void setRadius(Vector2 radius) { this.radius = radius.add(0.5, 0.5); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + this.radiusInverse = Vector2.ONE.divide(radius); } /** @@ -203,17 +166,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { hasY = true; maxY = y; } - + @Override -<<<<<<< HEAD - public Vector getMinimumPoint() { - return center.subtract(getRadius()).toVector(getMinimumY()); - } - - @Override - public Vector getMaximumPoint() { - return center.add(getRadius()).toVector(getMaximumY()); -======= public BlockVector3 getMinimumPoint() { return center.toVector2().subtract(getRadius()).toVector3(minY).toBlockPoint(); } @@ -221,7 +175,6 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { @Override public BlockVector3 getMaximumPoint() { return center.toVector2().add(getRadius()).toVector3(maxY).toBlockPoint(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Override @@ -291,18 +244,11 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { * @throws RegionOperationException */ @Override -<<<<<<< HEAD - public void expand(Vector... changes) throws RegionOperationException { - center = center.add(calculateDiff2D(changes)).toBlockVector2D(); - radius = radius.add(calculateChanges2D(changes)).toBlockVector2D(); - this.radiusInverse = Vector2D.ONE.divide(radius); - for (Vector change : changes) { -======= public void expand(BlockVector3... changes) throws RegionOperationException { center = center.add(calculateDiff2D(changes)); radius = radius.add(calculateChanges2D(changes).toVector2()); + this.radiusInverse = Vector2.ONE.divide(radius); for (BlockVector3 change : changes) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int changeY = change.getBlockY(); if (changeY > 0) { maxY += changeY; @@ -319,20 +265,12 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { * @throws RegionOperationException */ @Override -<<<<<<< HEAD - public void contract(Vector... changes) throws RegionOperationException { - center = center.subtract(calculateDiff2D(changes)).toBlockVector2D(); - Vector2D newRadius = radius.subtract(calculateChanges2D(changes)); - radius = Vector2D.getMaximum(new Vector2D(1.5, 1.5), newRadius).toBlockVector2D(); - this.radiusInverse = Vector2D.ONE.divide(radius); - for (Vector change : changes) { -======= 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); + this.radiusInverse = Vector2.ONE.divide(radius); for (BlockVector3 change : changes) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int height = maxY - minY; int changeY = change.getBlockY(); if (changeY > 0) { @@ -344,13 +282,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { } @Override -<<<<<<< HEAD - public void shift(Vector change) throws RegionOperationException { - center = center.add(change.toVector2D()).toBlockVector2D(); -======= public void shift(BlockVector3 change) throws RegionOperationException { center = center.add(change.toBlockVector2()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int changeY = change.getBlockY(); maxY += changeY; @@ -361,15 +294,9 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { * Checks to see if a point is inside this region. */ @Override -<<<<<<< HEAD - public boolean contains(Vector position) { - final int pt = position.getBlockY(); - if (pt < getMinimumY() || pt > getMaximumY()) { -======= public boolean contains(BlockVector3 position) { final int blockY = position.getBlockY(); if (blockY < minY || blockY > maxY) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner return false; } int px = position.getBlockX(); @@ -378,11 +305,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { double dx = Math.abs(px - center.getBlockX()) * radiusInverse.getX(); double dz = Math.abs(pz - center.getBlockZ()) * radiusInverse.getZ(); -<<<<<<< HEAD return dx * dx + dz * dz <= 1; -======= - return position.toBlockVector2().subtract(center).toVector2().divide(radius).lengthSq() <= 1; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +// return position.toBlockVector2().subtract(center).toVector2().divide(radius).lengthSq() <= 1; } @@ -415,18 +339,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { } @Override -<<<<<<< HEAD - public Iterable asFlatRegion() { - return new Iterable() { - @Override - public Iterator iterator() { - return new FlatRegionIterator(CylinderRegion.this); - } - }; -======= public Iterable asFlatRegion() { return () -> new FlatRegionIterator(CylinderRegion.this); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } /** 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 b335f3448..c06a1851e 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 @@ -37,13 +37,13 @@ public class EllipsoidRegion extends AbstractRegion { /** * Stores the center. */ - private MutableBlockVector center; + private BlockVector3 center; /** * Stores the radii plus 0.5 on each axis. */ - private MutableBlockVector radius; - private MutableBlockVector radiusSqr; + private Vector3 radius; + private Vector3 radiusSqr; private int radiusLengthSqr; private boolean sphere; @@ -67,8 +67,8 @@ public class EllipsoidRegion extends AbstractRegion { */ public EllipsoidRegion(World world, BlockVector3 center, Vector3 radius) { super(world); - this.center = new MutableBlockVector(center); - setRadius(radius.toBlockPoint()); + this.center = center; + setRadius(radius); } public EllipsoidRegion(EllipsoidRegion ellipsoidRegion) { @@ -128,20 +128,20 @@ public class EllipsoidRegion extends AbstractRegion { @Override public void expand(BlockVector3... changes) throws RegionOperationException { - center = new MutableBlockVector(center.add(calculateDiff(changes))); - setRadius(radius.add(calculateChanges(changes))); + center = center.add(calculateDiff(changes)); + setRadius(radius.add(calculateChanges(changes).toVector3())); } @Override public void contract(BlockVector3... changes) throws RegionOperationException { - center = new MutableBlockVector(center.subtract(calculateDiff(changes))); - BlockVector3 newRadius = radius.subtract(calculateChanges(changes)); - setRadius(new BlockVector3(1.5, 1.5, 1.5).getMaximum(newRadius)); + center = center.subtract(calculateDiff(changes)); + Vector3 newRadius = radius.subtract(calculateChanges(changes).toVector3()); + setRadius(new Vector3(1.5, 1.5, 1.5).getMaximum(newRadius)); } @Override public void shift(BlockVector3 change) throws RegionOperationException { - center = new MutableBlockVector(center.add(change)); + center = center.add(change); } /** @@ -160,7 +160,7 @@ public class EllipsoidRegion extends AbstractRegion { * @param center the center */ public void setCenter(BlockVector3 center) { - this.center = new MutableBlockVector(center); + this.center = center; } /** @@ -170,7 +170,7 @@ public class EllipsoidRegion extends AbstractRegion { */ public Vector3 getRadius() { if (radius == null) return null; - return radius.toVector3().subtract(0.5, 0.5, 0.5); + return radius.subtract(0.5, 0.5, 0.5); } /** @@ -178,10 +178,10 @@ public class EllipsoidRegion extends AbstractRegion { * * @param radius the radius */ - public void setRadius(BlockVector3 radius) { - this.radius = new MutableBlockVector(radius); - radiusSqr = new MutableBlockVector(radius.multiply(radius)); - radiusLengthSqr = radiusSqr.getBlockX(); + public void setRadius(Vector3 radius) { + this.radius = radius; + radiusSqr = radius.multiply(radius); + radiusLengthSqr = (int) radiusSqr.getX(); if (radius.getY() == radius.getX() && radius.getX() == radius.getZ()) { this.sphere = true; } else { @@ -238,7 +238,7 @@ public class EllipsoidRegion extends AbstractRegion { // double czd = (double) cz / radius.getBlockZ(); // return cxd * cxd + cyd * cyd + czd * czd <= 1; public boolean contains(BlockVector3 position) { - return position.subtract(center).divide(radius).lengthSq() <= 1; + return position.subtract(center).divide(radius.toBlockPoint()).lengthSq() <= 1; } /** @@ -253,7 +253,7 @@ public class EllipsoidRegion extends AbstractRegion { } public void extendRadius(Vector3 minRadius) { - setRadius(minRadius.getMaximum(getRadius()).toBlockPoint()); + setRadius(minRadius.getMaximum(getRadius())); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java index 7ac33b929..570f0a80d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java @@ -19,14 +19,10 @@ package com.sk89q.worldedit.regions; -<<<<<<< HEAD import com.sk89q.worldedit.*; -import com.sk89q.worldedit.Vector; -======= import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.World; import java.util.*; 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 18d7e6b36..f0216757e 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 @@ -277,7 +277,6 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { } @Override -<<<<<<< HEAD public boolean contains(int targetX, int targetZ) { boolean inside = false; int npoints = points.size(); @@ -325,11 +324,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { return inside; } - @Override - public boolean contains(Vector position) { -======= public boolean contains(BlockVector3 position) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner return contains(points, minY, maxY, position); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java index 9bdc81119..051731cdc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java @@ -161,7 +161,7 @@ public interface RegionSelector { * @return * @throws IncompleteRegionException */ - default List getVerticies() throws IncompleteRegionException { + default List getVerticies() throws IncompleteRegionException { return Collections.singletonList(getPrimaryPosition()); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java index 30b6acdd0..a4da1b56a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java @@ -19,17 +19,11 @@ package com.sk89q.worldedit.regions; -<<<<<<< HEAD -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.BlockVector2D; -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.math.transform.Identity; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.world.World; 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 b091873a1..786e04a2b 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 @@ -19,27 +19,16 @@ package com.sk89q.worldedit.regions.iterator; -<<<<<<< HEAD -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.regions.FlatRegion; import java.util.Iterator; import java.util.NoSuchElementException; -<<<<<<< HEAD -import static com.google.common.base.Preconditions.checkNotNull; - -public class FlatRegion3DIterator implements Iterator { -======= public class FlatRegion3DIterator implements Iterator { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner private Iterator flatIterator; private int minY; 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 a3521e3ef..42bda7d86 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 @@ -19,27 +19,18 @@ package com.sk89q.worldedit.regions.iterator; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.regions.Region; import java.util.Iterator; import java.util.NoSuchElementException; -<<<<<<< HEAD import static com.google.common.base.Preconditions.checkNotNull; -public class FlatRegionIterator implements Iterator { -======= public class FlatRegionIterator implements Iterator { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner private Region region; private int y; @@ -76,11 +67,7 @@ public class FlatRegionIterator implements Iterator { } private void forward() { -<<<<<<< HEAD while (hasNext() && !region.contains(nextX, y, nextZ)) { -======= - while (hasNext() && !region.contains(new BlockVector3(nextX, y, nextZ))) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner forwardOne(); } } 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 6c5d7d7b2..482d30151 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 @@ -19,25 +19,16 @@ package com.sk89q.worldedit.regions.iterator; -<<<<<<< HEAD -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.regions.Region; import java.util.Iterator; -<<<<<<< HEAD import static com.google.common.base.Preconditions.checkNotNull; -public class RegionIterator implements Iterator { -======= public class RegionIterator implements Iterator { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner private final Region region; private final int maxX; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java index 6fc5383d4..dfff27af6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.regions.polyhedron; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java index 93b160b59..2d7240e03 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.regions.polyhedron; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java index 1fe85b0e6..68791a33b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java @@ -19,14 +19,9 @@ package com.sk89q.worldedit.regions.selector; -<<<<<<< HEAD import com.boydti.fawe.config.BBC; -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.BlockVector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; @@ -104,15 +99,9 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion region = new ConvexPolyhedralRegion(oldRegion.getWorld()); -<<<<<<< HEAD - for (final BlockVector2D pt : new ArrayList(oldRegion.polygonize(Integer.MAX_VALUE))) { - region.addVertex(pt.toVector(minY)); - region.addVertex(pt.toVector(maxY)); -======= for (final BlockVector2 pt : new ArrayList<>(oldRegion.polygonize(Integer.MAX_VALUE))) { region.addVertex(pt.toBlockVector3(minY)); region.addVertex(pt.toBlockVector3(maxY)); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } learnChanges(); @@ -120,7 +109,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion } @Override - public List getVerticies() { + public List getVerticies() { return new ArrayList<>(region.getVertices()); } @@ -258,11 +247,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion Collection vertices = region.getVertices(); Collection triangles = region.getTriangles(); -<<<<<<< HEAD - Map vertexIds = new HashMap(vertices.size()); -======= Map vertexIds = new HashMap<>(vertices.size()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner int lastVertexId = -1; for (BlockVector3 vertex : vertices) { vertexIds.put(vertex, ++lastVertexId); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java index 226482a5c..c526cdfea 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java @@ -19,22 +19,17 @@ package com.sk89q.worldedit.regions.selector; -<<<<<<< HEAD import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Commands; import com.boydti.fawe.util.chat.Message; -import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.command.SelectionCommands; -======= import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.cui.CUIRegion; import com.sk89q.worldedit.internal.cui.SelectionPointEvent; @@ -57,15 +52,9 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class CuboidRegionSelector implements RegionSelector, CUIRegion { -<<<<<<< HEAD - public transient BlockVector position1; - public transient BlockVector position2; - public transient CuboidRegion region; -======= protected transient BlockVector3 position1; protected transient BlockVector3 position2; protected transient CuboidRegion region; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner /** * Create a new region selector with a {@code null} world. @@ -129,7 +118,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion { } @Override - public List getVerticies() { + public List getVerticies() { return Arrays.asList(position1, position2); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java index 5c212af98..3dfd75738 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.regions.selector; -<<<<<<< HEAD import com.boydti.fawe.config.BBC; -import com.sk89q.worldedit.BlockVector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; @@ -176,13 +172,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { } @Override -<<<<<<< HEAD - public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) { - BBC.SELECTOR_CENTER.send(player, pos, 0); -======= public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) { - player.print("Starting a new cylindrical selection at " + pos + "."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + BBC.SELECTOR_CENTER.send(player, pos, 0); session.describeCUI(player); } @@ -191,13 +182,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) { Vector3 center = region.getCenter(); -<<<<<<< HEAD - if (!center.equals(Vector.ZERO)) { + if (!center.equals(BlockVector3.ZERO)) { BBC.SELECTOR_RADIUS.send(player, NUMBER_FORMAT.format(region.getRadius().getX()) + "/" + NUMBER_FORMAT.format(region.getRadius().getZ()), region.getArea()); -======= - if (!center.equals(Vector3.ZERO)) { - player.print("Radius set to " + NUMBER_FORMAT.format(region.getRadius().getX()) + "/" + NUMBER_FORMAT.format(region.getRadius().getZ()) + " blocks. (" + region.getArea() + ")."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } else { BBC.SELECTION_WAND.send(player); return; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java index e3b8990eb..f524c0ba0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java @@ -19,13 +19,9 @@ package com.sk89q.worldedit.regions.selector; -<<<<<<< HEAD import com.boydti.fawe.config.BBC; -import com.sk89q.worldedit.BlockVector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; @@ -149,33 +145,15 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion { } @Override -<<<<<<< HEAD - public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) { - BBC.SELECTOR_CENTER.send(player, region.getCenter(), region.getArea()); -======= public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) { - if (isDefined()) { - player.print("Center position set to " + region.getCenter() + " (" + region.getArea() + ")."); - } else { - player.print("Center position set to " + region.getCenter() + "."); - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + BBC.SELECTOR_CENTER.send(player, region.getCenter(), region.getArea()); session.describeCUI(player); } @Override -<<<<<<< HEAD - public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) { - BBC.SELECTOR_RADIUS.send(player, region.getRadius(), region.getArea()); -======= public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) { - if (isDefined()) { - player.print("Radius set to " + region.getRadius() + " (" + region.getArea() + ")."); - } else { - player.print("Radius set to " + region.getRadius() + "."); - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + BBC.SELECTOR_RADIUS.send(player, region.getRadius(), region.getArea()); session.describeCUI(player); } 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 c55f11fd1..28c22cf96 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 @@ -19,11 +19,7 @@ package com.sk89q.worldedit.regions.selector; -<<<<<<< HEAD import com.boydti.fawe.config.BBC; -import com.sk89q.worldedit.BlockVector; -======= ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.math.BlockVector3; @@ -132,25 +128,15 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector { } @Override -<<<<<<< HEAD - public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) { - BBC.SELECTOR_POS.send(player, 1, pos, region.getArea()); -======= public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) { - player.print("Started selection at " + pos + " (" + region.getArea() + ")."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + BBC.SELECTOR_POS.send(player, 1, pos, region.getArea()); explainRegionAdjust(player, session); } @Override -<<<<<<< HEAD - public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) { - BBC.SELECTOR_EXPANDED.send(player, pos, region.getArea()); -======= public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) { - player.print("Extended selection to encompass " + pos + " (" + region.getArea() + ")."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + BBC.SELECTOR_EXPANDED.send(player, pos, region.getArea()); explainRegionAdjust(player, session); } 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 6f0cc3abd..ee2bb8ba3 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 @@ -19,14 +19,9 @@ package com.sk89q.worldedit.regions.selector; -<<<<<<< HEAD import com.boydti.fawe.config.BBC; -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.BlockVector2D; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; @@ -174,13 +169,8 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { } @Override -<<<<<<< HEAD - public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) { - BBC.SELECTOR_POS.send(player, 1, pos, region.getArea()); -======= public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) { - player.print("Starting a new polygon at " + pos + "."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + BBC.SELECTOR_POS.send(player, 1, pos, region.getArea()); session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID())); session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getArea())); @@ -188,13 +178,8 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { } @Override -<<<<<<< HEAD - public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) { - BBC.SELECTOR_POS.send(player, region.size(), pos, region.getArea()); -======= public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) { - player.print("Added point #" + region.size() + " at " + pos + "."); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + BBC.SELECTOR_POS.send(player, region.size(), pos, region.getArea()); session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea())); session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY())); 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 815d4b652..a37df4257 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 @@ -86,17 +86,8 @@ public class SphereRegionSelector extends EllipsoidRegionSelector { } @Override -<<<<<<< HEAD - public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) { - BBC.SELECTOR_RADIUS.send(player, region.getRadius().getX(), region.getArea()); -======= public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) { - if (isDefined()) { - player.print("Radius set to " + region.getRadius().getX() + " (" + region.getArea() + ")."); - } else { - player.print("Radius set to " + region.getRadius().getX() + "."); - } ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + BBC.SELECTOR_RADIUS.send(player, region.getRadius().getX(), region.getArea()); session.describeCUI(player); } 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 7377a1657..321c80b32 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 @@ -19,12 +19,8 @@ package com.sk89q.worldedit.regions.shape; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.regions.Region; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java index 8ccd26445..bfc82f5c6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java @@ -19,14 +19,10 @@ package com.sk89q.worldedit.session; -<<<<<<< HEAD import com.boydti.fawe.util.MaskTraverser; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector; -======= import static com.google.common.base.Preconditions.checkNotNull; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java index d74185d6d..9e37e4da0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java @@ -19,15 +19,11 @@ package com.sk89q.worldedit.session.request; -<<<<<<< HEAD -import com.sk89q.worldedit.*; -======= import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.regions.NullRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionOperationException; 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 729c9b644..09ec0aef4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java @@ -19,10 +19,7 @@ package com.sk89q.worldedit.util; -<<<<<<< HEAD import com.sk89q.worldedit.*; -======= ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; @@ -77,12 +74,7 @@ public class TargetBlock { * @param viewHeight where the view is positioned in y-axis * @param checkDistance how often to check for blocks, the smaller the more precise */ -<<<<<<< HEAD - private void setValues(Vector loc, double xRotation, double yRotation, - int maxDistance, double viewHeight, double checkDistance) { -======= private void setValues(Vector3 loc, double xRotation, double yRotation, int maxDistance, double viewHeight, double checkDistance) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner this.maxDistance = maxDistance; this.checkDistance = checkDistance; this.curDistance = 0; @@ -91,15 +83,9 @@ public class TargetBlock { double h = (checkDistance * Math.cos(Math.toRadians(yRotation))); -<<<<<<< HEAD - offset = new Vector((h * Math.cos(Math.toRadians(xRotation))), - (checkDistance * Math.sin(Math.toRadians(yRotation))), - (h * Math.sin(Math.toRadians(xRotation)))); -======= offset = new Vector3((h * Math.cos(Math.toRadians(xRotation))), (checkDistance * Math.sin(Math.toRadians(yRotation))), (h * Math.sin(Math.toRadians(xRotation)))); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner targetPosDouble = loc.add(0, viewHeight, 0); targetPos = targetPosDouble.toBlockPoint(); @@ -116,11 +102,7 @@ public class TargetBlock { boolean searchForLastBlock = true; Location lastBlock = null; while (getNextBlock() != null) { -<<<<<<< HEAD - if (world.getBlockType(getCurrentBlock().toVector()).getMaterial().isAir()) { -======= if (world.getBlock(targetPos).getBlockType().getMaterial().isAir()) { ->>>>>>> 399e0ad5... Refactor vector system to be cleaner if (searchForLastBlock) { lastBlock = getCurrentBlock(); if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) { @@ -142,11 +124,7 @@ public class TargetBlock { * @return Block */ public Location getTargetBlock() { -<<<<<<< HEAD - while (getNextBlock() != null && world.getBlockType(getCurrentBlock().toVector()).getMaterial().isAir()) ; -======= while (getNextBlock() != null && world.getBlock(targetPos).getBlockType().getMaterial().isAir()) ; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner return getCurrentBlock(); } @@ -157,11 +135,7 @@ public class TargetBlock { * @return Block */ public Location getSolidTargetBlock() { -<<<<<<< HEAD - while (getNextBlock() != null && !world.getBlockType(getCurrentBlock().toVector()).getMaterial().isMovementBlocker()) ; -======= while (getNextBlock() != null && !world.getBlock(targetPos).getBlockType().getMaterial().isMovementBlocker()) ; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner return getCurrentBlock(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index 8c2a73249..b6f75a281 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -19,13 +19,10 @@ package com.sk89q.worldedit.world; -<<<<<<< HEAD import com.sk89q.worldedit.*; -======= import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -128,18 +125,18 @@ public class NullWorld extends AbstractWorld { } @Override -<<<<<<< HEAD - public BlockState getLazyBlock(Vector position) { +//<<<<<<< HEAD + public BlockState getLazyBlock(BlockVector3 position) { return getBlock(position); } @Override - public BlockState getFullBlock(Vector position) { + public BlockState getFullBlock(BlockVector3 position) { return getBlock(position); -======= - public BaseBlock getFullBlock(BlockVector3 position) { - return getBlock(position).toBaseBlock(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// public BaseBlock getFullBlock(BlockVector3 position) { +// return getBlock(position).toBaseBlock(); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index 017c988cc..a69cdd5a0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -27,7 +27,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.collect.Maps; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BlockMaterial; @@ -36,6 +35,7 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.SingleBlockStateMask; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; @@ -205,12 +205,12 @@ public abstract class BlockState implements BlockStateHolder { } @Override - public boolean apply(Extent extent, Vector get, Vector set) throws WorldEditException { + public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { return extent.setBlock(set, this); } @Override - public BlockState apply(Vector position) { + public BlockState apply(BlockVector3 position) { return this; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java index de6c1cc80..b3406a083 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java @@ -20,13 +20,13 @@ package com.sk89q.worldedit.world.block; import com.google.common.collect.ImmutableList; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BlockMaterial; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.SingleBlockTypeMask; import com.sk89q.worldedit.function.pattern.FawePattern; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.world.item.ItemType; @@ -47,12 +47,12 @@ public interface BlockType extends FawePattern, Comparable { int getMaxStateId(); @Override - default boolean apply(Extent extent, Vector get, Vector set) throws WorldEditException { + default boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { return extent.setBlock(set, this.getDefaultState()); } @Override - default BlockStateHolder apply(Vector position) { + default BlockStateHolder apply(BlockVector3 position) { return this.getDefaultState(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index 8fb6e4d1d..abe7cf68b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -34,6 +34,7 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.SingleBlockTypeMask; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; @@ -830,7 +831,7 @@ public enum BlockTypes implements BlockType { } @Override - public boolean apply(Extent extent, Vector get, Vector set) throws WorldEditException { + public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { return extent.setBlock(set, this.settings.defaultState); } 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 19247cf06..972bc985a 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 @@ -27,11 +27,8 @@ import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.NBTUtils; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEdit; -<<<<<<< HEAD import com.sk89q.worldedit.blocks.BaseBlock; -======= import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; 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 8af1fef05..e02a715ca 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 @@ -26,13 +26,8 @@ import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.LongArrayTag; import com.sk89q.jnbt.NBTUtils; import com.sk89q.jnbt.Tag; -<<<<<<< HEAD -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; -======= import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.block.BlockState; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java index 08a8bb4f2..7a1ef7612 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java @@ -35,10 +35,6 @@ public interface Chunk { * @return block the block * @throws DataException thrown on data error */ -<<<<<<< HEAD - BlockStateHolder getBlock(Vector position) throws DataException; -======= BlockStateHolder getBlock(BlockVector3 position) throws DataException; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner } 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 52565b016..d337bf7bd 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 @@ -26,11 +26,8 @@ import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.NBTUtils; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEdit; -<<<<<<< HEAD import com.sk89q.worldedit.blocks.BaseBlock; -======= import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; @@ -157,13 +154,13 @@ public class OldChunk implements Chunk { } @Override -<<<<<<< HEAD - public BlockStateHolder getBlock(Vector position) throws DataException { - if(position.getBlockY() >= 128) return BlockTypes.VOID_AIR.getDefaultState(); -======= +//<<<<<<< HEAD public BlockStateHolder getBlock(BlockVector3 position) throws DataException { - if(position.getY() >= 128) return BlockTypes.VOID_AIR.getDefaultState().toBaseBlock(); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner + if(position.getBlockY() >= 128) return BlockTypes.VOID_AIR.getDefaultState(); +//======= +// public BlockStateHolder getBlock(BlockVector3 position) throws DataException { +// if(position.getY() >= 128) return BlockTypes.VOID_AIR.getDefaultState().toBaseBlock(); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner int id, dataVal; int x = position.getX() - rootX * 16; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java index a1913d04d..d9e289820 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java @@ -22,12 +22,8 @@ package com.sk89q.worldedit.world.registry; import com.google.common.io.Resources; import com.google.gson.*; import com.google.gson.reflect.TypeToken; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BlockMaterial; -======= import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.util.gson.VectorAdapter; import java.io.IOException; @@ -78,8 +74,8 @@ public class BundledBlockData { */ private void loadFromResource() throws IOException { GsonBuilder gsonBuilder = new GsonBuilder(); -<<<<<<< HEAD - gsonBuilder.registerTypeAdapter(Vector.class, new VectorAdapter()); +//<<<<<<< HEAD + gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter()); gsonBuilder.registerTypeAdapter(int.class, new JsonDeserializer() { @Override public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { @@ -92,9 +88,9 @@ public class BundledBlockData { return primitive.getAsInt(); } }); -======= - gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter()); ->>>>>>> 399e0ad5... Refactor vector system to be cleaner +//======= +// gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter()); +//>>>>>>> 399e0ad5... Refactor vector system to be cleaner Gson gson = gsonBuilder.create(); URL url = BundledBlockData.class.getResource("blocks.json"); if (url == null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java index f3d7ba156..8bf2a99cc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java @@ -25,15 +25,11 @@ import com.google.common.io.Resources; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.registry.state.PropertyKey; -======= import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.gson.VectorAdapter; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; 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 61b035b48..b243dcd3a 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 @@ -21,24 +21,14 @@ package com.sk89q.worldedit.world.snapshot; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.Vector2D; -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; -======= import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.DataException; -import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.chunk.Chunk; import com.sk89q.worldedit.world.storage.ChunkStore; import com.sk89q.worldedit.world.storage.MissingChunkException; -import com.sk89q.worldedit.world.storage.MissingWorldException; - import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java index 2bda8e7f6..b3b5728fe 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java @@ -22,11 +22,7 @@ package com.sk89q.worldedit.world.storage; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.Tag; -<<<<<<< HEAD -import com.sk89q.worldedit.*; -======= import com.sk89q.worldedit.math.BlockVector2; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.World; diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/VectorTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/VectorTest.java deleted file mode 100644 index fea68dbf0..000000000 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/VectorTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit; - -import org.junit.*; -import static org.junit.Assert.*; - -public class VectorTest { - @Test - public void collinearityTest() { - assertCollinear(0,0,0, 0,0,0); - - assertCollinear(0,0,0, 1,0,0); - assertCollinear(0,0,0, 0,1,0); - assertCollinear(0,0,0, 0,0,1); - - assertCollinear(1,0,0, 0,0,0); - assertCollinear(0,1,0, 0,0,0); - assertCollinear(0,0,1, 0,0,0); - - assertCollinear(1,0,0, 2,0,0); - assertNotCollinear(1,0,0, 0,1,0); - - assertNotCollinear(2,2,2, 8,4,4); - assertCollinear(8,2,2, 8,2,2); - assertNotCollinear(4,2,4, 4,4,4); - assertNotCollinear(1,1,2, 4,8,2); - assertNotCollinear(4,1,8, 1,4,4); - assertCollinear(2,4,2, 1,2,1); - assertNotCollinear(2,2,4, 1,2,1); - assertNotCollinear(4,4,1, 4,4,4); - assertNotCollinear(4,1,4, 1,8,2); - assertCollinear(8,8,4, 4,4,2); - assertNotCollinear(2,1,8, 1,1,2); - assertNotCollinear(8,1,2, 2,1,2); - assertNotCollinear(4,4,8, 2,2,8); - assertNotCollinear(8,4,8, 1,4,8); - assertNotCollinear(2,2,2, 1,4,2); - assertNotCollinear(1,1,2, 8,8,2); - assertNotCollinear(4,4,8, 8,4,4); - assertNotCollinear(1,8,2, 4,4,4); - assertNotCollinear(8,4,2, 1,2,2); - assertNotCollinear(1,8,2, 8,1,4); - assertNotCollinear(4,8,1, 4,8,8); - assertNotCollinear(8,1,8, 8,8,8); - assertNotCollinear(8,4,1, 4,2,2); - assertNotCollinear(4,8,1, 4,2,1); - assertNotCollinear(8,8,1, 2,4,2); - assertCollinear(8,1,4, 8,1,4); - assertNotCollinear(4,1,1, 2,4,8); - assertNotCollinear(4,2,8, 1,4,1); - assertNotCollinear(1,8,2, 1,8,1); - assertNotCollinear(1,1,2, 4,2,2); - - assertCollinear(0,0, 0,0); - - assertCollinear(0,0, 1,0); - assertCollinear(0,0, 0,1); - assertCollinear(0,0, 0,0); - - assertCollinear(1,0, 0,0); - assertCollinear(0,1, 0,0); - assertCollinear(0,0, 0,0); - - assertCollinear(1,0, 2,0); - assertNotCollinear(1,0, 0,1); - - assertNotCollinear(2,2, 8,4); - assertCollinear(8,2, 8,2); - assertNotCollinear(4,2, 4,4); - assertNotCollinear(1,1, 4,8); - assertNotCollinear(4,1, 1,4); - assertCollinear(2,4, 1,2); - assertNotCollinear(2,2, 1,2); - assertCollinear(4,4, 4,4); - assertNotCollinear(4,1, 1,8); - assertCollinear(8,8, 4,4); - assertNotCollinear(2,1, 1,1); - assertNotCollinear(8,1, 2,1); - assertCollinear(4,4, 2,2); - assertNotCollinear(8,4, 1,4); - assertNotCollinear(2,2, 1,4); - assertCollinear(1,1, 8,8); - assertNotCollinear(4,4, 8,4); - assertNotCollinear(1,8, 4,4); - assertNotCollinear(8,4, 1,2); - assertNotCollinear(1,8, 8,1); - assertCollinear(4,8, 4,8); - assertNotCollinear(8,1, 8,8); - assertCollinear(8,4, 4,2); - assertNotCollinear(4,8, 4,2); - assertNotCollinear(8,8, 2,4); - assertCollinear(8,1, 8,1); - assertNotCollinear(4,1, 2,4); - assertNotCollinear(4,2, 1,4); - assertCollinear(1,8, 1,8); - assertNotCollinear(1,1, 4,2); - } - - private void assertCollinear(double ax, double ay, double az, double bx, double by, double bz) { - final Vector a = new Vector(ax,ay,az); - final Vector b = new Vector(bx,by,bz); - assertTrue(a.isCollinearWith(b)); - assertTrue(b.isCollinearWith(a)); - assertTrue(a.multiply(-1.0).isCollinearWith(b)); - assertTrue(a.isCollinearWith(b.multiply(-1.0))); - } - private void assertNotCollinear(double ax, double ay, double az, double bx, double by, double bz) { - final Vector a = new Vector(ax,ay,az); - final Vector b = new Vector(bx,by,bz); - assertFalse(a.isCollinearWith(b)); - assertFalse(b.isCollinearWith(a)); - assertFalse(a.multiply(-1.0).isCollinearWith(b)); - assertFalse(a.isCollinearWith(b.multiply(-1.0))); - } - - private void assertCollinear(double ax, double az, double bx, double bz) { - final Vector2D a = new Vector2D(ax,az); - final Vector2D b = new Vector2D(bx,bz); - assertTrue(a.isCollinearWith(b)); - assertTrue(b.isCollinearWith(a)); - assertTrue(a.multiply(-1.0).isCollinearWith(b)); - assertTrue(a.isCollinearWith(b.multiply(-1.0))); - } - private void assertNotCollinear(double ax, double az, double bx, double bz) { - final Vector2D a = new Vector2D(ax,az); - final Vector2D b = new Vector2D(bx,bz); - assertFalse(a.isCollinearWith(b)); - assertFalse(b.isCollinearWith(a)); - assertFalse(a.multiply(-1.0).isCollinearWith(b)); - assertFalse(a.isCollinearWith(b.multiply(-1.0))); - } -} 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 af01b888f..9c2a08760 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 @@ -19,14 +19,10 @@ package com.sk89q.worldedit.util; -<<<<<<< HEAD -import com.sk89q.worldedit.Vector; -======= import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import com.sk89q.worldedit.math.Vector3; ->>>>>>> 399e0ad5... Refactor vector system to be cleaner import com.sk89q.worldedit.world.World; import org.junit.Test;