getDirections() {
return directions;
}
@@ -86,29 +85,29 @@ public abstract class BreadthFirstSearch implements Operation {
* Add the directions along the axes as directions to visit.
*/
protected void addAxes() {
- directions.add(new Vector(0, -1, 0));
- directions.add(new Vector(0, 1, 0));
- 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 BlockVector3(0, -1, 0));
+ directions.add(new BlockVector3(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));
}
/**
* Add the diagonal directions as directions to visit.
*/
protected void addDiagonal() {
- directions.add(new Vector(1, 0, 1));
- directions.add(new Vector(-1, 0, -1));
- directions.add(new Vector(1, 0, -1));
- directions.add(new Vector(-1, 0, 1));
+ directions.add(new BlockVector3(1, 0, 1));
+ directions.add(new BlockVector3(-1, 0, -1));
+ directions.add(new BlockVector3(1, 0, -1));
+ directions.add(new BlockVector3(-1, 0, 1));
}
/**
* Add the given location to the list of locations to visit, provided
* that it has not been visited. The position passed to this method
* will still be visited even if it fails
- * {@link #isVisitable(com.sk89q.worldedit.Vector, com.sk89q.worldedit.Vector)}.
+ * {@link #isVisitable(BlockVector3, BlockVector3)}.
*
* This method should be used before the search begins, because if
* the position does fail the test, and the search has already
@@ -118,8 +117,8 @@ public abstract class BreadthFirstSearch implements Operation {
*
* @param position the position
*/
- public void visit(Vector position) {
- BlockVector blockVector = position.toBlockVector();
+ public void visit(BlockVector3 position) {
+ BlockVector3 blockVector = position;
if (!visited.contains(blockVector)) {
queue.add(blockVector);
visited.add(blockVector);
@@ -132,8 +131,8 @@ public abstract class BreadthFirstSearch implements Operation {
* @param from the origin block
* @param to the block under question
*/
- private void visit(Vector from, Vector to) {
- BlockVector blockVector = to.toBlockVector();
+ private void visit(BlockVector3 from, BlockVector3 to) {
+ BlockVector3 blockVector = to;
if (!visited.contains(blockVector)) {
visited.add(blockVector);
if (isVisitable(from, to)) {
@@ -150,7 +149,7 @@ public abstract class BreadthFirstSearch implements Operation {
* @param to the block under question
* @return true if the 'to' block should be visited
*/
- protected abstract boolean isVisitable(Vector from, Vector to);
+ protected abstract boolean isVisitable(BlockVector3 from, BlockVector3 to);
/**
* Get the number of affected objects.
@@ -163,14 +162,14 @@ public abstract class BreadthFirstSearch implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
- Vector position;
+ BlockVector3 position;
while ((position = queue.poll()) != null) {
if (function.apply(position)) {
affected++;
}
- for (Vector dir : directions) {
+ for (BlockVector3 dir : directions) {
visit(position, position.add(dir));
}
}
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 3788d547d..62363a205 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
@@ -21,9 +21,9 @@ package com.sk89q.worldedit.function.visitor;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask;
+import com.sk89q.worldedit.math.BlockVector3;
import java.util.Collection;
@@ -51,17 +51,17 @@ public class DownwardVisitor 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 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));
}
@Override
- protected boolean isVisitable(Vector from, Vector to) {
+ protected boolean isVisitable(BlockVector3 from, BlockVector3 to) {
int fromY = from.getBlockY();
return (fromY == baseY || to.subtract(from).getBlockY() < 0) && super.isVisitable(from, to);
}
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 1f0d96e42..46ef33dc0 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
@@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.visitor;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
+import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.FlatRegion;
import java.util.List;
@@ -64,7 +64,7 @@ public class FlatRegionVisitor implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
- for (Vector2D pt : flatRegion.asFlatRegion()) {
+ for (BlockVector2 pt : flatRegion.asFlatRegion()) {
if (function.apply(pt)) {
affected++;
}
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 b6dcf4882..f3a191e12 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
@@ -22,14 +22,14 @@ package com.sk89q.worldedit.function.visitor;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.LayerFunction;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.FlatRegion;
import java.util.List;
@@ -92,20 +92,20 @@ public class LayerVisitor implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
- for (Vector2D column : flatRegion.asFlatRegion()) {
+ for (BlockVector2 column : flatRegion.asFlatRegion()) {
if (!mask.test(column)) {
continue;
}
// Abort if we are underground
- if (function.isGround(column.toVector(maxY + 1))) {
+ if (function.isGround(column.toBlockVector3(maxY + 1))) {
return null;
}
boolean found = false;
int groundY = 0;
for (int y = maxY; y >= minY; --y) {
- Vector test = column.toVector(y);
+ BlockVector3 test = column.toBlockVector3(y);
if (!found) {
if (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 8be7466b1..21aa8b6f6 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,9 +19,9 @@
package com.sk89q.worldedit.function.visitor;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask;
+import com.sk89q.worldedit.math.BlockVector3;
import java.util.Collection;
@@ -38,13 +38,13 @@ public class NonRisingVisitor extends RecursiveVisitor {
*/
public NonRisingVisitor(Mask mask, RegionFunction function) {
super(mask, function);
- 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 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));
}
}
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 ac89393a3..d3dda04f7 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
@@ -21,9 +21,9 @@ package com.sk89q.worldedit.function.visitor;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask;
+import com.sk89q.worldedit.math.BlockVector3;
/**
* An implementation of an {@link BreadthFirstSearch} that uses a mask to
@@ -46,7 +46,7 @@ public class RecursiveVisitor extends BreadthFirstSearch {
}
@Override
- protected boolean isVisitable(Vector from, Vector to) {
+ protected boolean isVisitable(BlockVector3 from, BlockVector3 to) {
return mask.test(to);
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java
index d6fc7d45c..12a955c0d 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java
@@ -19,11 +19,11 @@
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.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import java.util.List;
@@ -53,7 +53,7 @@ public class RegionVisitor implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
- for (Vector pt : region) {
+ for (BlockVector3 pt : region) {
if (function.apply(pt)) {
affected++;
}
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 4bb94aa09..1bbef8ab0 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
@@ -21,10 +21,10 @@ package com.sk89q.worldedit.history.change;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.history.UndoContext;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
/**
@@ -36,7 +36,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
*/
public class BlockChange implements Change {
- private final BlockVector position;
+ private final BlockVector3 position;
private final BlockStateHolder previous;
private final BlockStateHolder current;
@@ -47,7 +47,7 @@ public class BlockChange implements Change {
* @param previous the previous block
* @param current the current block
*/
- public BlockChange(BlockVector position, BlockStateHolder previous, BlockStateHolder current) {
+ public BlockChange(BlockVector3 position, BlockStateHolder previous, BlockStateHolder current) {
checkNotNull(position);
checkNotNull(previous);
checkNotNull(current);
@@ -61,7 +61,7 @@ public class BlockChange implements Change {
*
* @return the position
*/
- public BlockVector getPosition() {
+ public BlockVector3 getPosition() {
return position;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java
index 23f724110..9c9ad2a85 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java
@@ -22,9 +22,9 @@ package com.sk89q.worldedit.history.changeset;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Iterators;
-import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.history.change.BlockChange;
import com.sk89q.worldedit.history.change.Change;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.LocatedBlock;
import com.sk89q.worldedit.util.collection.LocatedBlockList;
@@ -42,7 +42,7 @@ import java.util.Iterator;
public class BlockOptimizedHistory extends ArrayListHistory {
private static Change createChange(LocatedBlock block) {
- return new BlockChange(block.getLocation().toBlockPoint(), block.getBlock(), block.getBlock());
+ return new BlockChange(block.getLocation(), block.getBlock(), block.getBlock());
}
private final LocatedBlockList previous = new LocatedBlockList();
@@ -54,7 +54,7 @@ public class BlockOptimizedHistory extends ArrayListHistory {
if (change instanceof BlockChange) {
BlockChange blockChange = (BlockChange) change;
- BlockVector position = blockChange.getPosition();
+ BlockVector3 position = blockChange.getPosition();
previous.add(position, blockChange.getPrevious());
current.add(position, blockChange.getCurrent());
} else {
@@ -80,5 +80,4 @@ public class BlockOptimizedHistory extends ArrayListHistory {
public int size() {
return super.size() + previous.size();
}
-
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/annotation/Direction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/annotation/Direction.java
index eac88237c..7f42b3a36 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/annotation/Direction.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/annotation/Direction.java
@@ -19,7 +19,7 @@
package com.sk89q.worldedit.internal.annotation;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -27,7 +27,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Annotates a {@link Vector} parameter to inject a direction.
+ * Annotates a {@link Vector3} parameter to inject a direction.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
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 a6371961f..262bdd0af 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
@@ -26,10 +26,10 @@ import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.Logging;
import com.sk89q.worldedit.IncompleteRegionException;
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.math.Vector3;
import com.sk89q.worldedit.util.command.parametric.AbstractInvokeListener;
import com.sk89q.worldedit.util.command.parametric.InvokeHandler;
import com.sk89q.worldedit.util.command.parametric.ParameterData;
@@ -102,13 +102,13 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv
}
if (logMode != null && sender.isPlayer()) {
- Vector position = player.getLocation().toVector();
+ Vector3 position = player.getLocation().toVector();
LocalSession session = worldEdit.getSessionManager().get(player);
switch (logMode) {
case PLACEMENT:
try {
- position = session.getPlacementPosition(player);
+ position = session.getPlacementPosition(player).toVector3();
} catch (IncompleteRegionException e) {
break;
}
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 1bdeee5c5..4cdebe5cb 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
@@ -23,10 +23,8 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.UnknownDirectionException;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.NoMatchException;
@@ -38,6 +36,7 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.annotation.Direction;
import com.sk89q.worldedit.internal.annotation.Selection;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
@@ -49,6 +48,7 @@ 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.registry.BiomeRegistry;
@@ -258,10 +258,10 @@ public class WorldEditBinding extends BindingHelper {
* @throws UnknownDirectionException on an unknown direction
*/
@BindingMatch(classifier = Direction.class,
- type = Vector.class,
+ type = BlockVector3.class,
behavior = BindingBehavior.CONSUMES,
consumedCount = 1)
- public Vector getDirection(ArgumentStack context, Direction direction)
+ public BlockVector3 getDirection(ArgumentStack context, Direction direction)
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/cui/SelectionCylinderEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java
index d23fd9a74..d10f5fb68 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java
@@ -21,15 +21,15 @@
package com.sk89q.worldedit.internal.cui;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector2;
public class SelectionCylinderEvent implements CUIEvent {
- protected final Vector pos;
- protected final Vector2D radius;
+ protected final BlockVector3 pos;
+ protected final Vector2 radius;
- public SelectionCylinderEvent(Vector pos, Vector2D radius) {
+ public SelectionCylinderEvent(BlockVector3 pos, Vector2 radius) {
this.pos = pos;
this.radius = radius;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java
index 3e371b105..e8c051040 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java
@@ -19,14 +19,14 @@
package com.sk89q.worldedit.internal.cui;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
public class SelectionEllipsoidPointEvent implements CUIEvent {
protected final int id;
- protected final Vector pos;
+ protected final BlockVector3 pos;
- public SelectionEllipsoidPointEvent(int id, Vector pos) {
+ public SelectionEllipsoidPointEvent(int id, BlockVector3 pos) {
this.id = id;
this.pos = pos;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java
index dc4d0adaa..1586dced9 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java
@@ -19,27 +19,27 @@
package com.sk89q.worldedit.internal.cui;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
public class SelectionPoint2DEvent implements CUIEvent {
protected final int id;
- protected final int blockx;
- protected final int blockz;
+ protected final int blockX;
+ protected final int blockZ;
protected final int area;
- public SelectionPoint2DEvent(int id, Vector2D pos, int area) {
+ public SelectionPoint2DEvent(int id, BlockVector2 pos, int area) {
this.id = id;
- this.blockx = pos.getBlockX();
- this.blockz = pos.getBlockZ();
+ this.blockX = pos.getX();
+ this.blockZ = pos.getZ();
this.area = area;
}
- public SelectionPoint2DEvent(int id, Vector pos, int area) {
+ public SelectionPoint2DEvent(int id, BlockVector3 pos, int area) {
this.id = id;
- this.blockx = pos.getBlockX();
- this.blockz = pos.getBlockZ();
+ this.blockX = pos.getX();
+ this.blockZ = pos.getZ();
this.area = area;
}
@@ -52,8 +52,8 @@ public class SelectionPoint2DEvent implements CUIEvent {
public String[] getParameters() {
return new String[] {
String.valueOf(id),
- String.valueOf(blockx),
- String.valueOf(blockz),
+ String.valueOf(blockX),
+ String.valueOf(blockZ),
String.valueOf(area)
};
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java
index e719b1855..baac3ab1f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java
@@ -19,15 +19,15 @@
package com.sk89q.worldedit.internal.cui;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
public class SelectionPointEvent implements CUIEvent {
protected final int id;
- protected final Vector pos;
+ protected final BlockVector3 pos;
protected final int area;
- public SelectionPointEvent(int id, Vector pos, int area) {
+ public SelectionPointEvent(int id, BlockVector3 pos, int area) {
this.id = id;
this.pos = pos;
this.area = area;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java
index af63bebe0..5a13140db 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java
@@ -26,9 +26,9 @@ import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.IncompleteRegionException;
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.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
@@ -85,7 +85,7 @@ public class ServerCUIHandler {
}
} else {
CuboidRegion region = ((CuboidRegionSelector) regionSelector).getIncompleteRegion();
- Vector point;
+ BlockVector3 point;
if (region.getPos1() != null) {
point = region.getPos1();
} else if (region.getPos2() != null) {
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 4b4cbad13..9f7eaceb1 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,9 +19,9 @@
package com.sk89q.worldedit.internal.expression.runtime;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.runtime.Function.Dynamic;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.noise.PerlinNoise;
import com.sk89q.worldedit.math.noise.RidgedMultiFractalNoise;
import com.sk89q.worldedit.math.noise.VoronoiNoise;
@@ -392,7 +392,7 @@ public final class Functions {
} catch (IllegalArgumentException e) {
throw new EvaluationException(0, "Perlin noise error: " + e.getMessage());
}
- return perlin.noise(new Vector(x.getValue(), y.getValue(), z.getValue()));
+ return perlin.noise(new Vector3(x.getValue(), y.getValue(), z.getValue()));
}
private static final ThreadLocal localVoronoi = ThreadLocal.withInitial(VoronoiNoise::new);
@@ -405,7 +405,7 @@ public final class Functions {
} catch (IllegalArgumentException e) {
throw new EvaluationException(0, "Voronoi error: " + e.getMessage());
}
- return voronoi.noise(new Vector(x.getValue(), y.getValue(), z.getValue()));
+ return voronoi.noise(new Vector3(x.getValue(), y.getValue(), z.getValue()));
}
private static final ThreadLocal localRidgedMulti = ThreadLocal.withInitial(RidgedMultiFractalNoise::new);
@@ -419,7 +419,7 @@ public final class Functions {
} catch (IllegalArgumentException e) {
throw new EvaluationException(0, "Ridged multi error: " + e.getMessage());
}
- return ridgedMulti.noise(new Vector(x.getValue(), y.getValue(), z.getValue()));
+ return ridgedMulti.noise(new Vector3(x.getValue(), y.getValue(), z.getValue()));
}
private static double queryInternal(RValue type, RValue data, double typeId, double dataValue) throws EvaluationException {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java
new file mode 100644
index 000000000..864e8c19c
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java
@@ -0,0 +1,529 @@
+/*
+ * 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.math;
+
+import com.google.common.collect.ComparisonChain;
+import com.sk89q.worldedit.math.transform.AffineTransform;
+
+import java.util.Comparator;
+
+/**
+ * An immutable 2-dimensional vector.
+ */
+public final class BlockVector2 {
+
+ public static final BlockVector2 ZERO = new BlockVector2(0, 0);
+ public static final BlockVector2 UNIT_X = new BlockVector2(1, 0);
+ public static final BlockVector2 UNIT_Z = new BlockVector2(0, 1);
+ public static final BlockVector2 ONE = new BlockVector2(1, 1);
+
+ /**
+ * A comparator for BlockVector2ds 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();
+ };
+
+ private final int x, z;
+
+ /**
+ * Construct an instance.
+ *
+ * @param x the X coordinate
+ * @param z the Z coordinate
+ */
+ public BlockVector2(double x, double z) {
+ this((int) Math.floor(x), (int) Math.floor(z));
+ }
+
+ /**
+ * Construct an instance.
+ *
+ * @param x the X coordinate
+ * @param z the Z coordinate
+ */
+ public BlockVector2(int x, int z) {
+ this.x = x;
+ this.z = z;
+ }
+
+ /**
+ * Get the X coordinate.
+ *
+ * @return the x coordinate
+ */
+ public int getX() {
+ return x;
+ }
+
+ /**
+ * Get the X coordinate.
+ *
+ * @return the x coordinate
+ */
+ public int getBlockX() {
+ return x;
+ }
+
+ /**
+ * Set the X coordinate.
+ *
+ * @param x the new X
+ * @return a new vector
+ */
+ public BlockVector2 withX(int x) {
+ return new BlockVector2(x, z);
+ }
+
+ /**
+ * Get the Z coordinate.
+ *
+ * @return the z coordinate
+ */
+ public int getZ() {
+ return z;
+ }
+
+ /**
+ * Get the Z coordinate.
+ *
+ * @return the z coordinate
+ */
+ public int getBlockZ() {
+ return z;
+ }
+
+ /**
+ * Set the Z coordinate.
+ *
+ * @param z the new Z
+ * @return a new vector
+ */
+ public BlockVector2 withZ(int z) {
+ return new BlockVector2(x, 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 BlockVector2 add(BlockVector2 other) {
+ return add(other.x, other.z);
+ }
+
+ /**
+ * Add another vector to this vector and return the result as a new vector.
+ *
+ * @param x the value to add
+ * @param z the value to add
+ * @return a new vector
+ */
+ public BlockVector2 add(int x, int z) {
+ return new BlockVector2(this.x + x, this.z + z);
+ }
+
+ /**
+ * 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 BlockVector2 add(BlockVector2... others) {
+ int newX = x, newZ = z;
+
+ for (BlockVector2 other : others) {
+ newX += other.x;
+ newZ += other.z;
+ }
+
+ return new BlockVector2(newX, newZ);
+ }
+
+ /**
+ * Subtract another vector from this vector and return the result
+ * as a new vector.
+ *
+ * @param other the other vector
+ * @return a new vector
+ */
+ public BlockVector2 subtract(BlockVector2 other) {
+ return subtract(other.x, other.z);
+ }
+
+ /**
+ * Subtract another vector from this vector and return the result
+ * as a new vector.
+ *
+ * @param x the value to subtract
+ * @param z the value to subtract
+ * @return a new vector
+ */
+ public BlockVector2 subtract(int x, int z) {
+ return new BlockVector2(this.x - x, this.z - z);
+ }
+
+ /**
+ * 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 BlockVector2 subtract(BlockVector2... others) {
+ int newX = x, newZ = z;
+
+ for (BlockVector2 other : others) {
+ newX -= other.x;
+ newZ -= other.z;
+ }
+
+ return new BlockVector2(newX, newZ);
+ }
+
+ /**
+ * Multiply this vector by another vector on each component.
+ *
+ * @param other the other vector
+ * @return a new vector
+ */
+ public BlockVector2 multiply(BlockVector2 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 BlockVector2 multiply(int x, int z) {
+ return new BlockVector2(this.x * x, this.z * z);
+ }
+
+ /**
+ * Multiply this vector by zero or more vectors on each component.
+ *
+ * @param others an array of vectors
+ * @return a new vector
+ */
+ public BlockVector2 multiply(BlockVector2... others) {
+ int newX = x, newZ = z;
+
+ for (BlockVector2 other : others) {
+ newX *= other.x;
+ newZ *= other.z;
+ }
+
+ return new BlockVector2(newX, newZ);
+ }
+
+ /**
+ * Perform scalar multiplication and return a new vector.
+ *
+ * @param n the value to multiply
+ * @return a new vector
+ */
+ public BlockVector2 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 BlockVector2 divide(BlockVector2 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 BlockVector2 divide(int x, int z) {
+ return new BlockVector2(this.x / x, this.z / z);
+ }
+
+ /**
+ * Perform scalar division and return a new vector.
+ *
+ * @param n the value to divide by
+ * @return a new vector
+ */
+ public BlockVector2 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(BlockVector2 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(BlockVector2 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, as a new vector.
+ *
+ * @return a new vector
+ */
+ public BlockVector2 normalize() {
+ double len = length();
+ double x = this.x / len;
+ double z = this.z / len;
+ return new BlockVector2(x, z);
+ }
+
+ /**
+ * 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(BlockVector2 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(BlockVector2 min, BlockVector2 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 BlockVector2 floor() {
+ // already floored, kept for feature parity with Vector2
+ return this;
+ }
+
+ /**
+ * Rounds all components up.
+ *
+ * @return a new vector
+ */
+ public BlockVector2 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 BlockVector2 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 BlockVector2 abs() {
+ return new BlockVector2(Math.abs(x), Math.abs(z));
+ }
+
+ /**
+ * 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 BlockVector2 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;
+ return new BlockVector2(
+ x2 + aboutX + translateX,
+ z2 + aboutZ + translateZ);
+ }
+
+ /**
+ * Gets the minimum components of two vectors.
+ *
+ * @param v2 the second vector
+ * @return minimum
+ */
+ public BlockVector2 getMinimum(BlockVector2 v2) {
+ return new BlockVector2(
+ Math.min(x, v2.x),
+ Math.min(z, v2.z)
+ );
+ }
+
+ /**
+ * Gets the maximum components of two vectors.
+ *
+ * @param v2 the second vector
+ * @return maximum
+ */
+ public BlockVector2 getMaximum(BlockVector2 v2) {
+ return new BlockVector2(
+ Math.max(x, v2.x),
+ Math.max(z, v2.z)
+ );
+ }
+
+ 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);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof BlockVector2)) {
+ return false;
+ }
+
+ BlockVector2 other = (BlockVector2) 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 "(" + x + ", " + z + ")";
+ }
+
+}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java
new file mode 100644
index 000000000..efe56e8af
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java
@@ -0,0 +1,613 @@
+/*
+ * 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.math;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import com.google.common.collect.ComparisonChain;
+import com.sk89q.worldedit.math.transform.AffineTransform;
+
+import java.util.Comparator;
+
+/**
+ * An immutable 3-dimensional vector.
+ */
+public final class BlockVector3 {
+
+ public static final BlockVector3 ZERO = new BlockVector3(0, 0, 0);
+ public static final BlockVector3 UNIT_X = new BlockVector3(1, 0, 0);
+ public static final BlockVector3 UNIT_Y = new BlockVector3(0, 1, 0);
+ public static final BlockVector3 UNIT_Z = new BlockVector3(0, 0, 1);
+ public static final BlockVector3 ONE = new BlockVector3(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;
+ }
+
+ private final int x, y, z;
+
+ /**
+ * Construct an instance.
+ *
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param z the Z coordinate
+ */
+ public BlockVector3(double x, double y, double z) {
+ this((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z));
+ }
+
+ /**
+ * Construct an instance.
+ *
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param z the Z coordinate
+ */
+ public BlockVector3(int x, int y, int z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ /**
+ * Get the X coordinate.
+ *
+ * @return the x coordinate
+ */
+ public int getX() {
+ return x;
+ }
+
+ /**
+ * Get the X coordinate.
+ *
+ * @return the x coordinate
+ */
+ public int getBlockX() {
+ return x;
+ }
+
+ /**
+ * Set the X coordinate.
+ *
+ * @param x the new X
+ * @return a new vector
+ */
+ public BlockVector3 withX(int x) {
+ return new BlockVector3(x, y, z);
+ }
+
+ /**
+ * Get the Y coordinate.
+ *
+ * @return the y coordinate
+ */
+ public int getY() {
+ return y;
+ }
+
+ /**
+ * Get the Y coordinate.
+ *
+ * @return the y coordinate
+ */
+ public int getBlockY() {
+ return y;
+ }
+
+ /**
+ * Set the Y coordinate.
+ *
+ * @param y the new Y
+ * @return a new vector
+ */
+ public BlockVector3 withY(int y) {
+ return new BlockVector3(x, y, z);
+ }
+
+ /**
+ * Get the Z coordinate.
+ *
+ * @return the z coordinate
+ */
+ public int getZ() {
+ return z;
+ }
+
+ /**
+ * Get the Z coordinate.
+ *
+ * @return the z coordinate
+ */
+ public int getBlockZ() {
+ return z;
+ }
+
+ /**
+ * Set the Z coordinate.
+ *
+ * @param z the new Z
+ * @return a new vector
+ */
+ public BlockVector3 withZ(int z) {
+ return new BlockVector3(x, y, 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 BlockVector3 add(BlockVector3 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 BlockVector3 add(int x, int y, int z) {
+ return new BlockVector3(this.x + x, this.y + y, this.z + z);
+ }
+
+ /**
+ * 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 BlockVector3 add(BlockVector3... others) {
+ int newX = x, newY = y, newZ = z;
+
+ for (BlockVector3 other : others) {
+ newX += other.x;
+ newY += other.y;
+ newZ += other.z;
+ }
+
+ return new BlockVector3(newX, newY, newZ);
+ }
+
+ /**
+ * Subtract another vector from this vector and return the result
+ * as a new vector.
+ *
+ * @param other the other vector
+ * @return a new vector
+ */
+ public BlockVector3 subtract(BlockVector3 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 BlockVector3 subtract(int x, int y, int z) {
+ return new BlockVector3(this.x - x, this.y - y, this.z - z);
+ }
+
+ /**
+ * 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 BlockVector3 subtract(BlockVector3... others) {
+ int newX = x, newY = y, newZ = z;
+
+ for (BlockVector3 other : others) {
+ newX -= other.x;
+ newY -= other.y;
+ newZ -= other.z;
+ }
+
+ return new BlockVector3(newX, newY, newZ);
+ }
+
+ /**
+ * Multiply this vector by another vector on each component.
+ *
+ * @param other the other vector
+ * @return a new vector
+ */
+ public BlockVector3 multiply(BlockVector3 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 BlockVector3 multiply(int x, int y, int z) {
+ return new BlockVector3(this.x * x, this.y * y, this.z * z);
+ }
+
+ /**
+ * Multiply this vector by zero or more vectors on each component.
+ *
+ * @param others an array of vectors
+ * @return a new vector
+ */
+ public BlockVector3 multiply(BlockVector3... others) {
+ int newX = x, newY = y, newZ = z;
+
+ for (BlockVector3 other : others) {
+ newX *= other.x;
+ newY *= other.y;
+ newZ *= other.z;
+ }
+
+ return new BlockVector3(newX, newY, newZ);
+ }
+
+ /**
+ * Perform scalar multiplication and return a new vector.
+ *
+ * @param n the value to multiply
+ * @return a new vector
+ */
+ public BlockVector3 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 BlockVector3 divide(BlockVector3 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 BlockVector3 divide(int x, int y, int z) {
+ return new BlockVector3(this.x / x, this.y / y, this.z / z);
+ }
+
+ /**
+ * Perform scalar division and return a new vector.
+ *
+ * @param n the value to divide by
+ * @return a new vector
+ */
+ public BlockVector3 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(BlockVector3 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(BlockVector3 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 BlockVector3 normalize() {
+ double len = length();
+ double x = this.x / len;
+ double y = this.y / len;
+ double z = this.z / len;
+ return new BlockVector3(x, y, z);
+ }
+
+ /**
+ * 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(BlockVector3 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 BlockVector3 cross(BlockVector3 other) {
+ return new BlockVector3(
+ 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(BlockVector3 min, BlockVector3 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 BlockVector3 clampY(int min, int max) {
+ checkArgument(min <= max, "minimum cannot be greater than maximum");
+ if (y < min) {
+ return new BlockVector3(x, min, z);
+ }
+ if (y > max) {
+ return new BlockVector3(x, max, z);
+ }
+ return this;
+ }
+
+ /**
+ * Floors the values of all components.
+ *
+ * @return a new vector
+ */
+ public BlockVector3 floor() {
+ // already floored, kept for feature parity with Vector3
+ return this;
+ }
+
+ /**
+ * Rounds all components up.
+ *
+ * @return a new vector
+ */
+ public BlockVector3 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 BlockVector3 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 BlockVector3 abs() {
+ return new BlockVector3(Math.abs(x), Math.abs(y), Math.abs(z));
+ }
+
+ /**
+ * 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 BlockVector3 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;
+
+ return new BlockVector3(
+ x2 + aboutX + translateX,
+ y,
+ z2 + aboutZ + translateZ
+ );
+ }
+
+ /**
+ * 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 BlockVector3 getMinimum(BlockVector3 v2) {
+ return new BlockVector3(
+ Math.min(x, v2.x),
+ Math.min(y, v2.y),
+ Math.min(z, v2.z)
+ );
+ }
+
+ /**
+ * Gets the maximum components of two vectors.
+ *
+ * @param v2 the second vector
+ * @return maximum
+ */
+ public BlockVector3 getMaximum(BlockVector3 v2) {
+ return new BlockVector3(
+ Math.max(x, v2.x),
+ Math.max(y, v2.y),
+ Math.max(z, v2.z)
+ );
+ }
+
+ /**
+ * 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);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof BlockVector3)) {
+ return false;
+ }
+
+ BlockVector3 other = (BlockVector3) 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 "(" + x + ", " + y + ", " + z + ")";
+ }
+
+}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java
new file mode 100644
index 000000000..e403cc5ea
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java
@@ -0,0 +1,471 @@
+/*
+ * 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.math;
+
+import com.sk89q.worldedit.math.transform.AffineTransform;
+
+/**
+ * An immutable 2-dimensional vector.
+ */
+public final class Vector2 {
+
+ public static final Vector2 ZERO = new Vector2(0, 0);
+ public static final Vector2 UNIT_X = new Vector2(1, 0);
+ public static final Vector2 UNIT_Z = new Vector2(0, 1);
+ public static final Vector2 ONE = new Vector2(1, 1);
+
+ private final double x, z;
+
+ /**
+ * Construct an instance.
+ *
+ * @param x the X coordinate
+ * @param z the Z coordinate
+ */
+ public Vector2(double x, double z) {
+ this.x = x;
+ this.z = z;
+ }
+
+ /**
+ * Copy another vector.
+ *
+ * @param other the other vector
+ */
+ public Vector2(Vector2 other) {
+ this.x = other.x;
+ this.z = other.z;
+ }
+
+ /**
+ * Get the X coordinate.
+ *
+ * @return the x coordinate
+ */
+ public double getX() {
+ return x;
+ }
+
+ /**
+ * Set the X coordinate.
+ *
+ * @param x the new X
+ * @return a new vector
+ */
+ public Vector2 withX(double x) {
+ return new Vector2(x, z);
+ }
+
+ /**
+ * Get the Z coordinate.
+ *
+ * @return the z coordinate
+ */
+ public double getZ() {
+ return z;
+ }
+
+ /**
+ * Set the Z coordinate.
+ *
+ * @param z the new Z
+ * @return a new vector
+ */
+ public Vector2 withZ(double z) {
+ return new Vector2(x, 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 Vector2 add(Vector2 other) {
+ return add(other.x, other.z);
+ }
+
+ /**
+ * Add another vector to this vector and return the result as a new vector.
+ *
+ * @param x the value to add
+ * @param z the value to add
+ * @return a new vector
+ */
+ public Vector2 add(double x, double z) {
+ return new Vector2(this.x + x, this.z + z);
+ }
+
+ /**
+ * 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 Vector2 add(Vector2... others) {
+ double newX = x, newZ = z;
+
+ for (Vector2 other : others) {
+ newX += other.x;
+ newZ += other.z;
+ }
+
+ return new Vector2(newX, newZ);
+ }
+
+ /**
+ * Subtract another vector from this vector and return the result
+ * as a new vector.
+ *
+ * @param other the other vector
+ * @return a new vector
+ */
+ public Vector2 subtract(Vector2 other) {
+ return subtract(other.x, other.z);
+ }
+
+ /**
+ * Subtract another vector from this vector and return the result
+ * as a new vector.
+ *
+ * @param x the value to subtract
+ * @param z the value to subtract
+ * @return a new vector
+ */
+ public Vector2 subtract(double x, double z) {
+ return new Vector2(this.x - x, this.z - z);
+ }
+
+ /**
+ * 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 Vector2 subtract(Vector2... others) {
+ double newX = x, newZ = z;
+
+ for (Vector2 other : others) {
+ newX -= other.x;
+ newZ -= other.z;
+ }
+
+ return new Vector2(newX, newZ);
+ }
+
+ /**
+ * Multiply this vector by another vector on each component.
+ *
+ * @param other the other vector
+ * @return a new vector
+ */
+ public Vector2 multiply(Vector2 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 Vector2 multiply(double x, double z) {
+ return new Vector2(this.x * x, this.z * z);
+ }
+
+ /**
+ * Multiply this vector by zero or more vectors on each component.
+ *
+ * @param others an array of vectors
+ * @return a new vector
+ */
+ public Vector2 multiply(Vector2... others) {
+ double newX = x, newZ = z;
+
+ for (Vector2 other : others) {
+ newX *= other.x;
+ newZ *= other.z;
+ }
+
+ return new Vector2(newX, newZ);
+ }
+
+ /**
+ * Perform scalar multiplication and return a new vector.
+ *
+ * @param n the value to multiply
+ * @return a new vector
+ */
+ public Vector2 multiply(double n) {
+ return multiply(n, n);
+ }
+
+ /**
+ * Divide this vector by another vector on each component.
+ *
+ * @param other the other vector
+ * @return a new vector
+ */
+ public Vector2 divide(Vector2 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 Vector2 divide(double x, double z) {
+ return new Vector2(this.x / x, this.z / z);
+ }
+
+ /**
+ * Perform scalar division and return a new vector.
+ *
+ * @param n the value to divide by
+ * @return a new vector
+ */
+ public Vector2 divide(double 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 double 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(Vector2 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(Vector2 other) {
+ double dx = other.x - x;
+ double dz = other.z - z;
+ return dx * dx + dz * dz;
+ }
+
+ /**
+ * Get the normalized vector, which is the vector divided by its
+ * length, as a new vector.
+ *
+ * @return a new vector
+ */
+ public Vector2 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(Vector2 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(Vector2 min, Vector2 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 Vector2 floor() {
+ return new Vector2(Math.floor(x), Math.floor(z));
+ }
+
+ /**
+ * Rounds all components up.
+ *
+ * @return a new vector
+ */
+ public Vector2 ceil() {
+ return new Vector2(Math.ceil(x), Math.ceil(z));
+ }
+
+ /**
+ * Rounds all components to the closest integer.
+ *
+ * Components < 0.5 are rounded down, otherwise up.
+ *
+ * @return a new vector
+ */
+ public Vector2 round() {
+ return new Vector2(Math.floor(x + 0.5), Math.floor(z + 0.5));
+ }
+
+ /**
+ * Returns a vector with the absolute values of the components of
+ * this vector.
+ *
+ * @return a new vector
+ */
+ public Vector2 abs() {
+ return new Vector2(Math.abs(x), Math.abs(z));
+ }
+
+ /**
+ * 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 Vector2 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;
+ return new Vector2(
+ x2 + aboutX + translateX,
+ z2 + aboutZ + translateZ);
+ }
+
+ /**
+ * Gets the minimum components of two vectors.
+ *
+ * @param v2 the second vector
+ * @return minimum
+ */
+ public Vector2 getMinimum(Vector2 v2) {
+ return new Vector2(
+ Math.min(x, v2.x),
+ Math.min(z, v2.z)
+ );
+ }
+
+ /**
+ * Gets the maximum components of two vectors.
+ *
+ * @param v2 the second vector
+ * @return maximum
+ */
+ public Vector2 getMaximum(Vector2 v2) {
+ return new Vector2(
+ Math.max(x, v2.x),
+ Math.max(z, v2.z)
+ );
+ }
+
+ public static BlockVector2 toBlockPoint(double x, double z) {
+ return new BlockVector2(x, z);
+ }
+
+ /**
+ * Create a new {@link BlockVector2} from this vector.
+ *
+ * @return a new {@link BlockVector2}
+ */
+ public BlockVector2 toBlockPoint() {
+ return toBlockPoint(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);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Vector2)) {
+ return false;
+ }
+
+ Vector2 other = (Vector2) obj;
+ return other.x == this.x && other.z == this.z;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 17;
+ hash = 31 * hash + Double.hashCode(x);
+ hash = 31 * hash + Double.hashCode(z);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + x + ", " + z + ")";
+ }
+
+}
\ No newline at end of file
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java
new file mode 100644
index 000000000..59847cbf2
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java
@@ -0,0 +1,596 @@
+/*
+ * 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.math;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import com.google.common.collect.ComparisonChain;
+import com.sk89q.worldedit.math.transform.AffineTransform;
+
+import java.util.Comparator;
+
+/**
+ * An immutable 3-dimensional vector.
+ */
+public final class Vector3 {
+
+ public static final Vector3 ZERO = new Vector3(0, 0, 0);
+ public static final Vector3 UNIT_X = new Vector3(1, 0, 0);
+ public static final Vector3 UNIT_Y = new Vector3(0, 1, 0);
+ public static final Vector3 UNIT_Z = new Vector3(0, 0, 1);
+ public static final Vector3 ONE = new Vector3(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;
+ }
+
+ private final double x, y, z;
+
+ /**
+ * Construct an instance.
+ *
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param z the Z coordinate
+ */
+ public Vector3(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ /**
+ * Copy another vector.
+ *
+ * @param other another vector to make a copy of
+ */
+ public Vector3(Vector3 other) {
+ this.x = other.x;
+ this.y = other.y;
+ this.z = other.z;
+ }
+
+ /**
+ * Get the X coordinate.
+ *
+ * @return the x coordinate
+ */
+ public double getX() {
+ return x;
+ }
+
+ /**
+ * Set the X coordinate.
+ *
+ * @param x the new X
+ * @return a new vector
+ */
+ public Vector3 withX(double x) {
+ return new Vector3(x, y, z);
+ }
+
+ /**
+ * Get the Y coordinate.
+ *
+ * @return the y coordinate
+ */
+ public double getY() {
+ return y;
+ }
+
+ /**
+ * Set the Y coordinate.
+ *
+ * @param y the new Y
+ * @return a new vector
+ */
+ public Vector3 withY(double y) {
+ return new Vector3(x, y, z);
+ }
+
+ /**
+ * Get the Z coordinate.
+ *
+ * @return the z coordinate
+ */
+ public double getZ() {
+ return z;
+ }
+
+ /**
+ * Set the Z coordinate.
+ *
+ * @param z the new Z
+ * @return a new vector
+ */
+ public Vector3 withZ(double z) {
+ return new Vector3(x, y, 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 Vector3 add(Vector3 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 Vector3 add(double x, double y, double z) {
+ return new Vector3(this.x + x, this.y + y, this.z + z);
+ }
+
+ /**
+ * 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 Vector3 add(Vector3... others) {
+ double newX = x, newY = y, newZ = z;
+
+ for (Vector3 other : others) {
+ newX += other.x;
+ newY += other.y;
+ newZ += other.z;
+ }
+
+ return new Vector3(newX, newY, newZ);
+ }
+
+ /**
+ * Subtract another vector from this vector and return the result
+ * as a new vector.
+ *
+ * @param other the other vector
+ * @return a new vector
+ */
+ public Vector3 subtract(Vector3 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 Vector3 subtract(double x, double y, double z) {
+ return new Vector3(this.x - x, this.y - y, this.z - z);
+ }
+
+ /**
+ * 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 Vector3 subtract(Vector3... others) {
+ double newX = x, newY = y, newZ = z;
+
+ for (Vector3 other : others) {
+ newX -= other.x;
+ newY -= other.y;
+ newZ -= other.z;
+ }
+
+ return new Vector3(newX, newY, newZ);
+ }
+
+ /**
+ * Multiply this vector by another vector on each component.
+ *
+ * @param other the other vector
+ * @return a new vector
+ */
+ public Vector3 multiply(Vector3 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 Vector3 multiply(double x, double y, double z) {
+ return new Vector3(this.x * x, this.y * y, this.z * z);
+ }
+
+ /**
+ * Multiply this vector by zero or more vectors on each component.
+ *
+ * @param others an array of vectors
+ * @return a new vector
+ */
+ public Vector3 multiply(Vector3... others) {
+ double newX = x, newY = y, newZ = z;
+
+ for (Vector3 other : others) {
+ newX *= other.x;
+ newY *= other.y;
+ newZ *= other.z;
+ }
+
+ return new Vector3(newX, newY, newZ);
+ }
+
+ /**
+ * Perform scalar multiplication and return a new vector.
+ *
+ * @param n the value to multiply
+ * @return a new vector
+ */
+ public Vector3 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 Vector3 divide(Vector3 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 Vector3 divide(double x, double y, double z) {
+ return new Vector3(this.x / x, this.y / y, this.z / z);
+ }
+
+ /**
+ * Perform scalar division and return a new vector.
+ *
+ * @param n the value to divide by
+ * @return a new vector
+ */
+ public Vector3 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.x - x;
+ double dy = other.y - y;
+ double 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 Vector3 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(Vector3 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(Vector3 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(Vector3 min, Vector3 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 Vector3 clampY(int min, int max) {
+ checkArgument(min <= max, "minimum cannot be greater than maximum");
+ if (y < min) {
+ return new Vector3(x, min, z);
+ }
+ if (y > max) {
+ return new Vector3(x, max, z);
+ }
+ return this;
+ }
+
+ /**
+ * Floors the values of all components.
+ *
+ * @return a new vector
+ */
+ public Vector3 floor() {
+ return new Vector3(Math.floor(x), Math.floor(y), Math.floor(z));
+ }
+
+ /**
+ * Rounds all components up.
+ *
+ * @return a new vector
+ */
+ public Vector3 ceil() {
+ return new Vector3(Math.ceil(x), Math.ceil(y), Math.ceil(z));
+ }
+
+ /**
+ * Rounds all components to the closest integer.
+ *
+ * Components < 0.5 are rounded down, otherwise up.
+ *
+ * @return a new vector
+ */
+ public Vector3 round() {
+ return new Vector3(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 0.5));
+ }
+
+ /**
+ * Returns a vector with the absolute values of the components of
+ * this vector.
+ *
+ * @return a new vector
+ */
+ public Vector3 abs() {
+ return new Vector3(Math.abs(x), Math.abs(y), Math.abs(z));
+ }
+
+ /**
+ * 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 Vector3 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;
+
+ return new Vector3(
+ x2 + aboutX + translateX,
+ y,
+ z2 + aboutZ + translateZ
+ );
+ }
+
+ /**
+ * 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 Vector3 getMinimum(Vector3 v2) {
+ return new Vector3(
+ Math.min(x, v2.x),
+ Math.min(y, v2.y),
+ Math.min(z, v2.z)
+ );
+ }
+
+ /**
+ * Gets the maximum components of two vectors.
+ *
+ * @param v2 the second vector
+ * @return maximum
+ */
+ public Vector3 getMaximum(Vector3 v2) {
+ return new Vector3(
+ Math.max(x, v2.x),
+ Math.max(y, v2.y),
+ Math.max(z, v2.z)
+ );
+ }
+
+ /**
+ * 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);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Vector3)) {
+ return false;
+ }
+
+ Vector3 other = (Vector3) 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 "(" + x + ", " + y + ", " + z + ")";
+ }
+
+}
\ No newline at end of file
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 0cfd4c35f..c12beee56 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
@@ -23,7 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
@@ -105,7 +105,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();
@@ -134,17 +134,17 @@ 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)
- BlockState existing = session.getBlock(new Vector(xr, curHeight, zr));
+ BlockState existing = session.getBlock(new BlockVector3(xr, curHeight, zr));
// Skip water/lava
if (existing.getBlockType() != BlockTypes.WATER && existing.getBlockType() != BlockTypes.LAVA) {
- session.setBlock(new Vector(xr, newHeight, zr), existing);
+ 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 Vector(xr, originY + y, zr), session.getBlock(new Vector(xr, originY + copyFrom, zr)));
+ session.setBlock(new BlockVector3(xr, originY + y, zr), session.getBlock(new BlockVector3(xr, originY + copyFrom, zr)));
++blocksChanged;
}
}
@@ -152,18 +152,18 @@ public class HeightMap {
// Shrink -- start from bottom
for (int y = 0; y < newHeight - originY; ++y) {
int copyFrom = (int) (y * scale);
- session.setBlock(new Vector(xr, originY + y, zr), session.getBlock(new Vector(xr, originY + copyFrom, zr)));
+ session.setBlock(new BlockVector3(xr, originY + y, zr), session.getBlock(new BlockVector3(xr, originY + copyFrom, zr)));
++blocksChanged;
}
// Set the top block of the column to be the same type
// (this could otherwise go wrong with rounding)
- session.setBlock(new Vector(xr, newHeight, zr), session.getBlock(new Vector(xr, curHeight, zr)));
+ session.setBlock(new BlockVector3(xr, newHeight, zr), session.getBlock(new BlockVector3(xr, curHeight, zr)));
++blocksChanged;
// Fill rest with air
for (int y = newHeight + 1; y <= curHeight; ++y) {
- session.setBlock(new Vector(xr, y, zr), fillerAir);
+ session.setBlock(new BlockVector3(xr, y, zr), fillerAir);
++blocksChanged;
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java
index 007977d58..af191dc72 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java
@@ -19,8 +19,8 @@
package com.sk89q.worldedit.math.geom;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.Vector2;
import java.util.ArrayList;
import java.util.List;
@@ -40,9 +40,9 @@ public final class Polygons {
* @param center the center point of the cylinder
* @param radius the radius of the cylinder
* @param maxPoints max points to be used for the calculation
- * @return a list of {@link BlockVector2D} which resemble the shape as a polygon
+ * @return a list of {@link BlockVector2} which resemble the shape as a polygon
*/
- public static List polygonizeCylinder(Vector2D center, Vector2D radius, int maxPoints) {
+ public static List polygonizeCylinder(BlockVector2 center, Vector2 radius, int maxPoints) {
int nPoints = (int) Math.ceil(Math.PI*radius.length());
// These strange semantics for maxPoints are copied from the selectSecondary method.
@@ -50,11 +50,11 @@ public final class Polygons {
nPoints = maxPoints - 1;
}
- final List points = new ArrayList<>(nPoints);
+ final List points = new ArrayList<>(nPoints);
for (int i = 0; i < nPoints; ++i) {
double angle = i * (2.0 * Math.PI) / nPoints;
- final Vector2D pos = new Vector2D(Math.cos(angle), Math.sin(angle));
- final BlockVector2D blockVector2D = pos.multiply(radius).add(center).toBlockVector2D();
+ final Vector2 pos = new Vector2(Math.cos(angle), Math.sin(angle));
+ final BlockVector2 blockVector2D = pos.multiply(radius).toBlockPoint().add(center);
points.add(blockVector2D);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java
index 68df24b0d..28ce2c492 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java
@@ -21,7 +21,7 @@
package com.sk89q.worldedit.math.interpolation;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
import java.util.List;
@@ -44,7 +44,7 @@ public interface Interpolation {
* @param position the position to interpolate
* @return the result
*/
- Vector getPosition(double position);
+ Vector3 getPosition(double position);
/**
* Gets the result of f'(position).
@@ -52,7 +52,7 @@ public interface Interpolation {
* @param position the position to interpolate
* @return the result
*/
- Vector get1stDerivative(double position);
+ Vector3 get1stDerivative(double position);
/**
* Gets the result of ∫ab|f'(t)| dt.
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java
index f5f41313b..3d87135f9 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java
@@ -23,7 +23,7 @@ package com.sk89q.worldedit.math.interpolation;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
import java.util.Collections;
import java.util.List;
@@ -37,10 +37,10 @@ import java.util.List;
public class KochanekBartelsInterpolation implements Interpolation {
private List nodes;
- private Vector[] coeffA;
- private Vector[] coeffB;
- private Vector[] coeffC;
- private Vector[] coeffD;
+ private Vector3[] coeffA;
+ private Vector3[] coeffB;
+ private Vector3[] coeffC;
+ private Vector3[] coeffD;
private double scaling;
public KochanekBartelsInterpolation() {
@@ -57,10 +57,10 @@ public class KochanekBartelsInterpolation implements Interpolation {
private void recalc() {
final int nNodes = nodes.size();
- coeffA = new Vector[nNodes];
- coeffB = new Vector[nNodes];
- coeffC = new Vector[nNodes];
- coeffD = new Vector[nNodes];
+ coeffA = new Vector3[nNodes];
+ coeffB = new Vector3[nNodes];
+ coeffC = new Vector3[nNodes];
+ coeffD = new Vector3[nNodes];
if (nNodes == 0)
return;
@@ -107,11 +107,11 @@ public class KochanekBartelsInterpolation implements Interpolation {
* @param f4 coefficient for baseIndex+2
* @return linear combination of nodes[n-1..n+2] with f1..4
*/
- private Vector linearCombination(int baseIndex, double f1, double f2, double f3, double f4) {
- final Vector r1 = retrieve(baseIndex - 1).multiply(f1);
- final Vector r2 = retrieve(baseIndex ).multiply(f2);
- final Vector r3 = retrieve(baseIndex + 1).multiply(f3);
- final Vector r4 = retrieve(baseIndex + 2).multiply(f4);
+ private Vector3 linearCombination(int baseIndex, double f1, double f2, double f3, double f4) {
+ final Vector3 r1 = retrieve(baseIndex - 1).multiply(f1);
+ final Vector3 r2 = retrieve(baseIndex ).multiply(f2);
+ final Vector3 r3 = retrieve(baseIndex + 1).multiply(f3);
+ final Vector3 r4 = retrieve(baseIndex + 2).multiply(f4);
return r1.add(r2).add(r3).add(r4);
}
@@ -122,7 +122,7 @@ public class KochanekBartelsInterpolation implements Interpolation {
* @param index node index to retrieve
* @return nodes[clamp(0, nodes.length-1)]
*/
- private Vector retrieve(int index) {
+ private Vector3 retrieve(int index) {
if (index < 0)
return fastRetrieve(0);
@@ -132,12 +132,12 @@ public class KochanekBartelsInterpolation implements Interpolation {
return fastRetrieve(index);
}
- private Vector fastRetrieve(int index) {
+ private Vector3 fastRetrieve(int index) {
return nodes.get(index).getPosition();
}
@Override
- public Vector getPosition(double position) {
+ public Vector3 getPosition(double position) {
if (coeffA == null)
throw new IllegalStateException("Must call setNodes first.");
@@ -149,16 +149,16 @@ public class KochanekBartelsInterpolation implements Interpolation {
final int index = (int) Math.floor(position);
final double remainder = position - index;
- final Vector a = coeffA[index];
- final Vector b = coeffB[index];
- final Vector c = coeffC[index];
- final Vector d = coeffD[index];
+ final Vector3 a = coeffA[index];
+ final Vector3 b = coeffB[index];
+ final Vector3 c = coeffC[index];
+ final Vector3 d = coeffD[index];
return a.multiply(remainder).add(b).multiply(remainder).add(c).multiply(remainder).add(d);
}
@Override
- public Vector get1stDerivative(double position) {
+ public Vector3 get1stDerivative(double position) {
if (coeffA == null)
throw new IllegalStateException("Must call setNodes first.");
@@ -170,9 +170,9 @@ public class KochanekBartelsInterpolation implements Interpolation {
final int index = (int) Math.floor(position);
//final double remainder = position - index;
- final Vector a = coeffA[index];
- final Vector b = coeffB[index];
- final Vector c = coeffC[index];
+ final Vector3 a = coeffA[index];
+ final Vector3 b = coeffB[index];
+ final Vector3 c = coeffC[index];
return a.multiply(1.5*position - 3.0*index).add(b).multiply(2.0*position).add(a.multiply(1.5*index).subtract(b).multiply(2.0*index)).add(c).multiply(scaling);
}
@@ -219,9 +219,9 @@ public class KochanekBartelsInterpolation implements Interpolation {
}
private double arcLengthRecursive(int index, double remainderLeft, double remainderRight) {
- final Vector a = coeffA[index].multiply(3.0);
- final Vector b = coeffB[index].multiply(2.0);
- final Vector c = coeffC[index];
+ final Vector3 a = coeffA[index].multiply(3.0);
+ final Vector3 b = coeffB[index].multiply(2.0);
+ final Vector3 c = coeffC[index];
final int nPoints = 8;
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 ea1962119..7b701f5fe 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
@@ -23,7 +23,7 @@ package com.sk89q.worldedit.math.interpolation;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
import java.util.List;
@@ -42,7 +42,7 @@ public class LinearInterpolation implements Interpolation {
}
@Override
- public Vector getPosition(double position) {
+ public Vector3 getPosition(double position) {
if (nodes == null)
throw new IllegalStateException("Must call setNodes first.");
@@ -54,8 +54,8 @@ public class LinearInterpolation implements Interpolation {
final int index1 = (int) Math.floor(position);
final double remainder = position - index1;
- final Vector position1 = nodes.get(index1).getPosition();
- final Vector position2 = nodes.get(index1 + 1).getPosition();
+ final Vector3 position1 = nodes.get(index1).getPosition();
+ final Vector3 position2 = nodes.get(index1 + 1).getPosition();
return position1.multiply(1.0 - remainder).add(position2.multiply(remainder));
}
@@ -76,7 +76,7 @@ public class LinearInterpolation implements Interpolation {
*/
@Override
- public Vector get1stDerivative(double position) {
+ public Vector3 get1stDerivative(double position) {
if (nodes == null)
throw new IllegalStateException("Must call setNodes first.");
@@ -87,8 +87,8 @@ public class LinearInterpolation implements Interpolation {
final int index1 = (int) Math.floor(position);
- final Vector position1 = nodes.get(index1).getPosition();
- final Vector position2 = nodes.get(index1 + 1).getPosition();
+ final Vector3 position1 = nodes.get(index1).getPosition();
+ final Vector3 position2 = nodes.get(index1 + 1).getPosition();
return position2.subtract(position1);
}
@@ -135,8 +135,8 @@ public class LinearInterpolation implements Interpolation {
}
private double arcLengthRecursive(int index, double remainderA, double remainderB) {
- final Vector position1 = nodes.get(index).getPosition();
- final Vector position2 = nodes.get(index + 1).getPosition();
+ final Vector3 position1 = nodes.get(index).getPosition();
+ final Vector3 position2 = nodes.get(index + 1).getPosition();
return position1.distance(position2) * (remainderB - remainderA);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java
index ce604824c..c2bc1e93b 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java
@@ -21,7 +21,7 @@
package com.sk89q.worldedit.math.interpolation;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
/**
* Represents a node for interpolation.
@@ -31,14 +31,14 @@ import com.sk89q.worldedit.Vector;
*/
public class Node {
- private Vector position;
+ private Vector3 position;
private double tension;
private double bias;
private double continuity;
public Node() {
- this(new Vector(0, 0, 0));
+ this(new Vector3(0, 0, 0));
}
public Node(Node other) {
@@ -49,16 +49,16 @@ public class Node {
this.continuity = other.continuity;
}
- public Node(Vector position) {
+ public Node(Vector3 position) {
this.position = position;
}
- public Vector getPosition() {
+ public Vector3 getPosition() {
return position;
}
- public void setPosition(Vector position) {
+ public void setPosition(Vector3 position) {
this.position = position;
}
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 d6920b829..29a3ee5ee 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
@@ -23,7 +23,7 @@ package com.sk89q.worldedit.math.interpolation;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
import java.util.List;
import java.util.Map.Entry;
@@ -65,7 +65,7 @@ public class ReparametrisingInterpolation implements Interpolation {
}
@Override
- public Vector getPosition(double position) {
+ public Vector3 getPosition(double position) {
if (position > 1)
return null;
@@ -73,7 +73,7 @@ public class ReparametrisingInterpolation implements Interpolation {
}
@Override
- public Vector get1stDerivative(double position) {
+ public Vector3 get1stDerivative(double position) {
if (position > 1)
return null;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java
index dbf7720fd..1da9d5b2d 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java
@@ -19,8 +19,9 @@
package com.sk89q.worldedit.math.noise;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.Vector2;
+import com.sk89q.worldedit.math.Vector3;
+
import net.royawesome.jlibnoise.module.Module;
import java.util.Random;
@@ -46,12 +47,12 @@ abstract class JLibNoiseGenerator implements NoiseGenerator {
public abstract int getSeed();
@Override
- public float noise(Vector2D position) {
+ public float noise(Vector2 position) {
return forceRange(module.GetValue(position.getX(), 0, position.getZ()));
}
@Override
- public float noise(Vector position) {
+ public float noise(Vector3 position) {
return forceRange(module.GetValue(position.getX(), position.getY(), position.getZ()));
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/NoiseGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/NoiseGenerator.java
index bb57d23f0..185e41fbb 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/NoiseGenerator.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/NoiseGenerator.java
@@ -19,8 +19,8 @@
package com.sk89q.worldedit.math.noise;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.Vector2;
+import com.sk89q.worldedit.math.Vector3;
/**
* Generates noise in a deterministic or non-deterministic manner.
@@ -34,7 +34,7 @@ public interface NoiseGenerator {
* @param position the position
* @return a noise value between 0 (inclusive) and 1 (inclusive)
*/
- float noise(Vector2D position);
+ float noise(Vector2 position);
/**
* Get the noise value for the given position. The returned value may
@@ -43,6 +43,6 @@ public interface NoiseGenerator {
* @param position the position
* @return a noise value between 0 (inclusive) and 1 (inclusive)
*/
- float noise(Vector position);
+ float noise(Vector3 position);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java
index 6daed2841..ff3421404 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java
@@ -19,8 +19,8 @@
package com.sk89q.worldedit.math.noise;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.Vector2;
+import com.sk89q.worldedit.math.Vector3;
import java.util.Random;
@@ -50,12 +50,12 @@ public class RandomNoise implements NoiseGenerator {
}
@Override
- public float noise(Vector2D position) {
+ public float noise(Vector2 position) {
return random.nextFloat();
}
@Override
- public float noise(Vector position) {
+ public float noise(Vector3 position) {
return random.nextFloat();
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java
index 36db0566c..376fd0b33 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java
@@ -19,8 +19,9 @@
package com.sk89q.worldedit.math.transform;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MathUtils;
+import com.sk89q.worldedit.math.Vector3;
/**
* An affine transform.
@@ -236,7 +237,11 @@ public class AffineTransform implements Transform {
n20, n21, n22, n23);
}
- public AffineTransform translate(Vector vec) {
+ public AffineTransform translate(Vector3 vec) {
+ return translate(vec.getX(), vec.getY(), vec.getZ());
+ }
+
+ public AffineTransform translate(BlockVector3 vec) {
return translate(vec.getX(), vec.getY(), vec.getZ());
}
@@ -282,13 +287,13 @@ public class AffineTransform implements Transform {
return concatenate(new AffineTransform(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0));
}
- public AffineTransform scale(Vector vec) {
+ public AffineTransform scale(Vector3 vec) {
return scale(vec.getX(), vec.getY(), vec.getZ());
}
@Override
- public Vector apply(Vector vector) {
- return new Vector(
+ public Vector3 apply(Vector3 vector) {
+ return new Vector3(
vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03,
vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13,
vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java
index 646e2a209..e5f2a2586 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
@@ -21,7 +21,7 @@ package com.sk89q.worldedit.math.transform;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
import java.util.ArrayList;
import java.util.Arrays;
@@ -66,7 +66,7 @@ public class CombinedTransform implements Transform {
}
@Override
- public Vector apply(Vector vector) {
+ public Vector3 apply(Vector3 vector) {
for (Transform transform : transforms) {
vector = transform.apply(vector);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Identity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Identity.java
index b0f4dddef..f9f1ed125 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Identity.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Identity.java
@@ -19,7 +19,7 @@
package com.sk89q.worldedit.math.transform;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
/**
* Makes no transformation to given vectors.
@@ -32,7 +32,7 @@ public class Identity implements Transform {
}
@Override
- public Vector apply(Vector vector) {
+ public Vector3 apply(Vector3 vector) {
return vector;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transform.java
index b8df8bcbd..e12030022 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transform.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transform.java
@@ -19,10 +19,10 @@
package com.sk89q.worldedit.math.transform;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
/**
- * Makes a transformation of {@link Vector}s.
+ * Makes a transformation of {@link Vector3}s.
*/
public interface Transform {
@@ -41,7 +41,7 @@ public interface Transform {
* @param input the input
* @return the result
*/
- Vector apply(Vector input);
+ Vector3 apply(Vector3 input);
/**
* Create a new inverse transform.
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 44f7070cb..cdaf362db 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,10 +19,9 @@
package com.sk89q.worldedit.regions;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.iterator.RegionIterator;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.storage.ChunkStore;
@@ -42,8 +41,8 @@ public abstract class AbstractRegion implements Region {
}
@Override
- public Vector getCenter() {
- return getMinimumPoint().add(getMaximumPoint()).divide(2);
+ public Vector3 getCenter() {
+ return getMinimumPoint().add(getMaximumPoint()).toVector3().divide(2);
}
/**
@@ -52,7 +51,7 @@ public abstract class AbstractRegion implements Region {
* @return iterator of points inside the region
*/
@Override
- public Iterator iterator() {
+ public Iterator iterator() {
return new RegionIterator(this);
}
@@ -67,7 +66,7 @@ public abstract class AbstractRegion implements Region {
}
@Override
- public void shift(Vector change) throws RegionOperationException {
+ public void shift(BlockVector3 change) throws RegionOperationException {
expand(change);
contract(change);
}
@@ -82,20 +81,20 @@ public abstract class AbstractRegion implements Region {
}
@Override
- public List polygonize(int maxPoints) {
+ public List polygonize(int maxPoints) {
if (maxPoints >= 0 && maxPoints < 4) {
throw new IllegalArgumentException("Cannot polygonize an AbstractRegion with no overridden polygonize method into less than 4 points.");
}
- final BlockVector min = getMinimumPoint().toBlockVector();
- final BlockVector max = getMaximumPoint().toBlockVector();
+ final BlockVector3 min = getMinimumPoint();
+ final BlockVector3 max = getMaximumPoint();
- final List points = new ArrayList<>(4);
+ final List points = new ArrayList<>(4);
- points.add(new BlockVector2D(min.getX(), min.getZ()));
- points.add(new BlockVector2D(min.getX(), max.getZ()));
- points.add(new BlockVector2D(max.getX(), max.getZ()));
- points.add(new BlockVector2D(max.getX(), min.getZ()));
+ points.add(new BlockVector2(min.getX(), min.getZ()));
+ points.add(new BlockVector2(min.getX(), max.getZ()));
+ points.add(new BlockVector2(max.getX(), max.getZ()));
+ points.add(new BlockVector2(max.getX(), min.getZ()));
return points;
}
@@ -107,12 +106,12 @@ public abstract class AbstractRegion implements Region {
*/
@Override
public int getArea() {
- Vector min = getMinimumPoint();
- Vector max = getMaximumPoint();
+ BlockVector3 min = getMinimumPoint();
+ BlockVector3 max = getMaximumPoint();
- return (int)((max.getX() - min.getX() + 1) *
- (max.getY() - min.getY() + 1) *
- (max.getZ() - min.getZ() + 1));
+ return (max.getX() - min.getX() + 1) *
+ (max.getY() - min.getY() + 1) *
+ (max.getZ() - min.getZ() + 1);
}
/**
@@ -122,10 +121,10 @@ public abstract class AbstractRegion implements Region {
*/
@Override
public int getWidth() {
- Vector min = getMinimumPoint();
- Vector max = getMaximumPoint();
+ BlockVector3 min = getMinimumPoint();
+ BlockVector3 max = getMaximumPoint();
- return (int) (max.getX() - min.getX() + 1);
+ return max.getX() - min.getX() + 1;
}
/**
@@ -135,10 +134,10 @@ public abstract class AbstractRegion implements Region {
*/
@Override
public int getHeight() {
- Vector min = getMinimumPoint();
- Vector max = getMaximumPoint();
+ BlockVector3 min = getMinimumPoint();
+ BlockVector3 max = getMaximumPoint();
- return (int) (max.getY() - min.getY() + 1);
+ return max.getY() - min.getY() + 1;
}
/**
@@ -148,10 +147,10 @@ public abstract class AbstractRegion implements Region {
*/
@Override
public int getLength() {
- Vector min = getMinimumPoint();
- Vector max = getMaximumPoint();
+ BlockVector3 min = getMinimumPoint();
+ BlockVector3 max = getMaximumPoint();
- return (int) (max.getZ() - min.getZ() + 1);
+ return max.getZ() - min.getZ() + 1;
}
/**
@@ -160,21 +159,21 @@ public abstract class AbstractRegion implements Region {
* @return a set of chunks
*/
@Override
- public Set getChunks() {
- final Set chunks = new HashSet<>();
+ public Set getChunks() {
+ final Set chunks = new HashSet<>();
- final Vector min = getMinimumPoint();
- final Vector max = getMaximumPoint();
+ final BlockVector3 min = getMinimumPoint();
+ final BlockVector3 max = getMaximumPoint();
final int minY = min.getBlockY();
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
- if (!contains(new Vector(x, minY, z))) {
+ if (!contains(new BlockVector3(x, minY, z))) {
continue;
}
- chunks.add(new BlockVector2D(
+ chunks.add(new BlockVector2(
x >> ChunkStore.CHUNK_SHIFTS,
z >> ChunkStore.CHUNK_SHIFTS
));
@@ -185,20 +184,20 @@ public abstract class AbstractRegion implements Region {
}
@Override
- public Set getChunkCubes() {
- final Set chunks = new HashSet<>();
+ public Set getChunkCubes() {
+ final Set chunks = new HashSet<>();
- final Vector min = getMinimumPoint();
- final Vector max = getMaximumPoint();
+ final BlockVector3 min = getMinimumPoint();
+ final BlockVector3 max = getMaximumPoint();
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
- if (!contains(new Vector(x, y, z))) {
+ if (!contains(new BlockVector3(x, y, z))) {
continue;
}
- chunks.add(new BlockVector(
+ chunks.add(new BlockVector3(
x >> ChunkStore.CHUNK_SHIFTS,
y >> ChunkStore.CHUNK_SHIFTS,
z >> ChunkStore.CHUNK_SHIFTS
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java
index fce016e23..ce1fc5b22 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java
@@ -21,7 +21,8 @@ package com.sk89q.worldedit.regions;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.polyhedron.Edge;
import com.sk89q.worldedit.regions.polyhedron.Triangle;
import com.sk89q.worldedit.world.World;
@@ -40,7 +41,7 @@ public class ConvexPolyhedralRegion 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.
@@ -50,25 +51,25 @@ public class ConvexPolyhedralRegion 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.
+ * The last triangle that caused a {@link #contains(Vector3)} to classify a point as "outside". Used for optimization.
*/
private Triangle lastTriangle;
@@ -108,7 +109,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
minimumPoint = null;
maximumPoint = null;
- centerAccum = Vector.ZERO;
+ centerAccum = BlockVector3.ZERO;
lastTriangle = null;
}
@@ -118,7 +119,7 @@ public class ConvexPolyhedralRegion 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
@@ -132,7 +133,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
return false;
}
- if (containsRaw(vertex)) {
+ if (containsRaw(vertex.toVector3())) {
return vertexBacklog.add(vertex);
}
}
@@ -144,8 +145,8 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
if (minimumPoint == null) {
minimumPoint = maximumPoint = vertex;
} else {
- minimumPoint = Vector.getMinimum(minimumPoint, vertex);
- maximumPoint = Vector.getMaximum(maximumPoint, vertex);
+ minimumPoint = minimumPoint.getMinimum(vertex);
+ maximumPoint = maximumPoint.getMaximum(vertex);
}
@@ -158,10 +159,10 @@ public class ConvexPolyhedralRegion 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[1], v[2])));
- triangles.add((new Triangle(v[0], v[2], v[1])));
+ triangles.add((new Triangle(v[0].toVector3(), v[1].toVector3(), v[2].toVector3())));
+ triangles.add((new Triangle(v[0].toVector3(), v[2].toVector3(), v[1].toVector3())));
return true;
}
@@ -171,7 +172,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
final Triangle triangle = it.next();
// If the triangle can't be seen, it's not relevant
- if (!triangle.above(vertex)) {
+ if (!triangle.above(vertex.toVector3())) {
continue;
}
@@ -191,7 +192,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
// Add triangles between the remembered edges and the new vertex.
for (Edge edge : borderEdges) {
- triangles.add(edge.createTriangle(vertex));
+ triangles.add(edge.createTriangle(vertex.toVector3()));
}
if (!vertexBacklog.isEmpty()) {
@@ -199,9 +200,9 @@ public class ConvexPolyhedralRegion 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);
}
@@ -217,39 +218,40 @@ public class ConvexPolyhedralRegion 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.toVector3().divide(vertices.size());
}
@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 {
+ Vector3 vec = change.toVector3();
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 Vector3 v0 = vec.add(triangle.getVertex(0));
+ final Vector3 v1 = vec.add(triangle.getVertex(1));
+ final Vector3 v2 = vec.add(triangle.getVertex(2));
triangles.set(i, new Triangle(v0, v1, v2));
}
@@ -260,16 +262,16 @@ public class ConvexPolyhedralRegion 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;
}
@@ -278,8 +280,8 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
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;
@@ -288,10 +290,10 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
if (z < min.getBlockZ()) return false;
if (z > max.getBlockZ()) return false;
- return containsRaw(position);
+ return containsRaw(position.toVector3());
}
- private boolean containsRaw(Vector pt) {
+ private boolean containsRaw(Vector3 pt) {
if (lastTriangle != null && lastTriangle.above(pt)) {
return false;
}
@@ -310,12 +312,12 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
return true;
}
- 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/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java
index 942e92d6e..cebd62098 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
@@ -22,15 +22,14 @@ package com.sk89q.worldedit.regions;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.storage.ChunkStore;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.NoSuchElementException;
import java.util.Set;
/**
@@ -38,8 +37,8 @@ import java.util.Set;
*/
public class CuboidRegion extends AbstractRegion implements FlatRegion {
- private Vector pos1;
- private Vector pos2;
+ private BlockVector3 pos1;
+ private BlockVector3 pos2;
/**
* Construct a new instance of this cuboid using two corners of the cuboid.
@@ -47,7 +46,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
* @param pos1 the first position
* @param pos2 the second position
*/
- public CuboidRegion(Vector pos1, Vector pos2) {
+ public CuboidRegion(BlockVector3 pos1, BlockVector3 pos2) {
this(null, pos1, pos2);
}
@@ -58,7 +57,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
* @param pos1 the first position
* @param pos2 the second position
*/
- public CuboidRegion(World world, Vector pos1, Vector pos2) {
+ public CuboidRegion(World world, BlockVector3 pos1, BlockVector3 pos2) {
super(world);
checkNotNull(pos1);
checkNotNull(pos2);
@@ -72,7 +71,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
*
* @return a position
*/
- public Vector getPos1() {
+ public BlockVector3 getPos1() {
return pos1;
}
@@ -81,7 +80,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
*
* @param pos1 a position
*/
- public void setPos1(Vector pos1) {
+ public void setPos1(BlockVector3 pos1) {
this.pos1 = pos1;
}
@@ -90,7 +89,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
*
* @return a position
*/
- public Vector getPos2() {
+ public BlockVector3 getPos2() {
return pos2;
}
@@ -99,7 +98,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
*
* @param pos2 a position
*/
- public void setPos2(Vector pos2) {
+ public void setPos2(BlockVector3 pos2) {
this.pos2 = pos2;
}
@@ -117,21 +116,21 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
* @return a new complex region
*/
public Region getFaces() {
- Vector min = getMinimumPoint();
- Vector max = getMaximumPoint();
+ BlockVector3 min = getMinimumPoint();
+ BlockVector3 max = getMaximumPoint();
return new RegionIntersection(
// Project to Z-Y plane
- new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())),
- new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())),
+ new CuboidRegion(pos1.withX(min.getX()), pos2.withX(min.getX())),
+ new CuboidRegion(pos1.withX(max.getX()), pos2.withX(max.getX())),
// Project to X-Y plane
- new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())),
- new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ())),
+ new CuboidRegion(pos1.withZ(min.getZ()), pos2.withZ(min.getZ())),
+ new CuboidRegion(pos1.withZ(max.getZ()), pos2.withZ(max.getZ())),
// Project to the X-Z plane
- new CuboidRegion(pos1.setY(min.getY()), pos2.setY(min.getY())),
- new CuboidRegion(pos1.setY(max.getY()), pos2.setY(max.getY())));
+ new CuboidRegion(pos1.withY(min.getY()), pos2.withY(min.getY())),
+ new CuboidRegion(pos1.withY(max.getY()), pos2.withY(max.getY())));
}
/**
@@ -141,31 +140,27 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
* @return a new complex region
*/
public Region getWalls() {
- Vector min = getMinimumPoint();
- Vector max = getMaximumPoint();
+ BlockVector3 min = getMinimumPoint();
+ BlockVector3 max = getMaximumPoint();
return new RegionIntersection(
// Project to Z-Y plane
- new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())),
- new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())),
+ new CuboidRegion(pos1.withX(min.getX()), pos2.withX(min.getX())),
+ new CuboidRegion(pos1.withX(max.getX()), pos2.withX(max.getX())),
// Project to X-Y plane
- new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())),
- new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ())));
+ new CuboidRegion(pos1.withZ(min.getZ()), pos2.withZ(min.getZ())),
+ new CuboidRegion(pos1.withZ(max.getZ()), pos2.withZ(max.getZ())));
}
@Override
- public Vector getMinimumPoint() {
- return new Vector(Math.min(pos1.getX(), pos2.getX()),
- Math.min(pos1.getY(), pos2.getY()),
- Math.min(pos1.getZ(), pos2.getZ()));
+ public BlockVector3 getMinimumPoint() {
+ return pos1.getMinimum(pos2);
}
@Override
- public Vector getMaximumPoint() {
- return new Vector(Math.max(pos1.getX(), pos2.getX()),
- Math.max(pos1.getY(), pos2.getY()),
- Math.max(pos1.getZ(), pos2.getZ()));
+ public BlockVector3 getMaximumPoint() {
+ return pos1.getMaximum(pos2);
}
@Override
@@ -179,49 +174,49 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public void expand(Vector... changes) {
+ public void expand(BlockVector3... changes) {
checkNotNull(changes);
- for (Vector change : changes) {
+ for (BlockVector3 change : changes) {
if (change.getX() > 0) {
if (Math.max(pos1.getX(), pos2.getX()) == pos1.getX()) {
- pos1 = pos1.add(new Vector(change.getX(), 0, 0));
+ pos1 = pos1.add(change.getX(), 0, 0);
} else {
- pos2 = pos2.add(new Vector(change.getX(), 0, 0));
+ pos2 = pos2.add(change.getX(), 0, 0);
}
} else {
if (Math.min(pos1.getX(), pos2.getX()) == pos1.getX()) {
- pos1 = pos1.add(new Vector(change.getX(), 0, 0));
+ pos1 = pos1.add(change.getX(), 0, 0);
} else {
- pos2 = pos2.add(new Vector(change.getX(), 0, 0));
+ pos2 = pos2.add(change.getX(), 0, 0);
}
}
if (change.getY() > 0) {
if (Math.max(pos1.getY(), pos2.getY()) == pos1.getY()) {
- pos1 = pos1.add(new Vector(0, change.getY(), 0));
+ pos1 = pos1.add(0, change.getY(), 0);
} else {
- pos2 = pos2.add(new Vector(0, change.getY(), 0));
+ pos2 = pos2.add(0, change.getY(), 0);
}
} else {
if (Math.min(pos1.getY(), pos2.getY()) == pos1.getY()) {
- pos1 = pos1.add(new Vector(0, change.getY(), 0));
+ pos1 = pos1.add(0, change.getY(), 0);
} else {
- pos2 = pos2.add(new Vector(0, change.getY(), 0));
+ pos2 = pos2.add(0, change.getY(), 0);
}
}
if (change.getZ() > 0) {
if (Math.max(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
- pos1 = pos1.add(new Vector(0, 0, change.getZ()));
+ pos1 = pos1.add(0, 0, change.getZ());
} else {
- pos2 = pos2.add(new Vector(0, 0, change.getZ()));
+ pos2 = pos2.add(0, 0, change.getZ());
}
} else {
if (Math.min(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
- pos1 = pos1.add(new Vector(0, 0, change.getZ()));
+ pos1 = pos1.add(0, 0, change.getZ());
} else {
- pos2 = pos2.add(new Vector(0, 0, change.getZ()));
+ pos2 = pos2.add(0, 0, change.getZ());
}
}
}
@@ -230,49 +225,49 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public void contract(Vector... changes) {
+ public void contract(BlockVector3... changes) {
checkNotNull(changes);
- for (Vector change : changes) {
+ for (BlockVector3 change : changes) {
if (change.getX() < 0) {
if (Math.max(pos1.getX(), pos2.getX()) == pos1.getX()) {
- pos1 = pos1.add(new Vector(change.getX(), 0, 0));
+ pos1 = pos1.add(change.getX(), 0, 0);
} else {
- pos2 = pos2.add(new Vector(change.getX(), 0, 0));
+ pos2 = pos2.add(change.getX(), 0, 0);
}
} else {
if (Math.min(pos1.getX(), pos2.getX()) == pos1.getX()) {
- pos1 = pos1.add(new Vector(change.getX(), 0, 0));
+ pos1 = pos1.add(change.getX(), 0, 0);
} else {
- pos2 = pos2.add(new Vector(change.getX(), 0, 0));
+ pos2 = pos2.add(change.getX(), 0, 0);
}
}
if (change.getY() < 0) {
if (Math.max(pos1.getY(), pos2.getY()) == pos1.getY()) {
- pos1 = pos1.add(new Vector(0, change.getY(), 0));
+ pos1 = pos1.add(0, change.getY(), 0);
} else {
- pos2 = pos2.add(new Vector(0, change.getY(), 0));
+ pos2 = pos2.add(0, change.getY(), 0);
}
} else {
if (Math.min(pos1.getY(), pos2.getY()) == pos1.getY()) {
- pos1 = pos1.add(new Vector(0, change.getY(), 0));
+ pos1 = pos1.add(0, change.getY(), 0);
} else {
- pos2 = pos2.add(new Vector(0, change.getY(), 0));
+ pos2 = pos2.add(0, change.getY(), 0);
}
}
if (change.getZ() < 0) {
if (Math.max(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
- pos1 = pos1.add(new Vector(0, 0, change.getZ()));
+ pos1 = pos1.add(0, 0, change.getZ());
} else {
- pos2 = pos2.add(new Vector(0, 0, change.getZ()));
+ pos2 = pos2.add(0, 0, change.getZ());
}
} else {
if (Math.min(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
- pos1 = pos1.add(new Vector(0, 0, change.getZ()));
+ pos1 = pos1.add(0, 0, change.getZ());
} else {
- pos2 = pos2.add(new Vector(0, 0, change.getZ()));
+ pos2 = pos2.add(0, 0, change.getZ());
}
}
}
@@ -281,7 +276,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public void shift(Vector change) throws RegionOperationException {
+ public void shift(BlockVector3 change) throws RegionOperationException {
pos1 = pos1.add(change);
pos2 = pos2.add(change);
@@ -289,15 +284,15 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public Set getChunks() {
- Set chunks = new HashSet<>();
+ public Set getChunks() {
+ Set chunks = new HashSet<>();
- Vector min = getMinimumPoint();
- Vector max = getMaximumPoint();
+ BlockVector3 min = getMinimumPoint();
+ BlockVector3 max = getMaximumPoint();
for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) {
for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) {
- chunks.add(new BlockVector2D(x, z));
+ chunks.add(new BlockVector2(x, z));
}
}
@@ -305,16 +300,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public Set getChunkCubes() {
- Set chunks = new HashSet<>();
+ public Set getChunkCubes() {
+ Set chunks = new HashSet<>();
- Vector min = getMinimumPoint();
- Vector max = getMaximumPoint();
+ BlockVector3 min = getMinimumPoint();
+ BlockVector3 max = getMaximumPoint();
for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) {
for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) {
for (int y = min.getBlockY() >> ChunkStore.CHUNK_SHIFTS; y <= max.getBlockY() >> ChunkStore.CHUNK_SHIFTS; ++y) {
- chunks.add(new BlockVector(x, y, z));
+ chunks.add(new BlockVector3(x, y, z));
}
}
}
@@ -323,24 +318,18 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public boolean contains(Vector position) {
- int x = position.getBlockX();
- int y = position.getBlockY();
- int z = position.getBlockZ();
+ public boolean contains(BlockVector3 position) {
+ BlockVector3 min = getMinimumPoint();
+ BlockVector3 max = getMaximumPoint();
- Vector min = getMinimumPoint();
- Vector max = getMaximumPoint();
-
- return x >= min.getBlockX() && x <= max.getBlockX()
- && y >= min.getBlockY() && y <= max.getBlockY()
- && z >= min.getBlockZ() && z <= max.getBlockZ();
+ return position.containedWithin(min, max);
}
@Override
- public Iterator iterator() {
- return new Iterator() {
- private Vector min = getMinimumPoint();
- private Vector max = getMaximumPoint();
+ public Iterator iterator() {
+ return new Iterator() {
+ private BlockVector3 min = getMinimumPoint();
+ private BlockVector3 max = getMaximumPoint();
private int nextX = min.getBlockX();
private int nextY = min.getBlockY();
private int nextZ = min.getBlockZ();
@@ -351,9 +340,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public BlockVector next() {
- if (!hasNext()) throw new java.util.NoSuchElementException();
- BlockVector answer = new BlockVector(nextX, nextY, nextZ);
+ public BlockVector3 next() {
+ if (!hasNext()) throw new NoSuchElementException();
+ BlockVector3 answer = new BlockVector3(nextX, nextY, nextZ);
if (++nextX > max.getBlockX()) {
nextX = min.getBlockX();
if (++nextY > max.getBlockY()) {
@@ -365,19 +354,14 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
return answer;
}
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
};
}
@Override
- public Iterable asFlatRegion() {
- return () -> new Iterator() {
- private Vector min = getMinimumPoint();
- private Vector max = getMaximumPoint();
+ public Iterable asFlatRegion() {
+ return () -> new Iterator() {
+ private BlockVector3 min = getMinimumPoint();
+ private BlockVector3 max = getMaximumPoint();
private int nextX = min.getBlockX();
private int nextZ = min.getBlockZ();
@@ -387,9 +371,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public Vector2D next() {
- if (!hasNext()) throw new java.util.NoSuchElementException();
- Vector2D answer = new Vector2D(nextX, nextZ);
+ public BlockVector2 next() {
+ if (!hasNext()) throw new NoSuchElementException();
+ BlockVector2 answer = new BlockVector2(nextX, nextZ);
if (++nextX > max.getBlockX()) {
nextX = min.getBlockX();
if (++nextZ > max.getBlockZ()) {
@@ -398,11 +382,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
}
return answer;
}
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
};
}
@@ -435,10 +414,10 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
* @param apothem the apothem, where 0 is the minimum value to make a 1x1 cuboid
* @return a cuboid region
*/
- public static CuboidRegion fromCenter(Vector origin, int apothem) {
+ public static CuboidRegion fromCenter(BlockVector3 origin, int apothem) {
checkNotNull(origin);
checkArgument(apothem >= 0, "apothem => 0 required");
- Vector size = new Vector(1, 1, 1).multiply(apothem);
+ BlockVector3 size = BlockVector3.ONE.multiply(apothem);
return new CuboidRegion(origin.subtract(size), origin.add(size));
}
}
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 ed0e70822..acff65c3a 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
@@ -21,11 +21,11 @@ package com.sk89q.worldedit.regions;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.Vector2;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.geom.Polygons;
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
@@ -39,8 +39,8 @@ import java.util.List;
*/
public class CylinderRegion extends AbstractRegion implements FlatRegion {
- private Vector2D center;
- private Vector2D radius;
+ private BlockVector2 center;
+ private Vector2 radius;
private int minY;
private int maxY;
private boolean hasY = false;
@@ -58,7 +58,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
* @param world the world
*/
public CylinderRegion(World world) {
- this(world, new Vector(), new Vector2D(), 0, 0);
+ this(world, BlockVector3.ZERO, Vector2.ZERO, 0, 0);
hasY = false;
}
@@ -71,9 +71,9 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
* @param minY the minimum Y, inclusive
* @param maxY the maximum Y, inclusive
*/
- public CylinderRegion(World world, Vector center, Vector2D radius, int minY, int maxY) {
+ public CylinderRegion(World world, BlockVector3 center, Vector2 radius, int minY, int maxY) {
super(world);
- setCenter(center.toVector2D());
+ setCenter(center.toBlockVector2());
setRadius(radius);
this.minY = minY;
this.maxY = maxY;
@@ -88,9 +88,9 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
* @param minY the minimum Y, inclusive
* @param maxY the maximum Y, inclusive
*/
- public CylinderRegion(Vector center, Vector2D radius, int minY, int maxY) {
+ public CylinderRegion(BlockVector3 center, Vector2 radius, int minY, int maxY) {
super(null);
- setCenter(center.toVector2D());
+ setCenter(center.toBlockVector2());
setRadius(radius);
this.minY = minY;
this.maxY = maxY;
@@ -98,13 +98,13 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
}
public CylinderRegion(CylinderRegion region) {
- this(region.world, region.getCenter(), region.getRadius(), region.minY, region.maxY);
+ this(region.world, region.getCenter().toBlockPoint(), region.getRadius(), region.minY, region.maxY);
hasY = region.hasY;
}
@Override
- public Vector getCenter() {
- return center.toVector((maxY + minY) / 2);
+ public Vector3 getCenter() {
+ return center.toVector3((maxY + minY) / 2);
}
/**
@@ -112,7 +112,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
*
* @param center the center point
*/
- public void setCenter(Vector2D center) {
+ public void setCenter(BlockVector2 center) {
this.center = center;
}
@@ -121,7 +121,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
*
* @return the radius along the X and Z axes
*/
- public Vector2D getRadius() {
+ public Vector2 getRadius() {
return radius.subtract(0.5, 0.5);
}
@@ -130,7 +130,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
*
* @param radius the radius along the X and Z axes
*/
- public void setRadius(Vector2D radius) {
+ public void setRadius(Vector2 radius) {
this.radius = radius.add(0.5, 0.5);
}
@@ -139,8 +139,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
*
* @param minRadius the minimum radius
*/
- public void extendRadius(Vector2D minRadius) {
- setRadius(Vector2D.getMaximum(minRadius, getRadius()));
+ public void extendRadius(Vector2 minRadius) {
+ setRadius(minRadius.getMaximum(getRadius()));
}
/**
@@ -164,13 +164,13 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public Vector getMinimumPoint() {
- return center.subtract(getRadius()).toVector(minY);
+ public BlockVector3 getMinimumPoint() {
+ return center.toVector2().subtract(getRadius()).toVector3(minY).toBlockPoint();
}
@Override
- public Vector getMaximumPoint() {
- return center.add(getRadius()).toVector(maxY);
+ public BlockVector3 getMaximumPoint() {
+ return center.toVector2().add(getRadius()).toVector3(maxY).toBlockPoint();
}
@Override
@@ -203,10 +203,10 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
return (int) (2 * radius.getZ());
}
- private Vector2D calculateDiff2D(Vector... changes) throws RegionOperationException {
- Vector2D diff = new Vector2D();
- for (Vector change : changes) {
- diff = diff.add(change.toVector2D());
+ private BlockVector2 calculateDiff2D(BlockVector3... changes) throws RegionOperationException {
+ BlockVector2 diff = BlockVector2.ZERO;
+ for (BlockVector3 change : changes) {
+ diff = diff.add(change.toBlockVector2());
}
if ((diff.getBlockX() & 1) + (diff.getBlockZ() & 1) != 0) {
@@ -216,10 +216,10 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
return diff.divide(2).floor();
}
- private Vector2D calculateChanges2D(Vector... changes) {
- Vector2D total = new Vector2D();
- for (Vector change : changes) {
- total = total.add(change.toVector2D().positive());
+ private BlockVector2 calculateChanges2D(BlockVector3... changes) {
+ BlockVector2 total = BlockVector2.ZERO;
+ for (BlockVector3 change : changes) {
+ total = total.add(change.toBlockVector2().abs());
}
return total.divide(2).floor();
@@ -233,10 +233,10 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
* @throws RegionOperationException
*/
@Override
- public void expand(Vector... changes) throws RegionOperationException {
+ public void expand(BlockVector3... changes) throws RegionOperationException {
center = center.add(calculateDiff2D(changes));
- radius = radius.add(calculateChanges2D(changes));
- for (Vector change : changes) {
+ radius = radius.add(calculateChanges2D(changes).toVector2());
+ for (BlockVector3 change : changes) {
int changeY = change.getBlockY();
if (changeY > 0) {
maxY += changeY;
@@ -253,11 +253,11 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
* @throws RegionOperationException
*/
@Override
- public void contract(Vector... changes) throws RegionOperationException {
+ public void contract(BlockVector3... changes) throws RegionOperationException {
center = center.subtract(calculateDiff2D(changes));
- Vector2D newRadius = radius.subtract(calculateChanges2D(changes));
- radius = Vector2D.getMaximum(new Vector2D(1.5, 1.5), newRadius);
- for (Vector change : changes) {
+ Vector2 newRadius = radius.subtract(calculateChanges2D(changes).toVector2());
+ radius = new Vector2(1.5, 1.5).getMaximum(newRadius);
+ for (BlockVector3 change : changes) {
int height = maxY - minY;
int changeY = change.getBlockY();
if (changeY > 0) {
@@ -269,8 +269,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public void shift(Vector change) throws RegionOperationException {
- center = center.add(change.toVector2D());
+ public void shift(BlockVector3 change) throws RegionOperationException {
+ center = center.add(change.toBlockVector2());
int changeY = change.getBlockY();
maxY += changeY;
@@ -281,13 +281,13 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
* Checks to see if a point is inside this region.
*/
@Override
- public boolean contains(Vector position) {
+ public boolean contains(BlockVector3 position) {
final int blockY = position.getBlockY();
if (blockY < minY || blockY > maxY) {
return false;
}
- return position.toVector2D().subtract(center).divide(radius).lengthSq() <= 1;
+ return position.toBlockVector2().subtract(center).toVector2().divide(radius).lengthSq() <= 1;
}
@@ -315,12 +315,12 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public Iterator iterator() {
+ public Iterator iterator() {
return new FlatRegion3DIterator(this);
}
@Override
- public Iterable asFlatRegion() {
+ public Iterable asFlatRegion() {
return () -> new FlatRegionIterator(CylinderRegion.this);
}
@@ -341,7 +341,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public List polygonize(int maxPoints) {
+ public List polygonize(int maxPoints) {
return Polygons.polygonizeCylinder(center, radius, maxPoints);
}
@@ -355,10 +355,10 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
* @param radius the radius in the X and Z axes
* @return a region
*/
- public static CylinderRegion createRadius(Extent extent, Vector center, double radius) {
+ public static CylinderRegion createRadius(Extent extent, BlockVector3 center, double radius) {
checkNotNull(extent);
checkNotNull(center);
- Vector2D radiusVec = new Vector2D(radius, radius);
+ Vector2 radiusVec = new Vector2(radius, radius);
int minY = extent.getMinimumPoint().getBlockY();
int maxY = extent.getMaximumPoint().getBlockY();
return new CylinderRegion(center, radiusVec, minY, maxY);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java
index 069cdaff3..0cf5e4b59 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
@@ -19,10 +19,9 @@
package com.sk89q.worldedit.regions;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.storage.ChunkStore;
@@ -37,12 +36,12 @@ public class EllipsoidRegion extends AbstractRegion {
/**
* Stores the center.
*/
- private Vector center;
+ private BlockVector3 center;
/**
* Stores the radii plus 0.5 on each axis.
*/
- private Vector radius;
+ private Vector3 radius;
/**
* Construct a new instance of this ellipsoid region.
@@ -50,7 +49,7 @@ public class EllipsoidRegion extends AbstractRegion {
* @param pos1 the first position
* @param pos2 the second position
*/
- public EllipsoidRegion(Vector pos1, Vector pos2) {
+ public EllipsoidRegion(BlockVector3 pos1, Vector3 pos2) {
this(null, pos1, pos2);
}
@@ -61,7 +60,7 @@ public class EllipsoidRegion extends AbstractRegion {
* @param center the center
* @param radius the radius
*/
- public EllipsoidRegion(World world, Vector center, Vector radius) {
+ public EllipsoidRegion(World world, BlockVector3 center, Vector3 radius) {
super(world);
this.center = center;
setRadius(radius);
@@ -72,13 +71,13 @@ public class EllipsoidRegion extends AbstractRegion {
}
@Override
- public Vector getMinimumPoint() {
- return center.subtract(getRadius());
+ public BlockVector3 getMinimumPoint() {
+ return center.toVector3().subtract(getRadius()).toBlockPoint();
}
@Override
- public Vector getMaximumPoint() {
- return center.add(getRadius());
+ public BlockVector3 getMaximumPoint() {
+ return center.toVector3().add(getRadius()).toBlockPoint();
}
@Override
@@ -101,8 +100,8 @@ public class EllipsoidRegion extends AbstractRegion {
return (int) (2 * radius.getZ());
}
- private Vector calculateDiff(Vector... changes) throws RegionOperationException {
- Vector diff = new Vector().add(changes);
+ private BlockVector3 calculateDiff(BlockVector3... changes) throws RegionOperationException {
+ BlockVector3 diff = BlockVector3.ZERO.add(changes);
if ((diff.getBlockX() & 1) + (diff.getBlockY() & 1) + (diff.getBlockZ() & 1) != 0) {
throw new RegionOperationException(
@@ -112,30 +111,30 @@ public class EllipsoidRegion extends AbstractRegion {
return diff.divide(2).floor();
}
- private Vector calculateChanges(Vector... changes) {
- Vector total = new Vector();
- for (Vector change : changes) {
- total = total.add(change.positive());
+ private Vector3 calculateChanges(BlockVector3... changes) {
+ Vector3 total = Vector3.ZERO;
+ for (BlockVector3 change : changes) {
+ total = total.add(change.abs().toVector3());
}
return total.divide(2).floor();
}
@Override
- public void expand(Vector... changes) throws RegionOperationException {
+ public void expand(BlockVector3... changes) throws RegionOperationException {
center = center.add(calculateDiff(changes));
radius = radius.add(calculateChanges(changes));
}
@Override
- public void contract(Vector... changes) throws RegionOperationException {
+ public void contract(BlockVector3... changes) throws RegionOperationException {
center = center.subtract(calculateDiff(changes));
- Vector newRadius = radius.subtract(calculateChanges(changes));
- radius = Vector.getMaximum(new Vector(1.5, 1.5, 1.5), newRadius);
+ Vector3 newRadius = radius.subtract(calculateChanges(changes));
+ radius = new Vector3(1.5, 1.5, 1.5).getMaximum(newRadius);
}
@Override
- public void shift(Vector change) throws RegionOperationException {
+ public void shift(BlockVector3 change) throws RegionOperationException {
center = center.add(change);
}
@@ -145,8 +144,8 @@ public class EllipsoidRegion extends AbstractRegion {
* @return center
*/
@Override
- public Vector getCenter() {
- return center;
+ public Vector3 getCenter() {
+ return center.toVector3();
}
/**
@@ -154,7 +153,7 @@ public class EllipsoidRegion extends AbstractRegion {
*
* @param center the center
*/
- public void setCenter(Vector center) {
+ public void setCenter(BlockVector3 center) {
this.center = center;
}
@@ -163,7 +162,7 @@ public class EllipsoidRegion extends AbstractRegion {
*
* @return radii
*/
- public Vector getRadius() {
+ public Vector3 getRadius() {
return radius.subtract(0.5, 0.5, 0.5);
}
@@ -172,25 +171,25 @@ public class EllipsoidRegion extends AbstractRegion {
*
* @param radius the radius
*/
- public void setRadius(Vector radius) {
+ public void setRadius(Vector3 radius) {
this.radius = radius.add(0.5, 0.5, 0.5);
}
@Override
- public Set getChunks() {
- final Set chunks = new HashSet<>();
+ public Set getChunks() {
+ final Set chunks = new HashSet<>();
- final Vector min = getMinimumPoint();
- final Vector max = getMaximumPoint();
- final int centerY = getCenter().getBlockY();
+ final BlockVector3 min = getMinimumPoint();
+ final BlockVector3 max = getMaximumPoint();
+ final int centerY = center.getBlockY();
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
- if (!contains(new BlockVector(x, centerY, z))) {
+ if (!contains(new BlockVector3(x, centerY, z))) {
continue;
}
- chunks.add(new BlockVector2D(
+ chunks.add(new BlockVector2(
x >> ChunkStore.CHUNK_SHIFTS,
z >> ChunkStore.CHUNK_SHIFTS
));
@@ -201,8 +200,8 @@ public class EllipsoidRegion extends AbstractRegion {
}
@Override
- public boolean contains(Vector position) {
- return position.subtract(center).divide(radius).lengthSq() <= 1;
+ public boolean contains(BlockVector3 position) {
+ return position.subtract(center).toVector3().divide(radius).lengthSq() <= 1;
}
/**
@@ -216,8 +215,8 @@ public class EllipsoidRegion extends AbstractRegion {
return center + " - " + getRadius();
}
- public void extendRadius(Vector minRadius) {
- setRadius(Vector.getMaximum(minRadius, getRadius()));
+ public void extendRadius(Vector3 minRadius) {
+ setRadius(minRadius.getMaximum(getRadius()));
}
@Override
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java
index 92cdf6e36..bd4561e4d 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java
@@ -19,7 +19,7 @@
package com.sk89q.worldedit.regions;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
public interface FlatRegion extends Region {
@@ -42,5 +42,5 @@ public interface FlatRegion extends Region {
*
* @return a flat region iterable
*/
- Iterable asFlatRegion();
+ Iterable asFlatRegion();
}
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 5f1c9653e..58e1d2197 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,10 +19,9 @@
package com.sk89q.worldedit.regions;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.World;
import java.util.Collections;
@@ -39,18 +38,18 @@ public class NullRegion implements Region {
private World world;
@Override
- public Vector getMinimumPoint() {
- return new Vector(0, 0, 0);
+ public BlockVector3 getMinimumPoint() {
+ return BlockVector3.ZERO;
}
@Override
- public Vector getMaximumPoint() {
- return new Vector(0, 0, 0);
+ public BlockVector3 getMaximumPoint() {
+ return BlockVector3.ZERO;
}
@Override
- public Vector getCenter() {
- return new Vector(0, 0, 0);
+ public Vector3 getCenter() {
+ return Vector3.ZERO;
}
@Override
@@ -74,32 +73,32 @@ public class NullRegion implements Region {
}
@Override
- public void expand(Vector... changes) throws RegionOperationException {
+ public void expand(BlockVector3... changes) throws RegionOperationException {
throw new RegionOperationException("Cannot change NullRegion");
}
@Override
- public void contract(Vector... changes) throws RegionOperationException {
+ public void contract(BlockVector3... changes) throws RegionOperationException {
throw new RegionOperationException("Cannot change NullRegion");
}
@Override
- public void shift(Vector change) throws RegionOperationException {
+ public void shift(BlockVector3 change) throws RegionOperationException {
throw new RegionOperationException("Cannot change NullRegion");
}
@Override
- public boolean contains(Vector position) {
+ public boolean contains(BlockVector3 position) {
return false;
}
@Override
- public Set getChunks() {
+ public Set getChunks() {
return Collections.emptySet();
}
@Override
- public Set getChunkCubes() {
+ public Set getChunkCubes() {
return Collections.emptySet();
}
@@ -119,27 +118,22 @@ public class NullRegion implements Region {
}
@Override
- public List polygonize(int maxPoints) {
+ public List polygonize(int maxPoints) {
return Collections.emptyList();
}
@Override
- public Iterator iterator() {
- return new Iterator() {
+ public Iterator iterator() {
+ return new Iterator() {
@Override
public boolean hasNext() {
return false;
}
@Override
- public BlockVector next() {
+ public BlockVector3 next() {
throw new NoSuchElementException();
}
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException("Cannot remove");
- }
};
}
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 b7d607d9d..41cdeebff 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
@@ -19,10 +19,9 @@
package com.sk89q.worldedit.regions;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector2;
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
import com.sk89q.worldedit.world.World;
@@ -37,9 +36,9 @@ import java.util.List;
*/
public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
- private List points;
- private Vector2D min;
- private Vector2D max;
+ private List points;
+ private BlockVector2 min;
+ private BlockVector2 max;
private int minY;
private int maxY;
private boolean hasY = false;
@@ -57,7 +56,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
* @param world the world
*/
public Polygonal2DRegion(World world) {
- this(world, Collections.emptyList(), 0, 0);
+ this(world, Collections.emptyList(), 0, 0);
hasY = false;
}
@@ -69,7 +68,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
* @param minY minimum Y
* @param maxY maximum Y
*/
- public Polygonal2DRegion(World world, List points, int minY, int maxY) {
+ public Polygonal2DRegion(World world, List points, int minY, int maxY) {
super(world);
this.points = new ArrayList<>(points);
this.minY = minY;
@@ -93,7 +92,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
*
* @return a list of points
*/
- public List getPoints() {
+ public List getPoints() {
return Collections.unmodifiableList(points);
}
@@ -103,9 +102,9 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
*/
protected void recalculate() {
if (points.isEmpty()) {
- min = new Vector2D(0, 0);
+ min = BlockVector2.ZERO;
minY = 0;
- max = new Vector2D(0, 0);
+ max = BlockVector2.ZERO;
maxY = 0;
return;
}
@@ -115,7 +114,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
int maxX = points.get(0).getBlockX();
int maxZ = points.get(0).getBlockZ();
- for (BlockVector2D v : points) {
+ for (BlockVector2 v : points) {
int x = v.getBlockX();
int z = v.getBlockZ();
if (x < minX) minX = x;
@@ -132,8 +131,8 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
minY = Math.min(Math.max(0, minY), world == null ? 255 : world.getMaxY());
maxY = Math.min(Math.max(0, maxY), world == null ? 255 : world.getMaxY());
- min = new Vector2D(minX, minZ);
- max = new Vector2D(maxX, maxZ);
+ min = new BlockVector2(minX, minZ);
+ max = new BlockVector2(maxX, maxZ);
}
/**
@@ -141,17 +140,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
*
* @param position the position
*/
- public void addPoint(Vector2D position) {
- points.add(position.toBlockVector2D());
- recalculate();
- }
-
- /**
- * Add a point to the list.
- *
- * @param position the position
- */
- public void addPoint(BlockVector2D position) {
+ public void addPoint(BlockVector2 position) {
points.add(position);
recalculate();
}
@@ -161,8 +150,8 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
*
* @param position the position
*/
- public void addPoint(Vector position) {
- points.add(new BlockVector2D(position.getBlockX(), position.getBlockZ()));
+ public void addPoint(BlockVector3 position) {
+ points.add(new BlockVector2(position.getBlockX(), position.getBlockZ()));
recalculate();
}
@@ -199,13 +188,13 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public Vector getMinimumPoint() {
- return min.toVector(minY);
+ public BlockVector3 getMinimumPoint() {
+ return min.toBlockVector3(minY);
}
@Override
- public Vector getMaximumPoint() {
- return max.toVector(maxY);
+ public BlockVector3 getMaximumPoint() {
+ return max.toBlockVector3(maxY);
}
@Override
@@ -239,14 +228,11 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public void expand(Vector... changes) throws RegionOperationException {
- for (Vector change : changes) {
+ public void expand(BlockVector3... changes) throws RegionOperationException {
+ for (BlockVector3 change : changes) {
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
throw new RegionOperationException("Polygons can only be expanded vertically.");
}
- }
-
- for (Vector change : changes) {
int changeY = change.getBlockY();
if (changeY > 0) {
maxY += changeY;
@@ -258,14 +244,11 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public void contract(Vector... changes) throws RegionOperationException {
- for (Vector change : changes) {
+ public void contract(BlockVector3... changes) throws RegionOperationException {
+ for (BlockVector3 change : changes) {
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
throw new RegionOperationException("Polygons can only be contracted vertically.");
}
- }
-
- for (Vector change : changes) {
int changeY = change.getBlockY();
if (changeY > 0) {
minY += changeY;
@@ -277,14 +260,14 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public void shift(Vector change) throws RegionOperationException {
+ public void shift(BlockVector3 change) throws RegionOperationException {
final double changeX = change.getX();
final double changeY = change.getY();
final double changeZ = change.getZ();
for (int i = 0; i < points.size(); ++i) {
- BlockVector2D point = points.get(i);
- points.set(i, new BlockVector2D(point.getX() + changeX, point.getZ() + changeZ));
+ BlockVector2 point = points.get(i);
+ points.set(i, new BlockVector2(point.getX() + changeX, point.getZ() + changeZ));
}
minY += changeY;
@@ -294,7 +277,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public boolean contains(Vector position) {
+ public boolean contains(BlockVector3 position) {
return contains(points, minY, maxY, position);
}
@@ -307,7 +290,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
* @param pt the position to check
* @return true if the given polygon contains the given point
*/
- public static boolean contains(List points, int minY, int maxY, Vector pt) {
+ public static boolean contains(List points, int minY, int maxY, BlockVector3 pt) {
if (points.size() < 3) {
return false;
}
@@ -398,12 +381,12 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public Iterator iterator() {
+ public Iterator iterator() {
return new FlatRegion3DIterator(this);
}
@Override
- public Iterable asFlatRegion() {
+ public Iterable asFlatRegion() {
return () -> new FlatRegionIterator(Polygonal2DRegion.this);
}
@@ -416,10 +399,10 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- List pts = getPoints();
- Iterator it = pts.iterator();
+ List pts = getPoints();
+ Iterator it = pts.iterator();
while (it.hasNext()) {
- BlockVector2D current = it.next();
+ BlockVector2 current = it.next();
sb.append("(").append(current.getBlockX()).append(", ").append(current.getBlockZ()).append(")");
if (it.hasNext()) sb.append(" - ");
}
@@ -435,7 +418,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
}
@Override
- public List polygonize(int maxPoints) {
+ public List polygonize(int maxPoints) {
if (maxPoints >= 0 && maxPoints < points.size()) {
throw new IllegalArgumentException("Cannot polygonize a this Polygonal2DRegion into the amount of points given.");
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java
index 77bfa8440..2d1c88f0a 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java
@@ -19,10 +19,9 @@
package com.sk89q.worldedit.regions;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.World;
import java.util.List;
@@ -33,21 +32,21 @@ import javax.annotation.Nullable;
/**
* Represents a physical shape.
*/
-public interface Region extends Iterable, Cloneable {
+public interface Region extends Iterable, Cloneable {
/**
* Get the lower point of a region.
*
* @return min. point
*/
- Vector getMinimumPoint();
+ BlockVector3 getMinimumPoint();
/**
* Get the upper point of a region.
*
* @return max. point
*/
- Vector getMaximumPoint();
+ BlockVector3 getMaximumPoint();
/**
* Get the center point of a region.
@@ -56,7 +55,7 @@ public interface Region extends Iterable, Cloneable {
*
* @return center point
*/
- Vector getCenter();
+ Vector3 getCenter();
/**
* Get the number of blocks in the region.
@@ -92,7 +91,7 @@ public interface Region extends Iterable, Cloneable {
* @param changes array/arguments with multiple related changes
* @throws RegionOperationException
*/
- void expand(Vector... changes) throws RegionOperationException;
+ void expand(BlockVector3... changes) throws RegionOperationException;
/**
* Contract the region.
@@ -100,7 +99,7 @@ public interface Region extends Iterable, Cloneable {
* @param changes array/arguments with multiple related changes
* @throws RegionOperationException
*/
- void contract(Vector... changes) throws RegionOperationException;
+ void contract(BlockVector3... changes) throws RegionOperationException;
/**
* Shift the region.
@@ -108,7 +107,7 @@ public interface Region extends Iterable, Cloneable {
* @param change the change
* @throws RegionOperationException
*/
- void shift(Vector change) throws RegionOperationException;
+ void shift(BlockVector3 change) throws RegionOperationException;
/**
* Returns true based on whether the region contains the point.
@@ -116,21 +115,21 @@ public interface Region extends Iterable, Cloneable {
* @param position the position
* @return true if contained
*/
- boolean contains(Vector position);
+ boolean contains(BlockVector3 position);
/**
* Get a list of chunks.
*
* @return a list of chunk coordinates
*/
- Set getChunks();
+ Set getChunks();
/**
* Return a list of 16*16*16 chunks in a region
*
* @return the chunk cubes this region overlaps with
*/
- Set getChunkCubes();
+ Set getChunkCubes();
/**
* Sets the world that the selection is in.
@@ -159,5 +158,5 @@ public interface Region extends Iterable, Cloneable {
* @param maxPoints maximum number of points to generate. -1 for no limit.
* @return the points.
*/
- List polygonize(int maxPoints);
+ List polygonize(int maxPoints);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java
index ad93903ee..5b26672cb 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java
@@ -23,8 +23,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Iterators;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import java.util.ArrayList;
@@ -90,37 +89,37 @@ public class RegionIntersection extends AbstractRegion {
}
@Override
- public Vector getMinimumPoint() {
- Vector minimum = regions.get(0).getMinimumPoint();
+ public BlockVector3 getMinimumPoint() {
+ BlockVector3 minimum = regions.get(0).getMinimumPoint();
for (int i = 1; i < regions.size(); i++) {
- minimum = Vector.getMinimum(regions.get(i).getMinimumPoint(), minimum);
+ minimum = regions.get(i).getMinimumPoint().getMinimum(minimum);
}
return minimum;
}
@Override
- public Vector getMaximumPoint() {
- Vector maximum = regions.get(0).getMaximumPoint();
+ public BlockVector3 getMaximumPoint() {
+ BlockVector3 maximum = regions.get(0).getMaximumPoint();
for (int i = 1; i < regions.size(); i++) {
- maximum = Vector.getMaximum(regions.get(i).getMaximumPoint(), maximum);
+ maximum = regions.get(i).getMaximumPoint().getMaximum(maximum);
}
return maximum;
}
@Override
- public void expand(Vector... changes) throws RegionOperationException {
+ public void expand(BlockVector3... changes) throws RegionOperationException {
checkNotNull(changes);
throw new RegionOperationException("Cannot expand a region intersection");
}
@Override
- public void contract(Vector... changes) throws RegionOperationException {
+ public void contract(BlockVector3... changes) throws RegionOperationException {
checkNotNull(changes);
throw new RegionOperationException("Cannot contract a region intersection");
}
@Override
- public boolean contains(Vector position) {
+ public boolean contains(BlockVector3 position) {
checkNotNull(position);
for (Region region : regions) {
@@ -134,8 +133,8 @@ public class RegionIntersection extends AbstractRegion {
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
- public Iterator iterator() {
- Iterator[] iterators = (Iterator[]) new Iterator[regions.size()];
+ public Iterator iterator() {
+ Iterator[] iterators = (Iterator[]) new Iterator[regions.size()];
for (int i = 0; i < regions.size(); i++) {
iterators[i] = regions.get(i).iterator();
}
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 278ae4815..fea83d30a 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
@@ -19,11 +19,10 @@
package com.sk89q.worldedit.regions;
-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.math.BlockVector3;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
@@ -59,7 +58,7 @@ public interface RegionSelector {
* @param position the position
* @return true if something changed
*/
- boolean selectPrimary(Vector position, SelectorLimits limits);
+ boolean selectPrimary(BlockVector3 position, SelectorLimits limits);
/**
* Called when the second point is selected.
@@ -67,7 +66,7 @@ public interface RegionSelector {
* @param position the position
* @return true if something changed
*/
- boolean selectSecondary(Vector position, SelectorLimits limits);
+ boolean selectSecondary(BlockVector3 position, SelectorLimits limits);
/**
* Tell the player information about his/her primary selection.
@@ -76,7 +75,7 @@ public interface RegionSelector {
* @param session the session
* @param position position
*/
- void explainPrimarySelection(Actor actor, LocalSession session, Vector position);
+ void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position);
/**
* Tell the player information about his/her secondary selection.
@@ -85,7 +84,7 @@ public interface RegionSelector {
* @param session the session
* @param position position
*/
- void explainSecondarySelection(Actor actor, LocalSession session, Vector position);
+ void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position);
/**
* The the player information about the region's changes. This may resend
@@ -102,7 +101,7 @@ public interface RegionSelector {
* @return the primary position
* @throws IncompleteRegionException thrown if a region has not been fully defined
*/
- BlockVector getPrimaryPosition() throws IncompleteRegionException;
+ BlockVector3 getPrimaryPosition() throws IncompleteRegionException;
/**
* Get the selection.
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 338d5f0e9..911e40b8b 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
@@ -21,9 +21,9 @@ package com.sk89q.worldedit.regions;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.Identity;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.world.World;
@@ -98,17 +98,17 @@ public class TransformRegion extends AbstractRegion {
}
@Override
- public Vector getMinimumPoint() {
- return transform.apply(region.getMinimumPoint());
+ public BlockVector3 getMinimumPoint() {
+ return transform.apply(region.getMinimumPoint().toVector3()).toBlockPoint();
}
@Override
- public Vector getMaximumPoint() {
- return transform.apply(region.getMaximumPoint());
+ public BlockVector3 getMaximumPoint() {
+ return transform.apply(region.getMaximumPoint().toVector3()).toBlockPoint();
}
@Override
- public Vector getCenter() {
+ public Vector3 getCenter() {
return transform.apply(region.getCenter());
}
@@ -133,50 +133,50 @@ public class TransformRegion extends AbstractRegion {
}
@Override
- public void expand(Vector... changes) throws RegionOperationException {
+ public void expand(BlockVector3... changes) throws RegionOperationException {
throw new RegionOperationException("Can't expand a TransformedRegion");
}
@Override
- public void contract(Vector... changes) throws RegionOperationException {
+ public void contract(BlockVector3... changes) throws RegionOperationException {
throw new RegionOperationException("Can't contract a TransformedRegion");
}
@Override
- public void shift(Vector change) throws RegionOperationException {
+ public void shift(BlockVector3 change) throws RegionOperationException {
throw new RegionOperationException("Can't change a TransformedRegion");
}
@Override
- public boolean contains(Vector position) {
- return region.contains(transform.inverse().apply(position));
+ public boolean contains(BlockVector3 position) {
+ return region.contains(transform.inverse().apply(position.toVector3()).toBlockPoint());
}
@Override
- public List polygonize(int maxPoints) {
- List origPoints = region.polygonize(maxPoints);
- List transformedPoints = new ArrayList<>();
- for (BlockVector2D vector : origPoints) {
- transformedPoints.add(transform.apply(vector.toVector(0)).toVector2D().toBlockVector2D());
+ public List polygonize(int maxPoints) {
+ List origPoints = region.polygonize(maxPoints);
+ List transformedPoints = new ArrayList<>();
+ for (BlockVector2 vector : origPoints) {
+ transformedPoints.add(transform.apply(vector.toVector3(0)).toVector2().toBlockPoint());
}
return transformedPoints;
}
@Override
- public Iterator iterator() {
- final Iterator it = region.iterator();
+ public Iterator iterator() {
+ final Iterator it = region.iterator();
- return new Iterator() {
+ return new Iterator() {
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
- public BlockVector next() {
- BlockVector next = it.next();
+ public BlockVector3 next() {
+ BlockVector3 next = it.next();
if (next != null) {
- return transform.apply(next).toBlockVector();
+ return transform.apply(next.toVector3()).toBlockPoint();
} else {
return null;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CuboidRegionFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CuboidRegionFactory.java
index 2f533f9fe..24be870a0 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CuboidRegionFactory.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CuboidRegionFactory.java
@@ -19,14 +19,14 @@
package com.sk89q.worldedit.regions.factory;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
public class CuboidRegionFactory implements RegionFactory {
@Override
- public Region createCenteredAt(Vector position, double size) {
+ public Region createCenteredAt(BlockVector3 position, double size) {
return CuboidRegion.fromCenter(position, (int) size);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java
index aa2c83cdd..ed3896d06 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java
@@ -19,8 +19,8 @@
package com.sk89q.worldedit.regions.factory;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector2;
import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.Region;
@@ -33,8 +33,8 @@ public class CylinderRegionFactory implements RegionFactory {
}
@Override
- public Region createCenteredAt(Vector position, double size) {
- return new CylinderRegion(position, new Vector2D(size, size), position.getBlockY() - (int) (height / 2), position.getBlockY() + (int) (height / 2));
+ public Region createCenteredAt(BlockVector3 position, double size) {
+ return new CylinderRegion(position, new Vector2(size, size), position.getBlockY() - (int) (height / 2), position.getBlockY() + (int) (height / 2));
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/RegionFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/RegionFactory.java
index 51cf3bc1f..8294b0c11 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/RegionFactory.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/RegionFactory.java
@@ -19,11 +19,11 @@
package com.sk89q.worldedit.regions.factory;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
public interface RegionFactory {
- Region createCenteredAt(Vector position, double size);
+ Region createCenteredAt(BlockVector3 position, double size);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/SphereRegionFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/SphereRegionFactory.java
index cf0f488f8..4ad8d4125 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/SphereRegionFactory.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/SphereRegionFactory.java
@@ -19,15 +19,16 @@
package com.sk89q.worldedit.regions.factory;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.EllipsoidRegion;
import com.sk89q.worldedit.regions.Region;
public class SphereRegionFactory implements RegionFactory {
@Override
- public Region createCenteredAt(Vector position, double size) {
- return new EllipsoidRegion(position, new Vector(size, size, size));
+ public Region createCenteredAt(BlockVector3 position, double size) {
+ return new EllipsoidRegion(position, new Vector3(size, size, size));
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java
index 8c6628616..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
@@ -21,23 +21,23 @@ package com.sk89q.worldedit.regions.iterator;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.FlatRegion;
import java.util.Iterator;
import java.util.NoSuchElementException;
-public class FlatRegion3DIterator implements Iterator {
+public class FlatRegion3DIterator implements Iterator {
- private Iterator flatIterator;
+ private Iterator flatIterator;
private int minY;
private int maxY;
- private Vector2D next2D;
+ private BlockVector2 next2D;
private int nextY;
- public FlatRegion3DIterator(FlatRegion region, Iterator flatIterator) {
+ public FlatRegion3DIterator(FlatRegion region, Iterator flatIterator) {
checkNotNull(region);
checkNotNull(flatIterator);
@@ -63,12 +63,12 @@ public class FlatRegion3DIterator implements Iterator {
}
@Override
- public BlockVector next() {
+ public BlockVector3 next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
- BlockVector current = new BlockVector(next2D.getBlockX(), nextY, next2D.getBlockZ());
+ BlockVector3 current = new BlockVector3(next2D.getBlockX(), nextY, next2D.getBlockZ());
if (nextY < maxY) {
nextY++;
} else if (flatIterator.hasNext()) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java
index 60018afeb..e4cd6457c 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
@@ -21,13 +21,14 @@ package com.sk89q.worldedit.regions.iterator;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import java.util.Iterator;
+import java.util.NoSuchElementException;
-public class FlatRegionIterator implements Iterator {
+public class FlatRegionIterator implements Iterator {
private Region region;
private int y;
@@ -42,8 +43,8 @@ public class FlatRegionIterator implements Iterator {
this.region = region;
- Vector min = region.getMinimumPoint();
- Vector max = region.getMaximumPoint();
+ BlockVector3 min = region.getMinimumPoint();
+ BlockVector3 max = region.getMaximumPoint();
this.y = min.getBlockY();
@@ -64,18 +65,18 @@ public class FlatRegionIterator implements Iterator {
}
private void forward() {
- while (hasNext() && !region.contains(new Vector(nextX, y, nextZ))) {
+ while (hasNext() && !region.contains(new BlockVector3(nextX, y, nextZ))) {
forwardOne();
}
}
@Override
- public Vector2D next() {
+ public BlockVector2 next() {
if (!hasNext()) {
- throw new java.util.NoSuchElementException();
+ throw new NoSuchElementException();
}
- Vector2D answer = new Vector2D(nextX, nextZ);
+ BlockVector2 answer = new BlockVector2(nextX, nextZ);
forwardOne();
forward();
@@ -95,9 +96,4 @@ public class FlatRegionIterator implements Iterator {
nextX = Integer.MIN_VALUE;
}
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
}
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 35700595c..d2ab586d8 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
@@ -21,19 +21,18 @@ package com.sk89q.worldedit.regions.iterator;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import java.util.Iterator;
-public class RegionIterator implements Iterator {
+public class RegionIterator implements Iterator {
private final Region region;
private final int maxX;
private final int maxY;
private final int maxZ;
- private final Vector min;
+ private final BlockVector3 min;
private int nextX;
private int nextY;
private int nextZ;
@@ -43,7 +42,7 @@ public class RegionIterator implements Iterator {
this.region = region;
- Vector max = region.getMaximumPoint();
+ BlockVector3 max = region.getMaximumPoint();
this.maxX = max.getBlockX();
this.maxY = max.getBlockY();
this.maxZ = max.getBlockZ();
@@ -62,16 +61,16 @@ public class RegionIterator implements Iterator {
}
private void forward() {
- while (hasNext() && !region.contains(new BlockVector(nextX, nextY, nextZ))) {
+ while (hasNext() && !region.contains(new BlockVector3(nextX, nextY, nextZ))) {
forwardOne();
}
}
@Override
- public BlockVector next() {
+ public BlockVector3 next() {
if (!hasNext()) throw new java.util.NoSuchElementException();
- BlockVector answer = new BlockVector(nextX, nextY, nextZ);
+ BlockVector3 answer = new BlockVector3(nextX, nextY, nextZ);
forwardOne();
forward();
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 3495fee83..dcf098d3c 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
@@ -21,14 +21,14 @@ package com.sk89q.worldedit.regions.polyhedron;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
public class Edge {
- private final Vector start;
- private final Vector end;
+ private final Vector3 start;
+ private final Vector3 end;
- public Edge(Vector start, Vector end) {
+ public Edge(Vector3 start, Vector3 end) {
checkNotNull(start);
checkNotNull(end);
@@ -71,7 +71,7 @@ public class Edge {
* @param vertex the 3rd vertex for the triangle
* @return a triangle
*/
- public Triangle createTriangle(Vector vertex) {
+ public Triangle createTriangle(Vector3 vertex) {
checkNotNull(vertex);
return new Triangle(this.start, this.end, vertex);
}
@@ -82,7 +82,7 @@ public class Edge {
* @param vertex the second vertex
* @return a new triangle
*/
- public Triangle createTriangle2(Vector vertex) {
+ public Triangle createTriangle2(Vector3 vertex) {
checkNotNull(vertex);
return new Triangle(this.start, vertex, this.end);
}
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 01bd7f8ae..5e5f7a770 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
@@ -21,13 +21,13 @@ package com.sk89q.worldedit.regions.polyhedron;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
public class Triangle {
private String tag = "Triangle";
- private final Vector[] vertices;
- private final Vector normal;
+ private final Vector3[] vertices;
+ private final Vector3 normal;
private final double b;
/**
@@ -37,12 +37,12 @@ public class Triangle {
* @param v1 second vertex
* @param v2 third vertex
*/
- public Triangle(Vector v0, Vector v1, Vector v2) {
+ public Triangle(Vector3 v0, Vector3 v1, Vector3 v2) {
checkNotNull(v0);
checkNotNull(v1);
checkNotNull(v2);
- vertices = new Vector[] { v0, v1, v2 };
+ vertices = new Vector3[] { v0, v1, v2 };
this.normal = v1.subtract(v0).cross(v2.subtract(v0)).normalize();
this.b = Math.max(Math.max(normal.dot(v0), normal.dot(v1)), normal.dot(v2));
@@ -54,7 +54,7 @@ public class Triangle {
* @param index Vertex index. Valid input: 0..2
* @return a vertex
*/
- public Vector getVertex(int index) {
+ public Vector3 getVertex(int index) {
return vertices[index];
}
@@ -77,7 +77,7 @@ public class Triangle {
* @param pt the point to test
* @return true if the point is below
*/
- public boolean below(Vector pt) {
+ public boolean below(Vector3 pt) {
checkNotNull(pt);
return normal.dot(pt) < b;
}
@@ -88,7 +88,7 @@ public class Triangle {
* @param pt the point to test
* @return true if the point is above
*/
- public boolean above(Vector pt) {
+ public boolean above(Vector3 pt) {
checkNotNull(pt);
return normal.dot(pt) > b;
}
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 afbcb1ae1..1c16ec77a 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
@@ -21,15 +21,14 @@ package com.sk89q.worldedit.regions.selector;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
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.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
@@ -52,7 +51,7 @@ import javax.annotation.Nullable;
public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion {
private final transient ConvexPolyhedralRegion region;
- private transient BlockVector pos1;
+ private transient BlockVector3 pos1;
/**
* Create a new selector with a {@code null} world.
@@ -97,9 +96,9 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
region = new ConvexPolyhedralRegion(oldRegion.getWorld());
- 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));
}
learnChanges();
@@ -118,15 +117,15 @@ public class ConvexPolyhedralRegionSelector 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();
@@ -139,7 +138,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
}
@Override
- public BlockVector getPrimaryPosition() throws IncompleteRegionException {
+ public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
return pos1;
}
@@ -169,7 +168,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
@Override
public void learnChanges() {
- pos1 = region.getVertices().iterator().next().toBlockVector();
+ pos1 = region.getVertices().iterator().next();
}
@Override
@@ -194,7 +193,7 @@ public class ConvexPolyhedralRegionSelector 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);
@@ -205,7 +204,7 @@ public class ConvexPolyhedralRegionSelector 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);
@@ -237,12 +236,12 @@ public class ConvexPolyhedralRegionSelector 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()));
}
@@ -250,7 +249,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
for (Triangle triangle : triangles) {
final int[] v = new int[3];
for (int i = 0; i < 3; ++i) {
- v[i] = vertexIds.get(triangle.getVertex(i));
+ v[i] = vertexIds.get(triangle.getVertex(i).toBlockPoint());
}
session.dispatchCUIEvent(player, new SelectionPolygonEvent(v));
}
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 182c08f0f..9eab91500 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
@@ -21,13 +21,12 @@ package com.sk89q.worldedit.regions.selector;
import static com.google.common.base.Preconditions.checkNotNull;
-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.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
@@ -44,8 +43,8 @@ import javax.annotation.Nullable;
*/
public class CuboidRegionSelector implements RegionSelector, CUIRegion {
- protected transient BlockVector position1;
- protected transient BlockVector position2;
+ protected transient BlockVector3 position1;
+ protected transient BlockVector3 position2;
protected transient CuboidRegion region;
/**
@@ -61,7 +60,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
* @param world the world, which may be {@code null}
*/
public CuboidRegionSelector(@Nullable World world) {
- region = new CuboidRegion(world, new Vector(), new Vector());
+ region = new CuboidRegion(world, BlockVector3.ZERO, BlockVector3.ZERO);
}
/**
@@ -85,8 +84,8 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
return;
}
- position1 = oldRegion.getMinimumPoint().toBlockVector();
- position2 = oldRegion.getMaximumPoint().toBlockVector();
+ position1 = oldRegion.getMinimumPoint();
+ position2 = oldRegion.getMaximumPoint();
}
region.setPos1(position1);
@@ -100,12 +99,12 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
* @param position1 position 1
* @param position2 position 2
*/
- public CuboidRegionSelector(@Nullable World world, Vector position1, Vector position2) {
+ public CuboidRegionSelector(@Nullable World world, BlockVector3 position1, BlockVector3 position2) {
this(world);
checkNotNull(position1);
checkNotNull(position2);
- this.position1 = position1.toBlockVector();
- this.position2 = position2.toBlockVector();
+ this.position1 = position1;
+ this.position2 = position2;
region.setPos1(position1);
region.setPos2(position2);
}
@@ -122,33 +121,33 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public boolean selectPrimary(Vector position, SelectorLimits limits) {
+ public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
checkNotNull(position);
- if (position1 != null && (position.compareTo(position1) == 0)) {
+ if (position1 != null && position1.equals(position)) {
return false;
}
- position1 = position.toBlockVector();
+ position1 = position;
region.setPos1(position1);
return true;
}
@Override
- public boolean selectSecondary(Vector position, SelectorLimits limits) {
+ public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
checkNotNull(position);
- if (position2 != null && (position.compareTo(position2)) == 0) {
+ if (position2 != null && position2.equals(position)) {
return false;
}
- position2 = position.toBlockVector();
+ position2 = position;
region.setPos2(position2);
return true;
}
@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);
@@ -163,7 +162,7 @@ public class CuboidRegionSelector 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);
@@ -192,7 +191,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public BlockVector getPrimaryPosition() throws IncompleteRegionException {
+ public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
if (position1 == null) {
throw new IncompleteRegionException();
}
@@ -221,8 +220,8 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
@Override
public void learnChanges() {
- position1 = region.getPos1().toBlockVector();
- position2 = region.getPos2().toBlockVector();
+ position1 = region.getPos1();
+ position2 = region.getPos2();
}
@Override
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 8e4ce873c..ae442482c 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
@@ -21,16 +21,17 @@ package com.sk89q.worldedit.regions.selector;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.cui.CUIRegion;
import com.sk89q.worldedit.internal.cui.SelectionCylinderEvent;
import com.sk89q.worldedit.internal.cui.SelectionMinMaxEvent;
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector2;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
@@ -92,12 +93,12 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
return;
}
- Vector pos1 = oldRegion.getMinimumPoint();
- Vector pos2 = oldRegion.getMaximumPoint();
+ BlockVector3 pos1 = oldRegion.getMinimumPoint();
+ BlockVector3 pos2 = oldRegion.getMaximumPoint();
- Vector center = pos1.add(pos2).divide(2).floor();
- region.setCenter(center.toVector2D());
- region.setRadius(pos2.toVector2D().subtract(center.toVector2D()));
+ BlockVector3 center = pos1.add(pos2).divide(2).floor();
+ region.setCenter(center.toBlockVector2());
+ region.setRadius(pos2.toBlockVector2().subtract(center.toBlockVector2()).toVector2());
region.setMaximumY(Math.max(pos1.getBlockY(), pos2.getBlockY()));
region.setMinimumY(Math.min(pos1.getBlockY(), pos2.getBlockY()));
@@ -113,7 +114,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
* @param minY the minimum Y
* @param maxY the maximum Y
*/
- public CylinderRegionSelector(@Nullable World world, Vector2D center, Vector2D radius, int minY, int maxY) {
+ public CylinderRegionSelector(@Nullable World world, BlockVector2 center, Vector2 radius, int minY, int maxY) {
this(world);
region.setCenter(center);
@@ -135,27 +136,27 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public boolean selectPrimary(Vector position, SelectorLimits limits) {
- if (!region.getCenter().equals(Vector.ZERO) && position.compareTo(region.getCenter()) == 0) {
+ public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
+ if (!region.getCenter().equals(Vector3.ZERO) && position.equals(region.getCenter().toBlockPoint())) {
return false;
}
region = new CylinderRegion(region.getWorld());
- region.setCenter(position.toVector2D());
+ region.setCenter(position.toBlockVector2());
region.setY(position.getBlockY());
return true;
}
@Override
- public boolean selectSecondary(Vector position, SelectorLimits limits) {
- Vector center = region.getCenter();
- if ((center.compareTo(Vector.ZERO)) == 0) {
+ public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
+ Vector3 center = region.getCenter();
+ if (center.equals(Vector3.ZERO)) {
return true;
}
- final Vector2D diff = position.subtract(center).toVector2D();
- final Vector2D minRadius = Vector2D.getMaximum(diff, diff.multiply(-1.0));
+ final Vector2 diff = position.toVector3().subtract(center).toVector2();
+ final Vector2 minRadius = diff.getMaximum(diff.multiply(-1.0));
region.extendRadius(minRadius);
region.setY(position.getBlockY());
@@ -164,17 +165,17 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
+ public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
player.print("Starting a new cylindrical selection at " + pos + ".");
session.describeCUI(player);
}
@Override
- public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
- Vector center = region.getCenter();
+ public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
+ Vector3 center = region.getCenter();
- if (!center.equals(Vector.ZERO)) {
+ 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() + ").");
} else {
player.printError("You must select the center point before setting the radius.");
@@ -190,12 +191,12 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public BlockVector getPrimaryPosition() throws IncompleteRegionException {
+ public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
if (!isDefined()) {
throw new IncompleteRegionException();
}
- return region.getCenter().toBlockVector();
+ return region.getCenter().toBlockPoint();
}
@Override
@@ -214,7 +215,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
@Override
public boolean isDefined() {
- return !region.getRadius().equals(Vector2D.ZERO);
+ return !region.getRadius().equals(Vector2.ZERO);
}
@Override
@@ -235,10 +236,10 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
public List getInformationLines() {
final List lines = new ArrayList<>();
- if (!region.getCenter().equals(Vector.ZERO)) {
+ if (!region.getCenter().equals(Vector3.ZERO)) {
lines.add("Center: " + region.getCenter());
}
- if (!region.getRadius().equals(Vector2D.ZERO)) {
+ if (!region.getRadius().equals(Vector2.ZERO)) {
lines.add("Radius: " + region.getRadius());
}
@@ -252,7 +253,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
@Override
public void describeCUI(LocalSession session, Actor player) {
- session.dispatchCUIEvent(player, new SelectionCylinderEvent(region.getCenter(), region.getRadius()));
+ session.dispatchCUIEvent(player, new SelectionCylinderEvent(region.getCenter().toBlockPoint(), region.getRadius()));
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
}
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 ca32ac3dc..8274a6e7b 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
@@ -21,14 +21,14 @@ package com.sk89q.worldedit.regions.selector;
import static com.google.common.base.Preconditions.checkNotNull;
-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.SelectionEllipsoidPointEvent;
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.EllipsoidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
@@ -61,7 +61,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
* @param world the world, which may be {@code null}
*/
public EllipsoidRegionSelector(@Nullable World world) {
- region = new EllipsoidRegion(world, new Vector(), new Vector());
+ region = new EllipsoidRegion(world, BlockVector3.ZERO, Vector3.ZERO);
}
/**
@@ -83,12 +83,12 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
return;
}
- BlockVector pos1 = oldRegion.getMinimumPoint().toBlockVector();
- BlockVector pos2 = oldRegion.getMaximumPoint().toBlockVector();
+ BlockVector3 pos1 = oldRegion.getMinimumPoint();
+ BlockVector3 pos2 = oldRegion.getMaximumPoint();
- Vector center = pos1.add(pos2).divide(2).floor();
+ BlockVector3 center = pos1.add(pos2).divide(2).floor();
region.setCenter(center);
- region.setRadius(pos2.subtract(center));
+ region.setRadius(pos2.subtract(center).toVector3());
}
}
@@ -99,7 +99,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
* @param center the center
* @param radius the radius
*/
- public EllipsoidRegionSelector(@Nullable World world, Vector center, Vector radius) {
+ public EllipsoidRegionSelector(@Nullable World world, BlockVector3 center, Vector3 radius) {
this(world);
region.setCenter(center);
@@ -118,32 +118,32 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public boolean selectPrimary(Vector position, SelectorLimits limits) {
+ public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
if (position.equals(region.getCenter()) && region.getRadius().lengthSq() == 0) {
return false;
}
- region.setCenter(position.toBlockVector());
- region.setRadius(new Vector());
+ region.setCenter(position);
+ region.setRadius(Vector3.ZERO);
started = true;
return true;
}
@Override
- public boolean selectSecondary(Vector position, SelectorLimits limits) {
+ public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
if (!started) {
return false;
}
- final Vector diff = position.subtract(region.getCenter());
- final Vector minRadius = Vector.getMaximum(diff, diff.multiply(-1.0));
+ final Vector3 diff = position.toVector3().subtract(region.getCenter());
+ final Vector3 minRadius = diff.getMaximum(diff.multiply(-1.0));
region.extendRadius(minRadius);
return true;
}
@Override
- public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
+ public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
if (isDefined()) {
player.print("Center position set to " + region.getCenter() + " (" + region.getArea() + ").");
} else {
@@ -154,7 +154,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
+ public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
if (isDefined()) {
player.print("Radius set to " + region.getRadius() + " (" + region.getArea() + ").");
} else {
@@ -194,8 +194,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
@Override
public void clear() {
- region.setCenter(new Vector());
- region.setRadius(new Vector());
+ region.setCenter(BlockVector3.ZERO);
+ region.setRadius(Vector3.ZERO);
}
@Override
@@ -207,12 +207,12 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
public List getInformationLines() {
final List lines = new ArrayList<>();
- final Vector center = region.getCenter();
+ final Vector3 center = region.getCenter();
if (center.lengthSq() > 0) {
lines.add("Center: " + center);
}
- final Vector radius = region.getRadius();
+ final Vector3 radius = region.getRadius();
if (radius.lengthSq() > 0) {
lines.add("X/Y/Z radius: " + radius);
}
@@ -227,8 +227,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
@Override
public void describeCUI(LocalSession session, Actor player) {
- session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(0, region.getCenter()));
- session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(1, region.getRadius()));
+ session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(0, region.getCenter().toBlockPoint()));
+ session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(1, region.getRadius().toBlockPoint()));
}
@Override
@@ -253,8 +253,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public BlockVector getPrimaryPosition() throws IncompleteRegionException {
- return region.getCenter().toBlockVector();
+ public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
+ return region.getCenter().toBlockPoint();
}
}
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 0e239f0d3..bf5aeaace 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,10 +19,9 @@
package com.sk89q.worldedit.regions.selector;
-import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalSession;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.extension.platform.Actor;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
@@ -63,8 +62,8 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
return;
}
- position1 = region.getMinimumPoint().toBlockVector();
- position2 = region.getMaximumPoint().toBlockVector();
+ position1 = region.getMinimumPoint();
+ position2 = region.getMaximumPoint();
region.setPos1(position1);
region.setPos2(position2);
}
@@ -76,28 +75,28 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
* @param position1 the first position
* @param position2 the second position
*/
- public ExtendingCuboidRegionSelector(@Nullable World world, Vector position1, Vector position2) {
+ public ExtendingCuboidRegionSelector(@Nullable World world, BlockVector3 position1, BlockVector3 position2) {
this(world);
- position1 = Vector.getMinimum(position1, position2);
- position2 = Vector.getMaximum(position1, position2);
+ position1 = position1.getMinimum(position2);
+ position2 = position1.getMaximum(position2);
region.setPos1(position1);
region.setPos2(position2);
}
@Override
- public boolean selectPrimary(Vector position, SelectorLimits limits) {
- if (position1 != null && position2 != null && position.compareTo(position1) == 0 && position.compareTo(position2) == 0) {
+ public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
+ if (position1 != null && position2 != null && position.equals(position1) && position.equals(position2)) {
return false;
}
- position1 = position2 = position.toBlockVector();
+ position1 = position2 = position;
region.setPos1(position1);
region.setPos2(position2);
return true;
}
@Override
- public boolean selectSecondary(Vector position, SelectorLimits limits) {
+ public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
if (position1 == null || position2 == null) {
return selectPrimary(position, limits);
}
@@ -114,10 +113,10 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
double y2 = Math.max(position.getY(), position2.getY());
double z2 = Math.max(position.getZ(), position2.getZ());
- final BlockVector o1 = position1;
- final BlockVector o2 = position2;
- position1 = new BlockVector(x1, y1, z1);
- position2 = new BlockVector(x2, y2, z2);
+ final BlockVector3 o1 = position1;
+ final BlockVector3 o2 = position2;
+ position1 = new BlockVector3(x1, y1, z1);
+ position2 = new BlockVector3(x2, y2, z2);
region.setPos1(position1);
region.setPos2(position2);
@@ -129,14 +128,14 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
}
@Override
- public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
+ public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
player.print("Started selection at " + pos + " (" + region.getArea() + ").");
explainRegionAdjust(player, session);
}
@Override
- public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
+ public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
player.print("Extended selection to encompass " + 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 2cf8682b8..fbc2bd123 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
@@ -21,16 +21,15 @@ package com.sk89q.worldedit.regions.selector;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
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.SelectionMinMaxEvent;
import com.sk89q.worldedit.internal.cui.SelectionPoint2DEvent;
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
@@ -48,7 +47,7 @@ import javax.annotation.Nullable;
*/
public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
- private transient BlockVector pos1;
+ private transient BlockVector3 pos1;
private transient Polygonal2DRegion region;
/**
@@ -91,9 +90,9 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
final int minY = oldRegion.getMinimumPoint().getBlockY();
final int maxY = oldRegion.getMaximumPoint().getBlockY();
- List points = oldRegion.polygonize(Integer.MAX_VALUE);
+ List points = oldRegion.polygonize(Integer.MAX_VALUE);
- pos1 = points.get(0).toVector(minY).toBlockVector();
+ pos1 = points.get(0).toBlockVector3(minY);
region = new Polygonal2DRegion(oldRegion.getWorld(), points, minY, maxY);
}
}
@@ -106,11 +105,11 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
* @param minY the minimum Y
* @param maxY the maximum Y
*/
- public Polygonal2DRegionSelector(@Nullable World world, List points, int minY, int maxY) {
+ public Polygonal2DRegionSelector(@Nullable World world, List points, int minY, int maxY) {
checkNotNull(points);
- final BlockVector2D pos2D = points.get(0);
- pos1 = new BlockVector(pos2D.getX(), minY, pos2D.getZ());
+ final BlockVector2 pos2D = points.get(0);
+ pos1 = new BlockVector3(pos2D.getX(), minY, pos2D.getZ());
region = new Polygonal2DRegion(world, points, minY, maxY);
}
@@ -126,12 +125,12 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public boolean selectPrimary(Vector position, SelectorLimits limits) {
+ public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
if (position.equals(pos1)) {
return false;
}
- pos1 = position.toBlockVector();
+ pos1 = position;
region = new Polygonal2DRegion(region.getWorld());
region.addPoint(position);
region.expandY(position.getBlockY());
@@ -140,11 +139,11 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public boolean selectSecondary(Vector position, SelectorLimits limits) {
+ public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
if (region.size() > 0) {
- final List points = region.getPoints();
+ final List points = region.getPoints();
- final BlockVector2D lastPoint = points.get(region.size() - 1);
+ final BlockVector2 lastPoint = points.get(region.size() - 1);
if (lastPoint.getBlockX() == position.getBlockX() && lastPoint.getBlockZ() == position.getBlockZ()) {
return false;
}
@@ -163,7 +162,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
+ public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
player.print("Starting a new polygon at " + pos + ".");
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
@@ -172,7 +171,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
+ public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
player.print("Added point #" + region.size() + " at " + pos + ".");
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
@@ -186,7 +185,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
}
@Override
- public BlockVector getPrimaryPosition() throws IncompleteRegionException {
+ public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
if (pos1 == null) {
throw new IncompleteRegionException();
}
@@ -215,8 +214,8 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
@Override
public void learnChanges() {
- BlockVector2D pt = region.getPoints().get(0);
- pos1 = new BlockVector(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ());
+ BlockVector2 pt = region.getPoints().get(0);
+ pos1 = new BlockVector3(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ());
}
@Override
@@ -251,7 +250,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
@Override
public void describeCUI(LocalSession session, Actor player) {
- final List points = region.getPoints();
+ final List points = region.getPoints();
for (int id = 0; id < points.size(); id++) {
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(id, points.get(id), getArea()));
}
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 8141748f3..6414c2cde 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
@@ -20,8 +20,9 @@
package com.sk89q.worldedit.regions.selector;
import com.sk89q.worldedit.LocalSession;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.extension.platform.Actor;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
@@ -56,9 +57,9 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
*/
public SphereRegionSelector(RegionSelector oldSelector) {
super(oldSelector);
- final Vector radius = region.getRadius();
+ final Vector3 radius = region.getRadius();
final double radiusScalar = Math.max(Math.max(radius.getX(), radius.getY()), radius.getZ());
- region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
+ region.setRadius(new Vector3(radiusScalar, radiusScalar, radiusScalar));
}
/**
@@ -68,24 +69,24 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
* @param center the center position
* @param radius the radius
*/
- public SphereRegionSelector(@Nullable World world, Vector center, int radius) {
- super(world, center, new Vector(radius, radius, radius));
+ public SphereRegionSelector(@Nullable World world, BlockVector3 center, int radius) {
+ super(world, center, new Vector3(radius, radius, radius));
}
@Override
- public boolean selectSecondary(Vector position, SelectorLimits limits) {
+ public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
if (!started) {
return false;
}
- final double radiusScalar = Math.ceil(position.distance(region.getCenter()));
- region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
+ final double radiusScalar = Math.ceil(position.toVector3().distance(region.getCenter()));
+ region.setRadius(new Vector3(radiusScalar, radiusScalar, radiusScalar));
return true;
}
@Override
- public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
+ public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
if (isDefined()) {
player.print("Radius set to " + region.getRadius().getX() + " (" + region.getArea() + ").");
} else {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java
index 942b55c6c..0ebdc7393 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java
@@ -20,7 +20,7 @@
package com.sk89q.worldedit.regions.shape;
import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region;
@@ -48,8 +48,8 @@ public abstract class ArbitraryBiomeShape {
this.extent = new CuboidRegion(extent.getWorld(), extent.getMinimumPoint(), extent.getMaximumPoint());
}
- Vector2D min = extent.getMinimumPoint().toVector2D();
- Vector2D max = extent.getMaximumPoint().toVector2D();
+ BlockVector2 min = extent.getMinimumPoint().toBlockVector2();
+ BlockVector2 max = extent.getMaximumPoint().toBlockVector2();
cacheOffsetX = min.getBlockX() - 1;
cacheOffsetZ = min.getBlockZ() - 1;
@@ -60,7 +60,7 @@ public abstract class ArbitraryBiomeShape {
cache = new BaseBiome[cacheSizeX * cacheSizeZ];
}
- protected Iterable getExtent() {
+ protected Iterable getExtent() {
return extent.asFlatRegion();
}
@@ -130,7 +130,7 @@ public abstract class ArbitraryBiomeShape {
public int generate(EditSession editSession, BaseBiome baseBiome, boolean hollow) {
int affected = 0;
- for (Vector2D position : getExtent()) {
+ for (BlockVector2 position : getExtent()) {
int x = position.getBlockX();
int z = position.getBlockZ();
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java
index 7629637d4..a361b528f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java
@@ -19,10 +19,10 @@
package com.sk89q.worldedit.regions.shape;
-import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.pattern.Pattern;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@@ -65,7 +65,7 @@ public abstract class ArbitraryShape {
public int generate(EditSession editSession, Pattern pattern, boolean hollow) throws MaxChangedBlocksException {
int affected = 0;
- for (BlockVector position : getExtent()) {
+ for (BlockVector3 position : getExtent()) {
int x = position.getBlockX();
int y = position.getBlockY();
int z = position.getBlockZ();
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 e8419cf00..08994c717 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,7 +19,7 @@
package com.sk89q.worldedit.regions.shape;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@@ -35,7 +35,7 @@ public class RegionShape extends ArbitraryShape {
@Override
protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) {
- if (!this.extent.contains(new Vector(x, y, z))) {
+ if (!this.extent.contains(new BlockVector3(x, y, z))) {
return null;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java
index 8757235a3..5022c90af 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java
@@ -19,30 +19,30 @@
package com.sk89q.worldedit.regions.shape;
-import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
- private final Vector unit;
- private final Vector zero2;
- private Vector current = new Vector();
+ private final Vector3 unit;
+ private final Vector3 zero2;
+ private Vector3 current = Vector3.ZERO;
private EditSession editSession;
- public WorldEditExpressionEnvironment(EditSession editSession, Vector unit, Vector zero) {
+ public WorldEditExpressionEnvironment(EditSession editSession, Vector3 unit, Vector3 zero) {
this.editSession = editSession;
this.unit = unit;
this.zero2 = zero.add(0.5, 0.5, 0.5);
}
- public BlockVector toWorld(double x, double y, double z) {
+ public BlockVector3 toWorld(double x, double y, double z) {
// unscale, unoffset, round-nearest
- return new Vector(x, y, z).multiply(unit).add(zero2).toBlockPoint();
+ return new Vector3(x, y, z).multiply(unit).add(zero2).toBlockPoint();
}
- public Vector toWorldRel(double x, double y, double z) {
+ public Vector3 toWorldRel(double x, double y, double z) {
return current.add(x, y, z);
}
@@ -76,7 +76,7 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
return 0;
}
- public void setCurrentBlock(Vector current) {
+ public void setCurrentBlock(Vector3 current) {
this.current = current;
}
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 e4a9ade5a..d50a277ac 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
@@ -21,13 +21,13 @@ package com.sk89q.worldedit.session;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
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.mask.ExistingBlockMask;
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.transform.Transform;
/**
@@ -39,7 +39,7 @@ public class PasteBuilder {
private final Transform transform;
private final Extent targetExtent;
- private Vector to = new Vector();
+ private BlockVector3 to = BlockVector3.ZERO;
private boolean ignoreAirBlocks;
/**
@@ -62,7 +62,7 @@ public class PasteBuilder {
* @param to the target location
* @return this builder instance
*/
- public PasteBuilder to(Vector to) {
+ public PasteBuilder to(BlockVector3 to) {
this.to = to;
return this;
}
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 72ae6ef2b..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,12 +19,11 @@
package com.sk89q.worldedit.session.request;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.NullRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
@@ -64,17 +63,17 @@ public class RequestSelection implements Region {
}
@Override
- public Vector getMinimumPoint() {
+ public BlockVector3 getMinimumPoint() {
return getRegion().getMinimumPoint();
}
@Override
- public Vector getMaximumPoint() {
+ public BlockVector3 getMaximumPoint() {
return getRegion().getMaximumPoint();
}
@Override
- public Vector getCenter() {
+ public Vector3 getCenter() {
return getRegion().getCenter();
}
@@ -99,32 +98,32 @@ public class RequestSelection implements Region {
}
@Override
- public void expand(Vector... changes) throws RegionOperationException {
+ public void expand(BlockVector3... changes) throws RegionOperationException {
getRegion().expand(changes);
}
@Override
- public void contract(Vector... changes) throws RegionOperationException {
+ public void contract(BlockVector3... changes) throws RegionOperationException {
getRegion().contract(changes);
}
@Override
- public void shift(Vector change) throws RegionOperationException {
+ public void shift(BlockVector3 change) throws RegionOperationException {
getRegion().shift(change);
}
@Override
- public boolean contains(Vector position) {
+ public boolean contains(BlockVector3 position) {
return getRegion().contains(position);
}
@Override
- public Set getChunks() {
+ public Set getChunks() {
return getRegion().getChunks();
}
@Override
- public Set getChunkCubes() {
+ public Set getChunkCubes() {
return getRegion().getChunkCubes();
}
@@ -144,12 +143,12 @@ public class RequestSelection implements Region {
}
@Override
- public List polygonize(int maxPoints) {
+ public List polygonize(int maxPoints) {
return getRegion().polygonize(maxPoints);
}
@Override
- public Iterator iterator() {
+ public Iterator iterator() {
return getRegion().iterator();
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java
index 0907753a4..e62796bd7 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java
@@ -19,7 +19,8 @@
package com.sk89q.worldedit.util;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import javax.annotation.Nullable;
@@ -28,32 +29,32 @@ import javax.annotation.Nullable;
*/
public enum Direction {
- NORTH(new Vector(0, 0, -1), Flag.CARDINAL),
- EAST(new Vector(1, 0, 0), Flag.CARDINAL),
- SOUTH(new Vector(0, 0, 1), Flag.CARDINAL),
- WEST(new Vector(-1, 0, 0), Flag.CARDINAL),
+ NORTH(new Vector3(0, 0, -1), Flag.CARDINAL),
+ EAST(new Vector3(1, 0, 0), Flag.CARDINAL),
+ SOUTH(new Vector3(0, 0, 1), Flag.CARDINAL),
+ WEST(new Vector3(-1, 0, 0), Flag.CARDINAL),
- UP(new Vector(0, 1, 0), Flag.UPRIGHT),
- DOWN(new Vector(0, -1, 0), Flag.UPRIGHT),
+ UP(new Vector3(0, 1, 0), Flag.UPRIGHT),
+ DOWN(new Vector3(0, -1, 0), Flag.UPRIGHT),
- NORTHEAST(new Vector(1, 0, -1), Flag.ORDINAL),
- NORTHWEST(new Vector(-1, 0, -1), Flag.ORDINAL),
- SOUTHEAST(new Vector(1, 0, 1), Flag.ORDINAL),
- SOUTHWEST(new Vector(-1, 0, 1), Flag.ORDINAL),
+ NORTHEAST(new Vector3(1, 0, -1), Flag.ORDINAL),
+ NORTHWEST(new Vector3(-1, 0, -1), Flag.ORDINAL),
+ SOUTHEAST(new Vector3(1, 0, 1), Flag.ORDINAL),
+ SOUTHWEST(new Vector3(-1, 0, 1), Flag.ORDINAL),
- WEST_NORTHWEST(new Vector(-Math.cos(Math.PI / 8), 0, -Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
- WEST_SOUTHWEST(new Vector(-Math.cos(Math.PI / 8), 0, Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
- NORTH_NORTHWEST(new Vector(-Math.sin(Math.PI / 8), 0, -Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
- NORTH_NORTHEAST(new Vector(Math.sin(Math.PI / 8), 0, -Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
- EAST_NORTHEAST(new Vector(Math.cos(Math.PI / 8), 0, -Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
- EAST_SOUTHEAST(new Vector(Math.cos(Math.PI / 8), 0, Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
- SOUTH_SOUTHEAST(new Vector(Math.sin(Math.PI / 8), 0, Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
- SOUTH_SOUTHWEST(new Vector(-Math.sin(Math.PI / 8), 0, Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL);
+ WEST_NORTHWEST(new Vector3(-Math.cos(Math.PI / 8), 0, -Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
+ WEST_SOUTHWEST(new Vector3(-Math.cos(Math.PI / 8), 0, Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
+ NORTH_NORTHWEST(new Vector3(-Math.sin(Math.PI / 8), 0, -Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
+ NORTH_NORTHEAST(new Vector3(Math.sin(Math.PI / 8), 0, -Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
+ EAST_NORTHEAST(new Vector3(Math.cos(Math.PI / 8), 0, -Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
+ EAST_SOUTHEAST(new Vector3(Math.cos(Math.PI / 8), 0, Math.sin(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
+ SOUTH_SOUTHEAST(new Vector3(Math.sin(Math.PI / 8), 0, Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL),
+ SOUTH_SOUTHWEST(new Vector3(-Math.sin(Math.PI / 8), 0, Math.cos(Math.PI / 8)), Flag.SECONDARY_ORDINAL);
- private final Vector direction;
+ private final Vector3 direction;
private final int flags;
- Direction(Vector vector, int flags) {
+ Direction(Vector3 vector, int flags) {
this.direction = vector.normalize();
this.flags = flags;
}
@@ -105,10 +106,19 @@ public enum Direction {
*
* @return the vector
*/
- public Vector toVector() {
+ public Vector3 toVector() {
return direction;
}
+ /**
+ * Get the vector.
+ *
+ * @return the vector
+ */
+ public BlockVector3 toBlockVector() {
+ return direction.toBlockPoint();
+ }
+
/**
* Find the closest direction to the given direction vector.
*
@@ -117,9 +127,9 @@ public enum Direction {
* @return the closest direction, or null if no direction can be returned
*/
@Nullable
- public static Direction findClosest(Vector vector, int flags) {
+ public static Direction findClosest(Vector3 vector, int flags) {
if ((flags & Flag.UPRIGHT) == 0) {
- vector = vector.setY(0);
+ vector = vector.withY(0);
}
vector = vector.normalize();
@@ -141,7 +151,7 @@ public enum Direction {
}
/**
- * Flags to use with {@link #findClosest(Vector, int)}.
+ * Flags to use with {@link #findClosest(Vector3, int)}.
*/
public static final class Flag {
public static int CARDINAL = 0x1;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java
index 9a768e33d..35552b8d9 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java
@@ -21,7 +21,7 @@ package com.sk89q.worldedit.util;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Objects;
@@ -31,15 +31,15 @@ import java.util.Objects;
*/
public final class LocatedBlock {
- private final Vector location;
+ private final BlockVector3 location;
private final BlockStateHolder block;
- public LocatedBlock(Vector location, BlockStateHolder block) {
+ public LocatedBlock(BlockVector3 location, BlockStateHolder block) {
this.location = checkNotNull(location);
this.block = checkNotNull(block);
}
- public Vector getLocation() {
+ public BlockVector3 getLocation() {
return location;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java
index 521545b37..82186bbb1 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java
@@ -21,8 +21,8 @@ package com.sk89q.worldedit.util;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.math.Vector3;
/**
* Represents a location in a world with has a direction.
@@ -37,7 +37,7 @@ import com.sk89q.worldedit.extent.Extent;
public class Location {
private final Extent extent;
- private final Vector position;
+ private final Vector3 position;
private final float pitch;
private final float yaw;
@@ -48,7 +48,7 @@ public class Location {
* @param extent the extent
*/
public Location(Extent extent) {
- this(extent, new Vector(), new Vector());
+ this(extent, Vector3.ZERO, Vector3.ZERO);
}
/**
@@ -61,7 +61,7 @@ public class Location {
* @param z the Z coordinate
*/
public Location(Extent extent, double x, double y, double z) {
- this(extent, new Vector(x, y, z), new Vector());
+ this(extent, new Vector3(x, y, z), Vector3.ZERO);
}
/**
@@ -71,8 +71,8 @@ public class Location {
* @param extent the extent
* @param position the position vector
*/
- public Location(Extent extent, Vector position) {
- this(extent, position, new Vector());
+ public Location(Extent extent, Vector3 position) {
+ this(extent, position, Vector3.ZERO);
}
/**
@@ -85,8 +85,8 @@ public class Location {
* @param z the Z coordinate
* @param direction the direction vector
*/
- public Location(Extent extent, double x, double y, double z, Vector direction) {
- this(extent, new Vector(x, y, z), direction);
+ public Location(Extent extent, double x, double y, double z, Vector3 direction) {
+ this(extent, new Vector3(x, y, z), direction);
}
/**
@@ -101,7 +101,7 @@ public class Location {
* @param pitch the pitch, in degrees
*/
public Location(Extent extent, double x, double y, double z, float yaw, float pitch) {
- this(extent, new Vector(x, y, z), yaw, pitch);
+ this(extent, new Vector3(x, y, z), yaw, pitch);
}
/**
@@ -112,8 +112,8 @@ public class Location {
* @param position the position vector
* @param direction the direction vector
*/
- public Location(Extent extent, Vector position, Vector direction) {
- this(extent, position, direction.toYaw(), direction.toPitch());
+ public Location(Extent extent, Vector3 position, Vector3 direction) {
+ this(extent, position, (float) direction.toYaw(), (float) direction.toPitch());
}
/**
@@ -125,7 +125,7 @@ public class Location {
* @param yaw the yaw, in degrees
* @param pitch the pitch, in degrees
*/
- public Location(Extent extent, Vector position, float yaw, float pitch) {
+ public Location(Extent extent, Vector3 position, float yaw, float pitch) {
checkNotNull(extent);
checkNotNull(position);
this.extent = extent;
@@ -207,11 +207,11 @@ public class Location {
*
* @return the direction vector
*/
- public Vector getDirection() {
+ public Vector3 getDirection() {
double yaw = Math.toRadians(this.getYaw());
double pitch = Math.toRadians(this.getPitch());
double xz = Math.cos(pitch);
- return new Vector(
+ return new Vector3(
-xz * Math.sin(yaw),
-Math.sin(pitch),
xz * Math.cos(yaw));
@@ -232,16 +232,16 @@ public class Location {
* @param direction the new direction
* @return the new instance
*/
- public Location setDirection(Vector direction) {
- return new Location(extent, position, direction.toYaw(), direction.toPitch());
+ public Location setDirection(Vector3 direction) {
+ return new Location(extent, position, (float) direction.toYaw(), (float) direction.toPitch());
}
/**
- * Get a {@link Vector} form of this location's position.
+ * Get a {@link Vector3} form of this location's position.
*
* @return a vector
*/
- public Vector toVector() {
+ public Vector3 toVector() {
return position;
}
@@ -260,7 +260,7 @@ public class Location {
* @return the rounded X component
*/
public int getBlockX() {
- return position.getBlockX();
+ return (int) Math.floor(position.getX());
}
/**
@@ -271,18 +271,7 @@ public class Location {
* @return a new immutable instance
*/
public Location setX(double x) {
- return new Location(extent, position.setX(x), yaw, pitch);
- }
-
- /**
- * Return a copy of this object with the X component of the new object
- * set to the given value.
- *
- * @param x the new value for the X component
- * @return a new immutable instance
- */
- public Location setX(int x) {
- return new Location(extent, position.setX(x), yaw, pitch);
+ return new Location(extent, position.withX(x), yaw, pitch);
}
/**
@@ -300,7 +289,7 @@ public class Location {
* @return the rounded Y component
*/
public int getBlockY() {
- return position.getBlockY();
+ return (int) Math.floor(position.getY());
}
/**
@@ -311,18 +300,7 @@ public class Location {
* @return a new immutable instance
*/
public Location setY(double y) {
- return new Location(extent, position.setY(y), yaw, pitch);
- }
-
- /**
- * Return a copy of this object with the Y component of the new object
- * set to the given value.
- *
- * @param y the new value for the Y component
- * @return a new immutable instance
- */
- public Location setY(int y) {
- return new Location(extent, position.setY(y), yaw, pitch);
+ return new Location(extent, position.withY(y), yaw, pitch);
}
/**
@@ -340,7 +318,7 @@ public class Location {
* @return the rounded Z component
*/
public int getBlockZ() {
- return position.getBlockZ();
+ return (int) Math.floor(position.getZ());
}
/**
@@ -351,18 +329,7 @@ public class Location {
* @return a new immutable instance
*/
public Location setZ(double z) {
- return new Location(extent, position.setZ(z), yaw, pitch);
- }
-
- /**
- * Return a copy of this object with the Z component of the new object
- * set to the given value.
- *
- * @param z the new value for the Y component
- * @return a new immutable instance
- */
- public Location setZ(int z) {
- return new Location(extent, position.setZ(z), yaw, pitch);
+ return new Location(extent, position.withZ(z), yaw, pitch);
}
/**
@@ -371,7 +338,7 @@ public class Location {
* @param position The new position
* @return a new immutable instance
*/
- public Location setPosition(Vector position) {
+ public Location setPosition(Vector3 position) {
return new Location(extent, position, yaw, pitch);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java
index be654ec17..1c2a97b3f 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,8 +19,9 @@
package com.sk89q.worldedit.util;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.entity.Player;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.World;
/**
@@ -35,10 +36,10 @@ public class TargetBlock {
private World world;
private int maxDistance;
private double checkDistance, curDistance;
- private Vector targetPos = new Vector();
- private Vector targetPosDouble = new Vector();
- private Vector prevPos = new Vector();
- private Vector offset = new Vector();
+ private BlockVector3 targetPos = BlockVector3.ZERO;
+ private Vector3 targetPosDouble = Vector3.ZERO;
+ private BlockVector3 prevPos = BlockVector3.ZERO;
+ private Vector3 offset = Vector3.ZERO;
/**
* Constructor requiring a player, uses default values
@@ -73,7 +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
*/
- 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) {
this.maxDistance = maxDistance;
this.checkDistance = checkDistance;
this.curDistance = 0;
@@ -82,7 +83,7 @@ public class TargetBlock {
double h = (checkDistance * Math.cos(Math.toRadians(yRotation)));
- offset = new Vector((h * Math.cos(Math.toRadians(xRotation))),
+ offset = new Vector3((h * Math.cos(Math.toRadians(xRotation))),
(checkDistance * Math.sin(Math.toRadians(yRotation))),
(h * Math.sin(Math.toRadians(xRotation))));
@@ -101,7 +102,7 @@ public class TargetBlock {
boolean searchForLastBlock = true;
Location lastBlock = null;
while (getNextBlock() != null) {
- if (world.getBlock(getCurrentBlock().toVector()).getBlockType().getMaterial().isAir()) {
+ if (world.getBlock(targetPos).getBlockType().getMaterial().isAir()) {
if (searchForLastBlock) {
lastBlock = getCurrentBlock();
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
@@ -123,7 +124,7 @@ public class TargetBlock {
* @return Block
*/
public Location getTargetBlock() {
- while (getNextBlock() != null && world.getBlock(getCurrentBlock().toVector()).getBlockType().getMaterial().isAir()) ;
+ while (getNextBlock() != null && world.getBlock(targetPos).getBlockType().getMaterial().isAir()) ;
return getCurrentBlock();
}
@@ -134,7 +135,7 @@ public class TargetBlock {
* @return Block
*/
public Location getSolidTargetBlock() {
- while (getNextBlock() != null && !world.getBlock(getCurrentBlock().toVector()).getBlockType().getMaterial().isMovementBlocker()) ;
+ while (getNextBlock() != null && !world.getBlock(targetPos).getBlockType().getMaterial().isMovementBlocker()) ;
return getCurrentBlock();
}
@@ -161,7 +162,7 @@ public class TargetBlock {
return null;
}
- return new Location(world, targetPos);
+ return new Location(world, targetPos.toVector3());
}
/**
@@ -173,7 +174,7 @@ public class TargetBlock {
if (curDistance > maxDistance) {
return null;
} else {
- return new Location(world, targetPos);
+ return new Location(world, targetPos.toVector3());
}
}
@@ -183,7 +184,7 @@ public class TargetBlock {
* @return block position
*/
public Location getPreviousBlock() {
- return new Location(world, prevPos);
+ return new Location(world, prevPos.toVector3());
}
public Location getAnyTargetBlockFace() {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java
index 58f32b480..7532f947f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java
@@ -22,7 +22,7 @@ package com.sk89q.worldedit.util;
import com.google.common.collect.Sets;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
@@ -49,7 +49,7 @@ public class TreeGenerator {
MEGA_REDWOOD("Large spruce tree", "largespruce", "megaredwood"),
RANDOM_REDWOOD("Random spruce tree", "randspruce", "randredwood", "randomredwood", "anyredwood") {
@Override
- public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
+ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
TreeType[] choices = { REDWOOD, TALL_REDWOOD, MEGA_REDWOOD };
return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos);
}
@@ -58,7 +58,7 @@ public class TreeGenerator {
TALL_BIRCH("Tall birch tree", "tallbirch"),
RANDOM_BIRCH("Random birch tree", "randbirch", "randombirch") {
@Override
- public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
+ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
TreeType[] choices = { BIRCH, TALL_BIRCH };
return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos);
}
@@ -67,13 +67,13 @@ public class TreeGenerator {
SMALL_JUNGLE("Small jungle tree", "shortjungle", "smalljungle"),
SHORT_JUNGLE("Short jungle tree") {
@Override
- public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
+ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
return SMALL_JUNGLE.generate(editSession, pos);
}
},
RANDOM_JUNGLE("Random jungle tree", "randjungle", "randomjungle") {
@Override
- public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
+ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
TreeType[] choices = { JUNGLE, SMALL_JUNGLE };
return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos);
}
@@ -83,7 +83,7 @@ public class TreeGenerator {
BROWN_MUSHROOM("Brown mushroom", "brownmushroom", "browngiantmushroom"),
RANDOM_MUSHROOM("Random mushroom", "randmushroom", "randommushroom") {
@Override
- public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
+ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
TreeType[] choices = { RED_MUSHROOM, BROWN_MUSHROOM };
return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos);
}
@@ -93,14 +93,14 @@ public class TreeGenerator {
DARK_OAK("Dark oak tree", "darkoak"),
PINE("Pine tree", "pine") {
@Override
- public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
+ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
makePineTree(editSession, pos);
return true;
}
},
RANDOM("Random tree", "rand", "random") {
@Override
- public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
+ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
TreeType[] choices = TreeType.values();
return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos);
}
@@ -139,7 +139,7 @@ public class TreeGenerator {
return Collections.unmodifiableSet(primaryAliases);
}
- public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException {
+ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
return editSession.getWorld().generateTree(this, editSession, pos);
}
@@ -174,7 +174,7 @@ public class TreeGenerator {
*
* @param basePosition the base position
*/
- private static void makePineTree(EditSession editSession, Vector basePosition)
+ private static void makePineTree(EditSession editSession, BlockVector3 basePosition)
throws MaxChangedBlocksException {
int trunkHeight = (int) Math.floor(Math.random() * 2) + 3;
int height = (int) Math.floor(Math.random() * 5) + 8;
@@ -250,7 +250,7 @@ public class TreeGenerator {
* @return whether a block was changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
- private static boolean setChanceBlockIfAir(EditSession session, Vector position, BlockStateHolder block, double probability)
+ private static boolean setChanceBlockIfAir(EditSession session, BlockVector3 position, BlockStateHolder block, double probability)
throws MaxChangedBlocksException {
return Math.random() <= probability && setBlockIfAir(session, position, block);
}
@@ -263,7 +263,7 @@ public class TreeGenerator {
* @return if block was changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
- private static boolean setBlockIfAir(EditSession session, Vector position, BlockStateHolder block) throws MaxChangedBlocksException {
+ private static boolean setBlockIfAir(EditSession session, BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException {
return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block);
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java
index 7c821b0f3..4f303acd6 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java
@@ -21,7 +21,7 @@ package com.sk89q.worldedit.util.collection;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.LocatedBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@@ -51,7 +51,7 @@ public class LocatedBlockList implements Iterable {
list.add(setBlockCall);
}
- public void add(Vector location, BlockStateHolder block) {
+ public void add(BlockVector3 location, BlockStateHolder block) {
add(new LocatedBlock(location, block));
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/GsonUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/GsonUtil.java
index 8d6d4dd2b..5d73c68ea 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/GsonUtil.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/GsonUtil.java
@@ -21,7 +21,7 @@ package com.sk89q.worldedit.util.gson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
/**
* Utility methods for Google's GSON library.
@@ -38,7 +38,7 @@ public final class GsonUtil {
*/
public static GsonBuilder createBuilder() {
GsonBuilder gsonBuilder = new GsonBuilder();
- gsonBuilder.registerTypeAdapter(Vector.class, new VectorAdapter());
+ gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
return gsonBuilder;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/VectorAdapter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/VectorAdapter.java
index a1e876dfe..4524e64f9 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/VectorAdapter.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/VectorAdapter.java
@@ -24,17 +24,17 @@ import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
import java.lang.reflect.Type;
/**
* Deserializes {@code Vector}s for GSON.
*/
-public class VectorAdapter implements JsonDeserializer {
+public class VectorAdapter implements JsonDeserializer {
@Override
- public Vector deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
+ public Vector3 deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonArray jsonArray = json.getAsJsonArray();
if (jsonArray.size() != 3) {
throw new JsonParseException("Expected array of 3 length for Vector");
@@ -44,6 +44,6 @@ public class VectorAdapter implements JsonDeserializer {
double y = jsonArray.get(1).getAsDouble();
double z = jsonArray.get(2).getAsDouble();
- return new Vector(x, y, z);
+ return new Vector3(x, y, z);
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java
index 4007125f6..124187fdd 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java
@@ -19,8 +19,6 @@
package com.sk89q.worldedit.world;
-import com.sk89q.worldedit.BlockVector2D;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
@@ -28,6 +26,9 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
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.util.Direction;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@@ -46,12 +47,12 @@ public abstract class AbstractWorld implements World {
private int taskId = -1;
@Override
- public boolean useItem(Vector position, BaseItem item, Direction face) {
+ public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
return false;
}
@Override
- public final boolean setBlock(Vector pt, BlockStateHolder block) throws WorldEditException {
+ public final boolean setBlock(BlockVector3 pt, BlockStateHolder block) throws WorldEditException {
return setBlock(pt, block, true);
}
@@ -66,31 +67,31 @@ public abstract class AbstractWorld implements World {
}
@Override
- public void dropItem(Vector pt, BaseItemStack item, int times) {
+ public void dropItem(Vector3 pt, BaseItemStack item, int times) {
for (int i = 0; i < times; ++i) {
dropItem(pt, item);
}
}
@Override
- public void checkLoadedChunk(Vector pt) {
+ public void checkLoadedChunk(BlockVector3 pt) {
}
@Override
- public void fixAfterFastMode(Iterable chunks) {
+ public void fixAfterFastMode(Iterable chunks) {
}
@Override
- public void fixLighting(Iterable chunks) {
+ public void fixLighting(Iterable chunks) {
}
@Override
- public boolean playEffect(Vector position, int type, int data) {
+ public boolean playEffect(Vector3 position, int type, int data) {
return false;
}
@Override
- public boolean queueBlockBreakEffect(Platform server, Vector position, BlockType blockType, double priority) {
+ public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) {
if (taskId == -1) {
taskId = server.schedule(0, 1, () -> {
int max = Math.max(1, Math.min(30, effectQueue.size() / 3));
@@ -106,19 +107,19 @@ public abstract class AbstractWorld implements World {
return false;
}
- effectQueue.offer(new QueuedEffect(position, blockType, priority));
+ effectQueue.offer(new QueuedEffect(position.toVector3(), blockType, priority));
return true;
}
@Override
- public Vector getMinimumPoint() {
- return new Vector(-30000000, 0, -30000000);
+ public BlockVector3 getMinimumPoint() {
+ return new BlockVector3(-30000000, 0, -30000000);
}
@Override
- public Vector getMaximumPoint() {
- return new Vector(30000000, 255, 30000000);
+ public BlockVector3 getMaximumPoint() {
+ return new BlockVector3(30000000, 255, 30000000);
}
@Override
@@ -127,11 +128,11 @@ public abstract class AbstractWorld implements World {
}
private class QueuedEffect implements Comparable {
- private final Vector position;
+ private final Vector3 position;
private final BlockType blockType;
private final double priority;
- private QueuedEffect(Vector position, BlockType blockType, double priority) {
+ private QueuedEffect(Vector3 position, BlockType blockType, double priority) {
this.position = position;
this.blockType = blockType;
this.priority = priority;
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 4542d19e2..43ee77e39 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
@@ -21,12 +21,13 @@ package com.sk89q.worldedit.world;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
+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.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
@@ -59,36 +60,36 @@ public class NullWorld extends AbstractWorld {
}
@Override
- public boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
+ public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
return false;
}
@Override
- public int getBlockLightLevel(Vector position) {
+ public int getBlockLightLevel(BlockVector3 position) {
return 0;
}
@Override
- public boolean clearContainerBlockContents(Vector position) {
+ public boolean clearContainerBlockContents(BlockVector3 position) {
return false;
}
@Override
- public BaseBiome getBiome(Vector2D position) {
+ public BaseBiome getBiome(BlockVector2 position) {
return null;
}
@Override
- public boolean setBiome(Vector2D position, BaseBiome biome) {
+ public boolean setBiome(BlockVector2 position, BaseBiome biome) {
return false;
}
@Override
- public void dropItem(Vector position, BaseItemStack item) {
+ public void dropItem(Vector3 position, BaseItemStack item) {
}
@Override
- public void simulateBlockMine(Vector position) {
+ public void simulateBlockMine(BlockVector3 position) {
}
@Override
@@ -97,7 +98,7 @@ public class NullWorld extends AbstractWorld {
}
@Override
- public boolean generateTree(TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException {
+ public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
return false;
}
@@ -120,12 +121,12 @@ public class NullWorld extends AbstractWorld {
}
@Override
- public BlockState getBlock(Vector position) {
+ public BlockState getBlock(BlockVector3 position) {
return BlockTypes.AIR.getDefaultState();
}
@Override
- public BaseBlock getFullBlock(Vector position) {
+ public BaseBlock getFullBlock(BlockVector3 position) {
return getBlock(position).toBaseBlock();
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java
index ed0234e6c..3e7bbf88c 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java
@@ -19,16 +19,17 @@
package com.sk89q.worldedit.world;
-import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.TreeGenerator;
@@ -72,10 +73,10 @@ public interface World extends Extent {
* @param face The face
* @return Whether it succeeded
*/
- boolean useItem(Vector position, BaseItem item, Direction face);
+ boolean useItem(BlockVector3 position, BaseItem item, Direction face);
/**
- * Similar to {@link Extent#setBlock(Vector, BlockStateHolder)} but a
+ * Similar to {@link Extent#setBlock(BlockVector3, BlockStateHolder)} but a
* {@code notifyAndLight} parameter indicates whether adjacent blocks
* should be notified that changes have been made and lighting operations
* should be executed.
@@ -92,7 +93,7 @@ public interface World extends Extent {
* @param notifyAndLight true to to notify and light
* @return true if the block was successfully set (return value may not be accurate)
*/
- boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException;
+ boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException;
/**
* Get the light level at the given block.
@@ -100,7 +101,7 @@ public interface World extends Extent {
* @param position the position
* @return the light level (0-15)
*/
- int getBlockLightLevel(Vector position);
+ int getBlockLightLevel(BlockVector3 position);
/**
* Clear a chest's contents.
@@ -108,7 +109,7 @@ public interface World extends Extent {
* @param position the position
* @return true if the container was cleared
*/
- boolean clearContainerBlockContents(Vector position);
+ boolean clearContainerBlockContents(BlockVector3 position);
/**
* Drop an item at the given position.
@@ -117,23 +118,23 @@ public interface World extends Extent {
* @param item the item to drop
* @param count the number of individual stacks to drop (number of item entities)
*/
- void dropItem(Vector position, BaseItemStack item, int count);
+ void dropItem(Vector3 position, BaseItemStack item, int count);
/**
* Drop one stack of the item at the given position.
*
* @param position the position
* @param item the item to drop
- * @see #dropItem(Vector, BaseItemStack, int) shortcut method to specify the number of stacks
+ * @see #dropItem(Vector3, BaseItemStack, int) shortcut method to specify the number of stacks
*/
- void dropItem(Vector position, BaseItemStack item);
+ void dropItem(Vector3 position, BaseItemStack item);
/**
* Simulate a block being mined at the given position.
*
* @param position the position
*/
- void simulateBlockMine(Vector position);
+ void simulateBlockMine(BlockVector3 position);
/**
* Regenerate an area.
@@ -153,19 +154,19 @@ public interface World extends Extent {
* @return true if generation was successful
* @throws MaxChangedBlocksException thrown if too many blocks were changed
*/
- boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException;
+ boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException;
/**
* Load the chunk at the given position if it isn't loaded.
*
* @param position the position
*/
- void checkLoadedChunk(Vector position);
+ void checkLoadedChunk(BlockVector3 position);
/**
* Fix the given chunks after fast mode was used.
*
- * Fast mode makes calls to {@link #setBlock(Vector, BlockStateHolder, boolean)}
+ *
Fast mode makes calls to {@link #setBlock(BlockVector3, BlockStateHolder, boolean)}
* with {@code false} for the {@code notifyAndLight} parameter, which
* may causes lighting errors to accumulate. Use of this method, if
* it is implemented by the underlying world, corrects those lighting
@@ -173,14 +174,14 @@ public interface World extends Extent {
*
* @param chunks a list of chunk coordinates to fix
*/
- void fixAfterFastMode(Iterable chunks);
+ void fixAfterFastMode(Iterable chunks);
/**
* Relight the given chunks if possible.
*
* @param chunks a list of chunk coordinates to fix
*/
- void fixLighting(Iterable chunks);
+ void fixLighting(Iterable chunks);
/**
* Play the given effect.
@@ -190,7 +191,7 @@ public interface World extends Extent {
* @param data the effect data
* @return true if the effect was played
*/
- boolean playEffect(Vector position, int type, int data);
+ boolean playEffect(Vector3 position, int type, int data);
/**
* Queue a block break effect.
@@ -201,7 +202,7 @@ public interface World extends Extent {
* @param priority the priority
* @return true if the effect was played
*/
- boolean queueBlockBreakEffect(Platform server, Vector position, BlockType blockType, double priority);
+ boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority);
/**
* Gets the weather type of the world.
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 6b1265854..65f76cd41 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
@@ -26,9 +26,8 @@ import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.Tag;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState;
@@ -52,7 +51,7 @@ public class AnvilChunk implements Chunk {
private int rootX;
private int rootZ;
- private Map> tileEntities;
+ private Map> tileEntities;
/**
* Construct the chunk with a compound tag.
@@ -119,10 +118,10 @@ public class AnvilChunk implements Chunk {
}
}
- private int getBlockID(Vector position) throws DataException {
- int x = position.getBlockX() - rootX * 16;
- int y = position.getBlockY();
- int z = position.getBlockZ() - rootZ * 16;
+ private int getBlockID(BlockVector3 position) throws DataException {
+ int x = position.getX() - rootX * 16;
+ int y = position.getY();
+ int z = position.getZ() - rootZ * 16;
int section = y >> 4;
if (section < 0 || section >= blocks.length) {
@@ -152,10 +151,10 @@ public class AnvilChunk implements Chunk {
}
}
- private int getBlockData(Vector position) throws DataException {
- int x = position.getBlockX() - rootX * 16;
- int y = position.getBlockY();
- int z = position.getBlockZ() - rootZ * 16;
+ private int getBlockData(BlockVector3 position) throws DataException {
+ int x = position.getX() - rootX * 16;
+ int y = position.getY();
+ int z = position.getZ() - rootZ * 16;
int section = y >> 4;
int yIndex = y & 0x0F;
@@ -225,7 +224,7 @@ public class AnvilChunk implements Chunk {
values.put(entry.getKey(), entry.getValue());
}
- BlockVector vec = new BlockVector(x, y, z);
+ BlockVector3 vec = new BlockVector3(x, y, z);
tileEntities.put(vec, values);
}
}
@@ -240,12 +239,12 @@ public class AnvilChunk implements Chunk {
* @throws DataException thrown if there is a data error
*/
@Nullable
- private CompoundTag getBlockTileEntity(Vector position) throws DataException {
+ private CompoundTag getBlockTileEntity(BlockVector3 position) throws DataException {
if (tileEntities == null) {
populateTileEntities();
}
- Map values = tileEntities.get(new BlockVector(position));
+ Map values = tileEntities.get(position);
if (values == null) {
return null;
}
@@ -254,7 +253,7 @@ public class AnvilChunk implements Chunk {
}
@Override
- public BlockStateHolder getBlock(Vector position) throws DataException {
+ public BlockStateHolder getBlock(BlockVector3 position) throws DataException {
int id = getBlockID(position);
int data = getBlockData(position);
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 025390c66..cda59cbda 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,8 +26,7 @@ import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.LongArrayTag;
import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.Tag;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BlockState;
@@ -52,7 +51,7 @@ public class AnvilChunk13 implements Chunk {
private int rootX;
private int rootZ;
- private Map> tileEntities;
+ private Map> tileEntities;
/**
* Construct the chunk with a compound tag.
@@ -201,7 +200,7 @@ public class AnvilChunk13 implements Chunk {
values.put(entry.getKey(), entry.getValue());
}
- BlockVector vec = new BlockVector(x, y, z);
+ BlockVector3 vec = new BlockVector3(x, y, z);
tileEntities.put(vec, values);
}
}
@@ -216,12 +215,12 @@ public class AnvilChunk13 implements Chunk {
* @throws DataException thrown if there is a data error
*/
@Nullable
- private CompoundTag getBlockTileEntity(Vector position) throws DataException {
+ private CompoundTag getBlockTileEntity(BlockVector3 position) throws DataException {
if (tileEntities == null) {
populateTileEntities();
}
- Map values = tileEntities.get(new BlockVector(position));
+ Map values = tileEntities.get(position);
if (values == null) {
return null;
}
@@ -230,10 +229,10 @@ public class AnvilChunk13 implements Chunk {
}
@Override
- public BlockStateHolder getBlock(Vector position) throws DataException {
- int x = position.getBlockX() - rootX * 16;
- int y = position.getBlockY();
- int z = position.getBlockZ() - rootZ * 16;
+ public BlockStateHolder getBlock(BlockVector3 position) throws DataException {
+ int x = position.getX() - rootX * 16;
+ int y = position.getY();
+ int z = position.getZ() - rootZ * 16;
int section = y >> 4;
int yIndex = y & 0x0F;
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 2f261570e..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
@@ -19,7 +19,7 @@
package com.sk89q.worldedit.world.chunk;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@@ -35,6 +35,6 @@ public interface Chunk {
* @return block the block
* @throws DataException thrown on data error
*/
- BlockStateHolder getBlock(Vector position) throws DataException;
+ BlockStateHolder getBlock(BlockVector3 position) throws DataException;
}
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 c6f983ced..4a3336e86 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
@@ -25,9 +25,8 @@ import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.Tag;
-import com.sk89q.worldedit.BlockVector;
-import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState;
@@ -51,7 +50,7 @@ public class OldChunk implements Chunk {
private int rootX;
private int rootZ;
- private Map> tileEntities;
+ private Map> tileEntities;
/**
* Construct the chunk with a compound tag.
@@ -127,7 +126,7 @@ public class OldChunk implements Chunk {
values.put(entry.getKey(), entry.getValue());
}
- BlockVector vec = new BlockVector(x, y, z);
+ BlockVector3 vec = new BlockVector3(x, y, z);
tileEntities.put(vec, values);
}
}
@@ -141,12 +140,12 @@ public class OldChunk implements Chunk {
* @return a tag
* @throws DataException
*/
- private CompoundTag getBlockTileEntity(Vector position) throws DataException {
+ private CompoundTag getBlockTileEntity(BlockVector3 position) throws DataException {
if (tileEntities == null) {
populateTileEntities();
}
- Map values = tileEntities.get(new BlockVector(position));
+ Map values = tileEntities.get(position);
if (values == null) {
return null;
}
@@ -154,13 +153,13 @@ public class OldChunk implements Chunk {
}
@Override
- public BlockStateHolder getBlock(Vector position) throws DataException {
- if(position.getBlockY() >= 128) BlockTypes.VOID_AIR.getDefaultState().toBaseBlock();
+ public BlockStateHolder getBlock(BlockVector3 position) throws DataException {
+ if(position.getY() >= 128) return BlockTypes.VOID_AIR.getDefaultState().toBaseBlock();
int id, dataVal;
- int x = position.getBlockX() - rootX * 16;
- int y = position.getBlockY();
- int z = position.getBlockZ() - rootZ * 16;
+ int x = position.getX() - rootX * 16;
+ int y = position.getY();
+ int z = position.getZ() - rootZ * 16;
int index = y + (z * 128 + (x * 128 * 16));
try {
id = blocks[index];
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 afe73c368..b98238dc0 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
@@ -23,7 +23,7 @@ import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import java.io.IOException;
@@ -73,7 +73,7 @@ public class BundledBlockData {
*/
private void loadFromResource() throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
- gsonBuilder.registerTypeAdapter(Vector.class, new VectorAdapter());
+ gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
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/BundledItemData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java
index 00cafb244..2867b2e56 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java
@@ -23,7 +23,7 @@ import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
-import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import java.io.IOException;
@@ -73,7 +73,7 @@ public class BundledItemData {
*/
private void loadFromResource() throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
- gsonBuilder.registerTypeAdapter(Vector.class, new VectorAdapter());
+ gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
Gson gson = gsonBuilder.create();
URL url = BundledItemData.class.getResource("items.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 78bc48131..5ea6044f3 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,9 +25,9 @@ import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
-import com.sk89q.worldedit.Vector;
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;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.item.ItemType;
@@ -71,7 +71,7 @@ public class LegacyMapper {
*/
private void loadFromResource() throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
- gsonBuilder.registerTypeAdapter(Vector.class, new VectorAdapter());
+ gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
Gson gson = gsonBuilder.disableHtmlEscaping().create();
URL url = LegacyMapper.class.getResource("legacy.json");
if (url == null) {
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 a7ef7ca9d..5b6691b85 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
@@ -19,12 +19,10 @@
package com.sk89q.worldedit.world.snapshot;
-import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.Vector2D;
-import com.sk89q.worldedit.world.block.BaseBlock;
+import com.sk89q.worldedit.math.BlockVector2;
+import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.DataException;
@@ -43,11 +41,11 @@ import java.util.Map;
*/
public class SnapshotRestore {
- private final Map> neededChunks = new LinkedHashMap<>();
+ private final Map> neededChunks = new LinkedHashMap<>();
private final ChunkStore chunkStore;
private final EditSession editSession;
- private ArrayList missingChunks;
- private ArrayList errorChunks;
+ private ArrayList