Improved Vector and Location with some utility methods, optimized Vector.isInSphere().

This commit is contained in:
sk89q
2011-01-02 10:42:13 -08:00
committed by Dinnerbone
parent 7168e9cf26
commit de91a2ebdc
2 changed files with 419 additions and 352 deletions

View File

@@ -60,6 +60,16 @@ public class Location implements Cloneable {
public double getX() {
return x;
}
/**
* Gets the floored value of the X component, indicating the block that
* this location is contained with.
*
* @return block X
*/
public int getBlockX() {
return (int)Math.floor(x);
}
/**
* Sets the y-coordinate of this location
@@ -79,6 +89,16 @@ public class Location implements Cloneable {
return y;
}
/**
* Gets the floored value of the Y component, indicating the block that
* this location is contained with.
*
* @return block y
*/
public int getBlockY() {
return (int)Math.floor(y);
}
/**
* Sets the z-coordinate of this location
*
@@ -97,6 +117,16 @@ public class Location implements Cloneable {
return z;
}
/**
* Gets the floored value of the Z component, indicating the block that
* this location is contained with.
*
* @return block z
*/
public int getBlockZ() {
return (int)Math.floor(z);
}
/**
* Sets the yaw of this location
*