3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-07-24 11:08:03 +02:00

Removed Point/BlockPoint to Vector/BlockVector.

Dieser Commit ist enthalten in:
sk89q 2010-10-12 18:03:56 -07:00
Ursprung c039e8e77d
Commit 68dcce31f8
10 geänderte Dateien mit 158 neuen und 158 gelöschten Zeilen

Datei anzeigen

@ -30,9 +30,9 @@ import com.sk89q.worldedit.*;
*/
public class CuboidClipboard {
private int[][][] data;
private Point min;
private Point max;
private Point origin;
private Vector min;
private Vector max;
private Vector origin;
/**
* Constructs the region instance. The minimum and maximum points must be
@ -42,7 +42,7 @@ public class CuboidClipboard {
* @param max
* @param origin
*/
public CuboidClipboard(Point min, Point max, Point origin) {
public CuboidClipboard(Vector min, Vector max, Vector origin) {
this.min = min;
this.max = max;
this.origin = origin;
@ -102,7 +102,7 @@ public class CuboidClipboard {
* @param noAir True to not paste air
* @throws MaxChangedBlocksException
*/
public void paste(EditSession editSession, Point newOrigin, boolean noAir)
public void paste(EditSession editSession, Vector newOrigin, boolean noAir)
throws MaxChangedBlocksException {
int offsetX = (int)(min.getX() - origin.getX() + newOrigin.getX());
int offsetY = (int)(min.getY() - origin.getY() + newOrigin.getY());
@ -168,7 +168,7 @@ public class CuboidClipboard {
}
if (moveOrigin) {
min = new Point((int)offsetX + xm * count,
min = new Vector((int)offsetX + xm * count,
(int)offsetY + ym * count,
(int)offsetZ + zm * count);
}
@ -238,7 +238,7 @@ public class CuboidClipboard {
* @throws SchematicException
* @throws IOException
*/
public static CuboidClipboard loadSchematic(String path, Point origin)
public static CuboidClipboard loadSchematic(String path, Vector origin)
throws SchematicException, IOException {
FileInputStream stream = new FileInputStream(path);
NBTInputStream nbtStream = new NBTInputStream(stream);
@ -259,8 +259,8 @@ public class CuboidClipboard {
}
byte[] blocks = (byte[])getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
Point min = origin;
Point max = new Point(
Vector min = origin;
Vector max = new Vector(
origin.getX() + xs - 1,
origin.getY() + ys - 1,
origin.getZ() + zs - 1

Datei anzeigen

@ -37,15 +37,15 @@ public class EditSession {
/**
* Stores the original blocks before modification.
*/
private HashMap<BlockPoint,Integer> original = new HashMap<BlockPoint,Integer>();
private HashMap<BlockVector,Integer> original = new HashMap<BlockVector,Integer>();
/**
* Stores the current blocks.
*/
private HashMap<BlockPoint,Integer> current = new HashMap<BlockPoint,Integer>();
private HashMap<BlockVector,Integer> current = new HashMap<BlockVector,Integer>();
/**
* Queue.
*/
private HashMap<BlockPoint,Integer> queue = new HashMap<BlockPoint,Integer>();
private HashMap<BlockVector,Integer> queue = new HashMap<BlockVector,Integer>();
/**
* The maximum number of blocks to change at a time. If this number is
* exceeded, a MaxChangedBlocksException exception will be
@ -98,7 +98,7 @@ public class EditSession {
* @param blockType
* @return Whether the block changed
*/
private boolean rawSetBlock(Point pt, int blockType) {
private boolean rawSetBlock(Vector pt, int blockType) {
return etc.getMCServer().e.d(pt.getBlockX(), pt.getBlockY(),
pt.getBlockZ(), blockType);
}
@ -116,7 +116,7 @@ public class EditSession {
*/
public boolean setBlock(int x, int y, int z, int blockType)
throws MaxChangedBlocksException {
return setBlock(new Point(x, y, z), blockType);
return setBlock(new Vector(x, y, z), blockType);
}
/**
@ -128,7 +128,7 @@ public class EditSession {
* @param blockType
* @return Whether the block changed -- not entirely dependable
*/
public boolean setBlock(Point pt, int blockType)
public boolean setBlock(Vector pt, int blockType)
throws MaxChangedBlocksException {
if (!original.containsKey(pt)) {
original.put(pt.toBlockPoint(), getBlock(pt));
@ -150,7 +150,7 @@ public class EditSession {
* @param blockType
* @return
*/
private boolean smartSetBlock(Point pt, int blockType) {
private boolean smartSetBlock(Vector pt, int blockType) {
if (queued) {
if (blockType != 0 && queuedBlocks.contains(blockType)
&& rawGetBlock(pt.add(0, -1, 0)) == 0) {
@ -171,7 +171,7 @@ public class EditSession {
* @param pt
* @return Block type
*/
public int getBlock(Point pt) {
public int getBlock(Vector pt) {
// In the case of the queue, the block may have not actually been
// changed yet
if (queued) {
@ -191,7 +191,7 @@ public class EditSession {
* @return Block type
*/
public int getBlock(int x, int y, int z) {
return getBlock(new Point(x, y, z));
return getBlock(new Vector(x, y, z));
}
/**
@ -200,7 +200,7 @@ public class EditSession {
* @param pt
* @return Block type
*/
public int rawGetBlock(Point pt) {
public int rawGetBlock(Vector pt) {
return etc.getMCServer().e.a(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
}
@ -208,8 +208,8 @@ public class EditSession {
* Restores all blocks to their initial state.
*/
public void undo() {
for (Map.Entry<BlockPoint,Integer> entry : original.entrySet()) {
BlockPoint pt = (BlockPoint)entry.getKey();
for (Map.Entry<BlockVector,Integer> entry : original.entrySet()) {
BlockVector pt = (BlockVector)entry.getKey();
smartSetBlock(pt, (int)entry.getValue());
}
flushQueue();
@ -219,8 +219,8 @@ public class EditSession {
* Sets to new state.
*/
public void redo() {
for (Map.Entry<BlockPoint,Integer> entry : current.entrySet()) {
BlockPoint pt = (BlockPoint)entry.getKey();
for (Map.Entry<BlockVector,Integer> entry : current.entrySet()) {
BlockVector pt = (BlockVector)entry.getKey();
smartSetBlock(pt, (int)entry.getValue());
}
flushQueue();
@ -288,8 +288,8 @@ public class EditSession {
public void flushQueue() {
if (!queued) { return; }
for (Map.Entry<BlockPoint,Integer> entry : queue.entrySet()) {
BlockPoint pt = (BlockPoint)entry.getKey();
for (Map.Entry<BlockVector,Integer> entry : queue.entrySet()) {
BlockVector pt = (BlockVector)entry.getKey();
rawSetBlock(pt, (int)entry.getValue());
}
}
@ -305,7 +305,7 @@ public class EditSession {
* @param depth
* @return number of blocks affected
*/
public int fillXZ(int x, int z, Point origin, int blockType, int radius, int depth)
public int fillXZ(int x, int z, Vector origin, int blockType, int radius, int depth)
throws MaxChangedBlocksException {
double dist = Math.sqrt(Math.pow(origin.getX() - x, 2) + Math.pow(origin.getZ() - z, 2));
int minY = origin.getBlockY() - depth + 1;
@ -315,7 +315,7 @@ public class EditSession {
return 0;
}
if (getBlock(new Point(x, origin.getY(), z)) == 0) {
if (getBlock(new Vector(x, origin.getY(), z)) == 0) {
affected = fillY(x, (int)origin.getY(), z, blockType, minY);
} else {
return 0;
@ -345,7 +345,7 @@ public class EditSession {
int affected = 0;
for (int y = cy; y >= minY; y--) {
Point pt = new Point(x, y, z);
Vector pt = new Vector(x, y, z);
if (getBlock(pt) == 0) {
setBlock(pt, blockType);
@ -366,7 +366,7 @@ public class EditSession {
* @param height
* @return number of blocks affected
*/
public int removeAbove(Point pos, int size, int height) throws
public int removeAbove(Vector pos, int size, int height) throws
MaxChangedBlocksException {
int maxY = Math.min(127, pos.getBlockY() + height - 1);
size--;
@ -375,7 +375,7 @@ public class EditSession {
for (int x = (int)pos.getX() - size; x <= (int)pos.getX() + size; x++) {
for (int z = (int)pos.getZ() - size; z <= (int)pos.getZ() + size; z++) {
for (int y = (int)pos.getY(); y <= maxY; y++) {
Point pt = new Point(x, y, z);
Vector pt = new Vector(x, y, z);
if (getBlock(pt) != 0) {
setBlock(pt, 0);
@ -396,7 +396,7 @@ public class EditSession {
* @param height
* @return number of blocks affected
*/
public int removeBelow(Point pos, int size, int height) throws
public int removeBelow(Vector pos, int size, int height) throws
MaxChangedBlocksException {
int minY = Math.max(0, pos.getBlockY() - height);
size--;
@ -405,7 +405,7 @@ public class EditSession {
for (int x = (int)pos.getX() - size; x <= (int)pos.getX() + size; x++) {
for (int z = (int)pos.getZ() - size; z <= (int)pos.getZ() + size; z++) {
for (int y = (int)pos.getY(); y >= minY; y--) {
Point pt = new Point(x, y, z);
Vector pt = new Vector(x, y, z);
if (getBlock(pt) != 0) {
setBlock(pt, 0);
@ -432,13 +432,13 @@ public class EditSession {
if (region instanceof CuboidRegion) {
// Doing this for speed
Point min = region.getMinimumPoint();
Point max = region.getMaximumPoint();
Vector min = region.getMinimumPoint();
Vector max = region.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++) {
Point pt = new Point(x, y, z);
Vector pt = new Vector(x, y, z);
if (setBlock(pt, blockType)) {
affected++;
@ -447,7 +447,7 @@ public class EditSession {
}
}
} else {
for (Point pt : region) {
for (Vector pt : region) {
if (setBlock(pt, blockType)) {
affected++;
}
@ -472,13 +472,13 @@ public class EditSession {
if (region instanceof CuboidRegion) {
// Doing this for speed
Point min = region.getMinimumPoint();
Point max = region.getMaximumPoint();
Vector min = region.getMinimumPoint();
Vector max = region.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++) {
Point pt = new Point(x, y, z);
Vector pt = new Vector(x, y, z);
int curBlockType = getBlock(pt);
if (fromBlockType == -1 && curBlockType != 0 ||
@ -491,7 +491,7 @@ public class EditSession {
}
}
} else {
for (Point pt : region) {
for (Vector pt : region) {
int curBlockType = getBlock(pt);
if (fromBlockType == -1 && curBlockType != 0 ||
@ -518,8 +518,8 @@ public class EditSession {
throws MaxChangedBlocksException {
int affected = 0;
Point min = region.getMinimumPoint();
Point max = region.getMaximumPoint();
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
@ -556,8 +556,8 @@ public class EditSession {
*/
public int overlayCuboidBlocks(Region region, int blockType)
throws MaxChangedBlocksException {
Point min = region.getMinimumPoint();
Point max = region.getMaximumPoint();
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
int upperY = Math.min(127, max.getBlockY() + 1);
int lowerY = Math.max(0, min.getBlockY()- 1);
@ -597,8 +597,8 @@ public class EditSession {
throws MaxChangedBlocksException {
int affected = 0;
Point min = region.getMinimumPoint();
Point max = region.getMaximumPoint();
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
int xs = region.getWidth();
int ys = region.getHeight();
int zs = region.getLength();
@ -606,7 +606,7 @@ public class EditSession {
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
int blockType = getBlock(new Point(x, y, z));
int blockType = getBlock(new Vector(x, y, z));
if (blockType != 0 || copyAir) {
for (int i = 1; i <= count; i++) {
@ -631,22 +631,22 @@ public class EditSession {
* @return number of blocks affected
* @throws MaxChangedBlocksException
*/
public int drainArea(Point pos, int radius) throws MaxChangedBlocksException {
public int drainArea(Vector pos, int radius) throws MaxChangedBlocksException {
int affected = 0;
HashSet<BlockPoint> visited = new HashSet<BlockPoint>();
Stack<BlockPoint> queue = new Stack<BlockPoint>();
HashSet<BlockVector> visited = new HashSet<BlockVector>();
Stack<BlockVector> queue = new Stack<BlockVector>();
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
queue.push(new BlockPoint(x, y, z));
queue.push(new BlockVector(x, y, z));
}
}
}
while (!queue.empty()) {
BlockPoint cur = queue.pop();
BlockVector cur = queue.pop();
int type = getBlock(cur);
@ -670,7 +670,7 @@ public class EditSession {
for (int x = cur.getBlockX() - 1; x <= cur.getBlockX() + 1; x++) {
for (int z = cur.getBlockZ() - 1; z <= cur.getBlockZ() + 1; z++) {
for (int y = cur.getBlockY() - 1; y <= cur.getBlockY() + 1; y++) {
BlockPoint newPos = new BlockPoint(x, y, z);
BlockVector newPos = new BlockVector(x, y, z);
if (!cur.equals(newPos)) {
queue.push(newPos);

Datei anzeigen

@ -269,7 +269,7 @@ public class WorldEdit {
if (session.getClipboard() == null) {
player.printError("Nothing is in your clipboard.");
} else {
Point pos = player.getBlockIn();
Vector pos = player.getBlockIn();
session.getClipboard().paste(editSession, pos,
split[0].equalsIgnoreCase("/editpaste"));
player.findFreePosition();
@ -285,7 +285,7 @@ public class WorldEdit {
int radius = Math.max(1, Integer.parseInt(split[2]));
int depth = split.length > 3 ? Math.max(1, Integer.parseInt(split[3])) : 1;
Point pos = player.getBlockIn();
Vector pos = player.getBlockIn();
int affected = editSession.fillXZ((int)pos.getX(), (int)pos.getZ(),
pos, blockType, radius, depth);
player.print(affected + " block(s) have been created.");
@ -326,7 +326,7 @@ public class WorldEdit {
if (!filePath.substring(0, dirPath.length()).equals(dirPath)) {
player.printError("Schematic could not read or it does not exist.");
} else {
Point origin = player.getBlockIn();
Vector origin = player.getBlockIn();
session.setClipboard(CuboidClipboard.loadSchematic(filePath, origin));
logger.log(Level.INFO, player.getName() + " loaded " + filePath);
player.print(filename + " loaded.");
@ -447,9 +447,9 @@ public class WorldEdit {
} else if (split[0].equalsIgnoreCase("/editcopy")) {
checkArgs(split, 0, 0, split[0]);
Region region = session.getRegion();
Point min = region.getMinimumPoint();
Point max = region.getMaximumPoint();
Point pos = player.getBlockIn();
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
Vector pos = player.getBlockIn();
CuboidClipboard clipboard = new CuboidClipboard(min, max, pos);
clipboard.copy(editSession);

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import com.sk89q.worldedit.Point;
import com.sk89q.worldedit.Vector;
/**
*
@ -49,8 +49,8 @@ public class WorldEditPlayer {
*
* @return point
*/
public Point getBlockOn() {
return Point.toBlockPoint(player.getX(), player.getY() - 1, player.getZ());
public Vector getBlockOn() {
return Vector.toBlockPoint(player.getX(), player.getY() - 1, player.getZ());
}
/**
@ -58,8 +58,8 @@ public class WorldEditPlayer {
*
* @return point
*/
public Point getBlockIn() {
return Point.toBlockPoint(player.getX(), player.getY(), player.getZ());
public Vector getBlockIn() {
return Vector.toBlockPoint(player.getX(), player.getY(), player.getZ());
}
/**
@ -67,8 +67,8 @@ public class WorldEditPlayer {
*
* @return point
*/
public Point getPosition() {
return new Point(player.getX(), player.getY(), player.getZ());
public Vector getPosition() {
return new Vector(player.getX(), player.getY(), player.getZ());
}
/**
@ -123,7 +123,7 @@ public class WorldEditPlayer {
* @param pitch
* @param yaw
*/
public void setPosition(Point pos, float pitch, float yaw) {
public void setPosition(Vector pos, float pitch, float yaw) {
Location loc = new Location();
loc.x = pos.getX();
loc.y = pos.getY();

Datei anzeigen

@ -68,7 +68,7 @@ public class WorldEditSMListener extends PluginListener {
WorldEditSession session = worldEdit.getSession(player);
if (session.isToolControlEnabled()) {
Point cur = Point.toBlockPoint(blockClicked.getX(),
Vector cur = Vector.toBlockPoint(blockClicked.getX(),
blockClicked.getY(),
blockClicked.getZ());
@ -99,7 +99,7 @@ public class WorldEditSMListener extends PluginListener {
WorldEditSession session = worldEdit.getSession(player);
if (session.isToolControlEnabled()) {
Point cur = Point.toBlockPoint(blockClicked.getX(),
Vector cur = Vector.toBlockPoint(blockClicked.getX(),
blockClicked.getY(),
blockClicked.getZ());

Datei anzeigen

@ -26,12 +26,12 @@ import java.util.LinkedList;
*/
public class WorldEditSession {
public static final int MAX_HISTORY_SIZE = 15;
private Point pos1, pos2;
private Vector pos1, pos2;
private LinkedList<EditSession> history = new LinkedList<EditSession>();
private int historyPointer = 0;
private CuboidClipboard clipboard;
private boolean toolControl = true;
private Point lastToolPos1;
private Vector lastToolPos1;
private long lastToolClick = 0;
private int maxBlocksChanged = -1;
@ -120,7 +120,7 @@ public class WorldEditSession {
* @return position 1
* @throws IncompleteRegionException
*/
public Point getPos1() throws IncompleteRegionException {
public Vector getPos1() throws IncompleteRegionException {
checkPos1();
return pos1;
}
@ -130,7 +130,7 @@ public class WorldEditSession {
*
* @param pt
*/
public void setPos1(Point pt) {
public void setPos1(Vector pt) {
pos1 = pt;
}
@ -140,7 +140,7 @@ public class WorldEditSession {
* @return position 2
* @throws IncompleteRegionException
*/
public Point getPos2() throws IncompleteRegionException {
public Vector getPos2() throws IncompleteRegionException {
checkPos2();
return pos2;
}
@ -150,7 +150,7 @@ public class WorldEditSession {
*
* @param pt
*/
public void setPos2(Point pt) {
public void setPos2(Vector pt) {
pos2 = pt;
}
@ -206,14 +206,14 @@ public class WorldEditSession {
/**
* @return the lastToolPos1
*/
public Point getLastToolPos1() {
public Vector getLastToolPos1() {
return lastToolPos1;
}
/**
* @param lastToolPos1 the lastToolPos1 to set
*/
public void setLastToolPos1(Point lastToolPos1) {
public void setLastToolPos1(Vector lastToolPos1) {
this.lastToolPos1 = lastToolPos1;
}

Datei anzeigen

@ -20,44 +20,44 @@
package com.sk89q.worldedit;
/**
* Extension of Point that supports being compared as ints (for accuracy).
* Extension of Vector that supports being compared as ints (for accuracy).
*
* @author sk89q
*/
public class BlockPoint extends Point {
public class BlockVector extends Vector {
/**
* Construct the Point object.
* Construct the Vector object.
*
* @param pt
*/
public BlockPoint(Point pt) {
public BlockVector(Vector pt) {
super(pt);
}
/**
* Construct the Point object.
* Construct the Vector object.
*
* @param pt
*/
public BlockPoint(int x, int y, int z) {
public BlockVector(int x, int y, int z) {
super(x, y, z);
}
/**
* Construct the Point object.
* Construct the Vector object.
*
* @param pt
*/
public BlockPoint(float x, float y, float z) {
public BlockVector(float x, float y, float z) {
super(x, y, z);
}
/**
* Construct the Point object.
* Construct the Vector object.
*
* @param pt
*/
public BlockPoint(double x, double y, double z) {
public BlockVector(double x, double y, double z) {
super(x, y, z);
}
@ -69,10 +69,10 @@ public class BlockPoint extends Point {
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Point)) {
if (!(obj instanceof Vector)) {
return false;
}
Point other = (Point)obj;
Vector other = (Vector)obj;
return (int)other.x == (int)this.x && (int)other.y == (int)this.y
&& (int)other.z == (int)this.z;

Datei anzeigen

@ -29,11 +29,11 @@ public class CuboidRegion implements Region {
/**
* Store the first point.
*/
private Point pos1;
private Vector pos1;
/**
* Store the second point.
*/
private Point pos2;
private Vector pos2;
/**
* Construct a new instance of this cuboid region.
@ -41,7 +41,7 @@ public class CuboidRegion implements Region {
* @param pos1
* @param pos2
*/
public CuboidRegion(Point pos1, Point pos2) {
public CuboidRegion(Vector pos1, Vector pos2) {
this.pos1 = pos1;
this.pos2 = pos2;
}
@ -52,8 +52,8 @@ public class CuboidRegion implements Region {
* @return min point
*/
@Override
public Point getMinimumPoint() {
return new Point(Math.min(pos1.getX(), pos2.getX()),
public Vector getMinimumPoint() {
return new Vector(Math.min(pos1.getX(), pos2.getX()),
Math.min(pos1.getY(), pos2.getY()),
Math.min(pos1.getZ(), pos2.getZ()));
}
@ -64,8 +64,8 @@ public class CuboidRegion implements Region {
* @return max point
*/
@Override
public Point getMaximumPoint() {
return new Point(Math.max(pos1.getX(), pos2.getX()),
public Vector getMaximumPoint() {
return new Vector(Math.max(pos1.getX(), pos2.getX()),
Math.max(pos1.getY(), pos2.getY()),
Math.max(pos1.getZ(), pos2.getZ()));
}
@ -76,8 +76,8 @@ public class CuboidRegion implements Region {
* @return number of blocks
*/
public int getSize() {
Point min = getMinimumPoint();
Point max = getMaximumPoint();
Vector min = getMinimumPoint();
Vector max = getMaximumPoint();
return (int)((max.getX() - min.getX() + 1) *
(max.getY() - min.getY() + 1) *
@ -90,8 +90,8 @@ public class CuboidRegion implements Region {
* @return width
*/
public int getWidth() {
Point min = getMinimumPoint();
Point max = getMaximumPoint();
Vector min = getMinimumPoint();
Vector max = getMaximumPoint();
return (int)(max.getX() - min.getX() + 1);
}
@ -102,8 +102,8 @@ public class CuboidRegion implements Region {
* @return height
*/
public int getHeight() {
Point min = getMinimumPoint();
Point max = getMaximumPoint();
Vector min = getMinimumPoint();
Vector max = getMaximumPoint();
return (int)(max.getY() - min.getY() + 1);
}
@ -114,8 +114,8 @@ public class CuboidRegion implements Region {
* @return length
*/
public int getLength() {
Point min = getMinimumPoint();
Point max = getMaximumPoint();
Vector min = getMinimumPoint();
Vector max = getMaximumPoint();
return (int)(max.getZ() - min.getZ() + 1);
}
@ -125,7 +125,7 @@ public class CuboidRegion implements Region {
*
* @return iterator of Points
*/
public Iterator<Point> iterator() {
public Iterator<Vector> iterator() {
throw new UnsupportedOperationException("Not implemented");
}
}

Datei anzeigen

@ -23,19 +23,19 @@ package com.sk89q.worldedit;
*
* @author Albert
*/
public interface Region extends Iterable<Point> {
public interface Region extends Iterable<Vector> {
/**
* Get the lower point of a region.
*
* @return min. point
*/
public Point getMinimumPoint();
public Vector getMinimumPoint();
/**
* Get the upper point of a region.
*
* @return max. point
*/
public Point getMaximumPoint();
public Vector getMaximumPoint();
/**
* Get the number of blocks in the region.
*

Datei anzeigen

@ -23,63 +23,63 @@ package com.sk89q.worldedit;
*
* @author Albert
*/
public class Point {
public class Vector {
protected final double x, y, z;
/**
* Construct the Point object.
* Construct the Vector object.
*
* @param x
* @param y
* @param z
*/
public Point(double x, double y, double z) {
public Vector(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
/**
* Construct the Point object.
* Construct the Vector object.
*
* @param x
* @param y
* @param z
*/
public Point(int x, int y, int z) {
public Vector(int x, int y, int z) {
this.x = (double)x;
this.y = (double)y;
this.z = (double)z;
}
/**
* Construct the Point object.
* Construct the Vector object.
*
* @param x
* @param y
* @param z
*/
public Point(float x, float y, float z) {
public Vector(float x, float y, float z) {
this.x = (double)x;
this.y = (double)y;
this.z = (double)z;
}
/**
* Construct the Point object.
* Construct the Vector object.
*
* @param pt
*/
public Point(Point pt) {
public Vector(Vector pt) {
this.x = pt.x;
this.y = pt.y;
this.z = pt.z;
}
/**
* Construct the Point object.
* Construct the Vector object.
*/
public Point() {
public Vector() {
this.x = 0;
this.y = 0;
this.z = 0;
@ -133,8 +133,8 @@ public class Point {
* @param other
* @return New point
*/
public Point add(Point other) {
return new Point(x + other.x, y + other.y, z + other.z);
public Vector add(Vector other) {
return new Vector(x + other.x, y + other.y, z + other.z);
}
/**
@ -145,8 +145,8 @@ public class Point {
* @param z
* @return New point
*/
public Point add(double x, double y, double z) {
return new Point(this.x + x, this.y + y, this.z + z);
public Vector add(double x, double y, double z) {
return new Vector(this.x + x, this.y + y, this.z + z);
}
/**
@ -157,8 +157,8 @@ public class Point {
* @param z
* @return New point
*/
public Point add(int x, int y, int z) {
return new Point(this.x + x, this.y + y, this.z + z);
public Vector add(int x, int y, int z) {
return new Vector(this.x + x, this.y + y, this.z + z);
}
/**
@ -167,7 +167,7 @@ public class Point {
* @param others
* @return New point
*/
public Point add(Point ... others) {
public Vector add(Vector ... others) {
double newX = x, newY = y, newZ = z;
for (int i = 0; i < others.length; i++) {
@ -175,7 +175,7 @@ public class Point {
newY += others[i].y;
newZ += others[i].z;
}
return new Point(newX, newY, newZ);
return new Vector(newX, newY, newZ);
}
/**
@ -184,8 +184,8 @@ public class Point {
* @param other
* @return New point
*/
public Point subtract(Point other) {
return new Point(x - other.x, y - other.y, z - other.z);
public Vector subtract(Vector other) {
return new Vector(x - other.x, y - other.y, z - other.z);
}
/**
@ -196,8 +196,8 @@ public class Point {
* @param z
* @return New point
*/
public Point subtract(double x, double y, double z) {
return new Point(this.x - x, this.y - y, this.z - z);
public Vector subtract(double x, double y, double z) {
return new Vector(this.x - x, this.y - y, this.z - z);
}
/**
@ -208,8 +208,8 @@ public class Point {
* @param z
* @return New point
*/
public Point subtract(int x, int y, int z) {
return new Point(this.x - x, this.y - y, this.z - z);
public Vector subtract(int x, int y, int z) {
return new Vector(this.x - x, this.y - y, this.z - z);
}
/**
@ -218,7 +218,7 @@ public class Point {
* @param others
* @return New point
*/
public Point subtract(Point ... others) {
public Vector subtract(Vector ... others) {
double newX = x, newY = y, newZ = z;
for (int i = 0; i < others.length; i++) {
@ -226,7 +226,7 @@ public class Point {
newY -= others[i].y;
newZ -= others[i].z;
}
return new Point(newX, newY, newZ);
return new Vector(newX, newY, newZ);
}
/**
@ -235,8 +235,8 @@ public class Point {
* @param other
* @return New point
*/
public Point multiply(Point other) {
return new Point(x * other.x, y * other.y, z * other.z);
public Vector multiply(Vector other) {
return new Vector(x * other.x, y * other.y, z * other.z);
}
/**
@ -247,8 +247,8 @@ public class Point {
* @param z
* @return New point
*/
public Point multiply(double x, double y, double z) {
return new Point(this.x * x, this.y * y, this.z * z);
public Vector multiply(double x, double y, double z) {
return new Vector(this.x * x, this.y * y, this.z * z);
}
/**
@ -259,8 +259,8 @@ public class Point {
* @param z
* @return New point
*/
public Point multiply(int x, int y, int z) {
return new Point(this.x * x, this.y * y, this.z * z);
public Vector multiply(int x, int y, int z) {
return new Vector(this.x * x, this.y * y, this.z * z);
}
/**
@ -269,7 +269,7 @@ public class Point {
* @param others
* @return New point
*/
public Point multiply(Point ... others) {
public Vector multiply(Vector ... others) {
double newX = x, newY = y, newZ = z;
for (int i = 0; i < others.length; i++) {
@ -277,7 +277,7 @@ public class Point {
newY *= others[i].y;
newZ *= others[i].z;
}
return new Point(newX, newY, newZ);
return new Vector(newX, newY, newZ);
}
/**
@ -286,8 +286,8 @@ public class Point {
* @param other
* @return New point
*/
public Point divide(Point other) {
return new Point(x / other.x, y / other.y, z / other.z);
public Vector divide(Vector other) {
return new Vector(x / other.x, y / other.y, z / other.z);
}
/**
@ -298,8 +298,8 @@ public class Point {
* @param z
* @return New point
*/
public Point divide(double x, double y, double z) {
return new Point(this.x / x, this.y / y, this.z / z);
public Vector divide(double x, double y, double z) {
return new Vector(this.x / x, this.y / y, this.z / z);
}
/**
@ -310,8 +310,8 @@ public class Point {
* @param z
* @return New point
*/
public Point divide(int x, int y, int z) {
return new Point(this.x / x, this.y / y, this.z / z);
public Vector divide(int x, int y, int z) {
return new Vector(this.x / x, this.y / y, this.z / z);
}
/**
@ -320,7 +320,7 @@ public class Point {
* @param pt
* @return distance
*/
public double distance(Point pt) {
public double distance(Vector pt) {
return Math.sqrt(Math.pow(pt.x - x, 2) +
Math.pow(pt.y - y, 2) +
Math.pow(pt.z - z, 2));
@ -334,8 +334,8 @@ public class Point {
* @param z
* @return point
*/
public static Point toBlockPoint(double x, double y, double z) {
return new Point((int)Math.floor(x),
public static Vector toBlockPoint(double x, double y, double z) {
return new Vector((int)Math.floor(x),
(int)Math.floor(y),
(int)Math.floor(z));
}
@ -348,10 +348,10 @@ public class Point {
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Point)) {
if (!(obj instanceof Vector)) {
return false;
}
Point other = (Point)obj;
Vector other = (Vector)obj;
return other.x == this.x && other.y == this.y && other.z == this.z;
}
@ -379,11 +379,11 @@ public class Point {
}
/**
* Gets a BlockPoint version.
* Gets a BlockVector version.
*
* @return BlockPoint
* @return BlockVector
*/
public BlockPoint toBlockPoint() {
return new BlockPoint(this);
public BlockVector toBlockPoint() {
return new BlockVector(this);
}
}