Package com.loohp.limbo.location
Class Location
java.lang.Object
com.loohp.limbo.location.Location
- All Implemented Interfaces:
Cloneable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(double x, double y, double z) Adds the location by another.Adds the location by another.Adds the location by a vector.void
Check if each component of this Location is finite.clone()
double
Get the distance between this location and another.double
Get the squared distance between this location and another.boolean
Gets a unit-vector pointing in the direction that this Location is facing.float
getPitch()
getWorld()
double
getX()
double
getY()
float
getYaw()
double
getZ()
int
hashCode()
boolean
double
length()
Gets the magnitude of the location, defined as sqrt(x^2+y^2+z^2).double
Gets the magnitude of the location squared.static int
locToBlock
(double loc) Safely converts a double (location coordinate) to an int (block coordinate)multiply
(double m) Performs scalar multiplication, multiplying all components with a scalar.static float
normalizePitch
(float pitch) Normalizes the given pitch angle to a value between+/-90
degrees.static float
normalizeYaw
(float yaw) Normalizes the given yaw angle to a value between+/-180
degrees.void
setBlockState
(BlockState state) setDirection
(Vector vector) void
setPitch
(float pitch) void
void
setX
(double x) void
setY
(double y) void
setYaw
(float yaw) void
setZ
(double z) subtract
(double x, double y, double z) Subtracts the location by another.Subtracts the location by another.Subtracts the location by a vector.toString()
toVector()
Constructs a newVector
based on this Locationzero()
Zero this location's components.
-
Constructor Details
-
Location
-
Location
-
-
Method Details
-
clone
-
getBlockState
-
setBlockState
-
isWorldLoaded
public boolean isWorldLoaded() -
getWorld
-
setWorld
-
getX
public double getX() -
setX
public void setX(double x) -
getY
public double getY() -
setY
public void setY(double y) -
getZ
public double getZ() -
setZ
public void setZ(double z) -
getYaw
public float getYaw() -
setYaw
public void setYaw(float yaw) -
getPitch
public float getPitch() -
setPitch
public void setPitch(float pitch) -
getDirection
Gets a unit-vector pointing in the direction that this Location is facing. -
setDirection
- Parameters:
vector
- the direction vector- Returns:
- the same location
-
add
Adds the location by another.- Parameters:
vec
- The other location- Returns:
- the same location
- Throws:
IllegalArgumentException
- for differing worlds- See Also:
-
add
Adds the location by a vector.- Parameters:
vec
- Vector to use- Returns:
- the same location
- See Also:
-
add
Adds the location by another. Not world-aware.- Parameters:
x
- X coordinatey
- Y coordinatez
- Z coordinate- Returns:
- the same location
- See Also:
-
subtract
Subtracts the location by another.- Parameters:
vec
- The other location- Returns:
- the same location
- Throws:
IllegalArgumentException
- for differing worlds- See Also:
-
subtract
Subtracts the location by a vector.- Parameters:
vec
- The vector to use- Returns:
- the same location
- See Also:
-
subtract
Subtracts the location by another. Not world-aware and orientation independent.- Parameters:
x
- X coordinatey
- Y coordinatez
- Z coordinate- Returns:
- the same location
- See Also:
-
length
public double length()Gets the magnitude of the location, defined as sqrt(x^2+y^2+z^2). The value of this method is not cached and uses a costly square-root function, so do not repeatedly call this method to get the location's magnitude. NaN will be returned if the inner result of the sqrt() function overflows, which will be caused if the length is too long. Not world-aware and orientation independent.- Returns:
- the magnitude
- See Also:
-
lengthSquared
public double lengthSquared()Gets the magnitude of the location squared. Not world-aware and orientation independent.- Returns:
- the magnitude
- See Also:
-
distance
Get the distance between this location and another. The value of this method is not cached and uses a costly square-root function, so do not repeatedly call this method to get the location's magnitude. NaN will be returned if the inner result of the sqrt() function overflows, which will be caused if the distance is too long.- Parameters:
o
- The other location- Returns:
- the distance
- Throws:
IllegalArgumentException
- for differing worlds- See Also:
-
distanceSquared
Get the squared distance between this location and another.- Parameters:
o
- The other location- Returns:
- the distance
- Throws:
IllegalArgumentException
- for differing worlds- See Also:
-
multiply
Performs scalar multiplication, multiplying all components with a scalar. Not world-aware.- Parameters:
m
- The factor- Returns:
- the same location
- See Also:
-
zero
Zero this location's components. Not world-aware.- Returns:
- the same location
- See Also:
-
toVector
Constructs a newVector
based on this Location- Returns:
- New Vector containing the coordinates represented by this Location
-
checkFinite
Check if each component of this Location is finite.- Throws:
IllegalArgumentException
- if any component is not finite
-
locToBlock
public static int locToBlock(double loc) Safely converts a double (location coordinate) to an int (block coordinate)- Parameters:
loc
- Precise coordinate- Returns:
- Block coordinate
-
normalizeYaw
public static float normalizeYaw(float yaw) Normalizes the given yaw angle to a value between+/-180
degrees.- Parameters:
yaw
- the yaw in degrees- Returns:
- the normalized yaw in degrees
- See Also:
-
normalizePitch
public static float normalizePitch(float pitch) Normalizes the given pitch angle to a value between+/-90
degrees.- Parameters:
pitch
- the pitch in degrees- Returns:
- the normalized pitch in degrees
- See Also:
-
toSimpleString
-
toString
-
equals
-
hashCode
public int hashCode()
-