summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/Location.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/bukkit/Location.java')
-rw-r--r--src/main/java/org/bukkit/Location.java71
1 files changed, 33 insertions, 38 deletions
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index 583dbe8f..e7af316d 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -43,12 +43,12 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param pitch The absolute rotation on the y-plane, in degrees
*/
public Location(final World world, final double x, final double y, final double z, final float yaw, final float pitch) {
- setWorld(world);
- setX(x);
- setY(y);
- setZ(z);
- setPitch(pitch);
- setYaw(yaw);
+ this.world = world;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.pitch = pitch;
+ this.yaw = yaw;
}
/**
@@ -93,7 +93,6 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param x X-coordinate
*/
public void setX(double x) {
- checkFinite(x, "x must be finite");
this.x = x;
}
@@ -122,7 +121,6 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param y y-coordinate
*/
public void setY(double y) {
- checkFinite(y, "y must be finite");
this.y = y;
}
@@ -151,7 +149,6 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param z z-coordinate
*/
public void setZ(double z) {
- checkFinite(z, "z must be finite");
this.z = z;
}
@@ -189,7 +186,6 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param yaw new rotation's yaw
*/
public void setYaw(float yaw) {
- checkFinite(yaw, "yaw must be finite");
this.yaw = yaw;
}
@@ -224,7 +220,6 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param pitch new incline's pitch
*/
public void setPitch(float pitch) {
- checkFinite(pitch, "pitch must be finite");
this.pitch = pitch;
}
@@ -288,17 +283,17 @@ public class Location implements Cloneable, ConfigurationSerializable {
final double z = vector.getZ();
if (x == 0 && z == 0) {
- setPitch(vector.getY() > 0 ? -90 : 90);
+ pitch = vector.getY() > 0 ? -90 : 90;
return this;
}
double theta = Math.atan2(-x, z);
- setYaw((float) Math.toDegrees((theta + _2PI) % _2PI));
+ yaw = (float) Math.toDegrees((theta + _2PI) % _2PI);
double x2 = NumberConversions.square(x);
double z2 = NumberConversions.square(z);
double xz = Math.sqrt(x2 + z2);
- setPitch((float) Math.toDegrees(Math.atan(-vector.getY() / xz)));
+ pitch = (float) Math.toDegrees(Math.atan(-vector.getY() / xz));
return this;
}
@@ -316,9 +311,9 @@ public class Location implements Cloneable, ConfigurationSerializable {
throw new IllegalArgumentException("Cannot add Locations of differing worlds");
}
- setX(getX() + vec.getX());
- setY(getY() + vec.getY());
- setZ(getZ() + vec.getZ());
+ x += vec.x;
+ y += vec.y;
+ z += vec.z;
return this;
}
@@ -330,9 +325,9 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return the same location
*/
public Location add(Vector vec) {
- setX(getX() + vec.getX());
- setY(getY() + vec.getY());
- setZ(getZ() + vec.getZ());
+ this.x += vec.getX();
+ this.y += vec.getY();
+ this.z += vec.getZ();
return this;
}
@@ -346,9 +341,9 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return the same location
*/
public Location add(double x, double y, double z) {
- setX(getX() + x);
- setY(getY() + y);
- setZ(getZ() + z);
+ this.x += x;
+ this.y += y;
+ this.z += z;
return this;
}
@@ -365,9 +360,9 @@ public class Location implements Cloneable, ConfigurationSerializable {
throw new IllegalArgumentException("Cannot add Locations of differing worlds");
}
- setX(getX() - vec.getX());
- setY(getY() - vec.getY());
- setZ(getZ() - vec.getZ());
+ x -= vec.x;
+ y -= vec.y;
+ z -= vec.z;
return this;
}
@@ -379,9 +374,9 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return the same location
*/
public Location subtract(Vector vec) {
- setX(getX() - vec.getX());
- setY(getY() - vec.getY());
- setZ(getZ() - vec.getZ());
+ this.x -= vec.getX();
+ this.y -= vec.getY();
+ this.z -= vec.getZ();
return this;
}
@@ -396,9 +391,9 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return the same location
*/
public Location subtract(double x, double y, double z) {
- setX(getX() - x);
- setY(getY() - y);
- setZ(getZ() - z);
+ this.x -= x;
+ this.y -= y;
+ this.z -= z;
return this;
}
@@ -473,9 +468,9 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return the same location
*/
public Location multiply(double m) {
- setX(getX() * m);
- setY(getY() * m);
- setZ(getZ() * m);
+ x *= m;
+ y *= m;
+ z *= m;
return this;
}
@@ -486,9 +481,9 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return the same location
*/
public Location zero() {
- setX(0D);
- setY(0D);
- setZ(0D);
+ x = 0;
+ y = 0;
+ z = 0;
return this;
}