public class Location
extends java.lang.Object
Like Vectors
, Locations
are immutable and mutator methods
will create a new copy.
At the moment, but this may change in the future, hashCode()
and
equals(Object)
are subject to minor differences caused by
floating point errors.
Constructor and Description |
---|
Location(Extent extent)
Create a new instance in the given extent at 0, 0, 0 with a
direction vector of 0, 0, 0.
|
Location(Extent extent,
double x,
double y,
double z)
Create a new instance in the given extent with the given coordinates
with a direction vector of 0, 0, 0.
|
Location(Extent extent,
double x,
double y,
double z,
float yaw,
float pitch)
Create a new instance in the given extent with the given coordinates
and the given direction vector.
|
Location(Extent extent,
double x,
double y,
double z,
Vector direction)
Create a new instance in the given extent with the given coordinates
and the given direction vector.
|
Location(Extent extent,
Vector position)
Create a new instance in the given extent with the given position
vector and a direction vector of 0, 0, 0.
|
Location(Extent extent,
Vector position,
float yaw,
float pitch)
Create a new instance in the given extent with the given position vector
and the given direction vector.
|
Location(Extent extent,
Vector position,
Vector direction)
Create a new instance in the given extent with the given position vector
and the given direction vector.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
int |
getBlockX()
Get the rounded X component of the position vector.
|
int |
getBlockY()
Get the rounded Y component of the position vector.
|
int |
getBlockZ()
Get the rounded Z component of the position vector.
|
Vector |
getDirection()
Get the direction vector.
|
Extent |
getExtent()
Get the extent.
|
float |
getPitch()
Get the pitch in degrees.
|
double |
getX()
Get the X component of the position vector.
|
double |
getY()
Get the Y component of the position vector.
|
float |
getYaw()
Get the yaw in degrees.
|
double |
getZ()
Get the Z component of the position vector.
|
int |
hashCode() |
Location |
setDirection(float yaw,
float pitch)
Create a clone of this object with the given yaw and pitch.
|
Location |
setDirection(Vector direction)
Create a clone of this object with the given direction.
|
Location |
setExtent(Extent extent)
Create a clone of this object with the given extent.
|
Location |
setPitch(float pitch)
Create a clone of this object with the given pitch.
|
Location |
setX(double x)
Return a copy of this object with the X component of the new object
set to the given value.
|
Location |
setX(int x)
Return a copy of this object with the X component of the new object
set to the given value.
|
Location |
setY(double y)
Return a copy of this object with the Y component of the new object
set to the given value.
|
Location |
setY(int y)
Return a copy of this object with the Y component of the new object
set to the given value.
|
Location |
setYaw(float yaw)
Create a clone of this object with the given yaw.
|
Location |
setZ(double z)
Return a copy of this object with the Z component of the new object
set to the given value.
|
Location |
setZ(int z)
Return a copy of this object with the Z component of the new object
set to the given value.
|
Vector |
toVector()
Get a
Vector form of this location's position. |
public Location(Extent extent)
extent
- the extentpublic Location(Extent extent, double x, double y, double z)
extent
- the extentx
- the X coordinatey
- the Y coordinatez
- the Z coordinatepublic Location(Extent extent, Vector position)
extent
- the extentposition
- the position vectorpublic Location(Extent extent, double x, double y, double z, Vector direction)
extent
- the extentx
- the X coordinatey
- the Y coordinatez
- the Z coordinatedirection
- the direction vectorpublic Location(Extent extent, double x, double y, double z, float yaw, float pitch)
extent
- the extentx
- the X coordinatey
- the Y coordinatez
- the Z coordinateyaw
- the yaw, in degreespitch
- the pitch, in degreespublic Location(Extent extent, Vector position, Vector direction)
extent
- the extentposition
- the position vectordirection
- the direction vectorpublic Location(Extent extent, Vector position, float yaw, float pitch)
extent
- the extentposition
- the position vectoryaw
- the yaw, in degreespitch
- the pitch, in degreespublic Extent getExtent()
public Location setExtent(Extent extent)
extent
- the new extentpublic float getYaw()
public Location setYaw(float yaw)
yaw
- the new yawpublic float getPitch()
public Location setPitch(float pitch)
pitch
- the new yawpublic Location setDirection(float yaw, float pitch)
yaw
- the new yawpitch
- the new pitchpublic Vector getDirection()
public Location setDirection(Vector direction)
direction
- the new directionpublic double getX()
public int getBlockX()
public Location setX(double x)
x
- the new value for the X componentpublic Location setX(int x)
x
- the new value for the X componentpublic double getY()
public int getBlockY()
public Location setY(double y)
y
- the new value for the Y componentpublic Location setY(int y)
y
- the new value for the Y componentpublic double getZ()
public int getBlockZ()
public Location setZ(double z)
z
- the new value for the Y componentpublic Location setZ(int z)
z
- the new value for the Y componentpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object