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,
Vector3 direction)
Create a new instance in the given extent with the given coordinates
and the given direction vector.
|
Location(Extent extent,
Vector3 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,
Vector3 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,
Vector3 position,
Vector3 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.
|
Vector3 |
getDirection()
Get the direction vector.
|
Direction |
getDirectionEnum()
Get the direction as a
Direction . |
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(Vector3 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 |
setPosition(Vector3 position)
Return a copy of this object with the position set to the given value.
|
Location |
setX(double 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 |
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.
|
Vector3 |
toVector()
Get a
Vector3 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, Vector3 position)
extent
- the extentposition
- the position vectorpublic Location(Extent extent, double x, double y, double z, Vector3 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, Vector3 position, Vector3 direction)
extent
- the extentposition
- the position vectordirection
- the direction vectorpublic Location(Extent extent, Vector3 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 Vector3 getDirection()
public Direction getDirectionEnum()
Direction
.public Location setDirection(Vector3 direction)
direction
- the new directionpublic Vector3 toVector()
Vector3
form of this location's position.public double getX()
public int getBlockX()
public Location setX(double 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 double getZ()
public int getBlockZ()
public Location setZ(double z)
z
- the new value for the Y componentpublic Location setPosition(Vector3 position)
position
- The new positionpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object