Revert finite checks in locations. Fixes SPIGOT-628 and others

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2015-02-28 09:43:52 +11:00
parent 925591bd64
commit 76a64b3e2d
3 changed files with 115 additions and 92 deletions

View File

@@ -16,7 +16,9 @@ public class BlockVector extends Vector {
* Construct the vector with all components as 0.
*/
public BlockVector() {
super();
this.x = 0;
this.y = 0;
this.z = 0;
}
/**
@@ -25,7 +27,9 @@ public class BlockVector extends Vector {
* @param vec The other vector.
*/
public BlockVector(Vector vec) {
this(vec.getX(), vec.getY(), vec.getZ());
this.x = vec.getX();
this.y = vec.getY();
this.z = vec.getZ();
}
/**
@@ -36,7 +40,9 @@ public class BlockVector extends Vector {
* @param z Z component
*/
public BlockVector(int x, int y, int z) {
super(x, y, z);
this.x = x;
this.y = y;
this.z = z;
}
/**
@@ -47,7 +53,9 @@ public class BlockVector extends Vector {
* @param z Z component
*/
public BlockVector(double x, double y, double z) {
super(x, y, z);
this.x = x;
this.y = y;
this.z = z;
}
/**
@@ -58,7 +66,9 @@ public class BlockVector extends Vector {
* @param z Z component
*/
public BlockVector(float x, float y, float z) {
super(x, y, z);
this.x = x;
this.y = y;
this.z = z;
}
/**

View File

@@ -34,7 +34,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* Construct the vector with all components as 0.
*/
public Vector() {
this(0, 0, 0);
this.x = 0;
this.y = 0;
this.z = 0;
}
/**
@@ -45,7 +47,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @param z Z component
*/
public Vector(int x, int y, int z) {
this((double) x, (double) y, (double) z);
this.x = x;
this.y = y;
this.z = z;
}
/**
@@ -56,10 +60,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @param z Z component
*/
public Vector(double x, double y, double z) {
// use setters for range checks
setX(x);
setY(y);
setZ(z);
this.x = x;
this.y = y;
this.z = z;
}
/**
@@ -70,7 +73,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @param z Z component
*/
public Vector(float x, float y, float z) {
this((double) x, (double) y, (double) z);
this.x = x;
this.y = y;
this.z = z;
}
/**
@@ -80,9 +85,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector add(Vector vec) {
setX(getX() + vec.getX());
setY(getY() + vec.getY());
setZ(getZ() + vec.getZ());
x += vec.x;
y += vec.y;
z += vec.z;
return this;
}
@@ -93,9 +98,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector subtract(Vector vec) {
setX(getX() - vec.getX());
setY(getY() - vec.getY());
setZ(getZ() - vec.getZ());
x -= vec.x;
y -= vec.y;
z -= vec.z;
return this;
}
@@ -106,9 +111,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector multiply(Vector vec) {
setX(getX() * vec.getX());
setY(getY() * vec.getY());
setZ(getZ() * vec.getZ());
x *= vec.x;
y *= vec.y;
z *= vec.z;
return this;
}
@@ -119,9 +124,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector divide(Vector vec) {
setX(getX() / vec.getX());
setY(getY() / vec.getY());
setZ(getZ() / vec.getZ());
x /= vec.x;
y /= vec.y;
z /= vec.z;
return this;
}
@@ -132,9 +137,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector copy(Vector vec) {
setX(vec.getX());
setY(vec.getY());
setZ(vec.getZ());
x = vec.x;
y = vec.y;
z = vec.z;
return this;
}
@@ -203,9 +208,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return this same vector (now a midpoint)
*/
public Vector midpoint(Vector other) {
setX((getX() + other.getX()) / 2);
setY((getY() + other.getY()) / 2);
setZ((getZ() + other.getZ()) / 2);
x = (x + other.x) / 2;
y = (y + other.y) / 2;
z = (z + other.z) / 2;
return this;
}
@@ -230,7 +235,10 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector multiply(int m) {
return multiply((double) m);
x *= m;
y *= m;
z *= m;
return this;
}
/**
@@ -241,9 +249,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector multiply(double m) {
setX(getX() * m);
setY(getY() * m);
setZ(getZ() * m);
x *= m;
y *= m;
z *= m;
return this;
}
@@ -255,7 +263,10 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector multiply(float m) {
return multiply((double) m);
x *= m;
y *= m;
z *= m;
return this;
}
/**
@@ -282,13 +293,13 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector crossProduct(Vector o) {
double newX = getY() * o.getZ() - o.getY() * getZ();
double newY = getZ() * o.getX() - o.getZ() * getX();
double newZ = getX() * o.getY() - o.getX() * getY();
double newX = y * o.z - o.y * z;
double newY = z * o.x - o.z * x;
double newZ = x * o.y - o.x * y;
setX(newX);
setY(newY);
setZ(newZ);
x = newX;
y = newY;
z = newZ;
return this;
}
@@ -300,7 +311,11 @@ public class Vector implements Cloneable, ConfigurationSerializable {
public Vector normalize() {
double length = length();
return multiply(1 / length);
x /= length;
y /= length;
z /= length;
return this;
}
/**
@@ -309,9 +324,9 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return the same vector
*/
public Vector zero() {
setX(0D);
setY(0D);
setZ(0D);
x = 0;
y = 0;
z = 0;
return this;
}
@@ -404,7 +419,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return This vector.
*/
public Vector setX(int x) {
return setX((double) x);
this.x = x;
return this;
}
/**
@@ -414,7 +430,6 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return This vector.
*/
public Vector setX(double x) {
checkFinite(x, "x must be finite");
this.x = x;
return this;
}
@@ -426,7 +441,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return This vector.
*/
public Vector setX(float x) {
return setX((double) x);
this.x = x;
return this;
}
/**
@@ -436,7 +452,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return This vector.
*/
public Vector setY(int y) {
return setY((double) y);
this.y = y;
return this;
}
/**
@@ -446,7 +463,6 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return This vector.
*/
public Vector setY(double y) {
checkFinite(y, "y must be finite");
this.y = y;
return this;
}
@@ -458,7 +474,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return This vector.
*/
public Vector setY(float y) {
return setY((double) y);
this.y = y;
return this;
}
/**
@@ -468,7 +485,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return This vector.
*/
public Vector setZ(int z) {
return setZ((double) z);
this.z = z;
return this;
}
/**
@@ -478,7 +496,6 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return This vector.
*/
public Vector setZ(double z) {
checkFinite(z, "z must be finite");
this.z = z;
return this;
}
@@ -490,7 +507,8 @@ public class Vector implements Cloneable, ConfigurationSerializable {
* @return This vector.
*/
public Vector setZ(float z) {
return setZ((double) z);
this.z = z;
return this;
}
/**