mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Removed Point/BlockPoint to Vector/BlockVector.
This commit is contained in:
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user