Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
org.bukkit.Location Class Reference

Represents a 3-dimensional position in a world. More...

+ Inheritance diagram for org.bukkit.Location:
+ Collaboration diagram for org.bukkit.Location:

Public Member Functions

 Location (final World world, final double x, final double y, final double z)
 Constructs a new Location with the given coordinates.
 
 Location (final World world, final double x, final double y, final double z, final float yaw, final float pitch)
 Constructs a new Location with the given coordinates and direction.
 
void setWorld (World world)
 Sets the world that this location resides in.
 
World getWorld ()
 Gets the world that this location resides in.
 
Chunk getChunk ()
 Gets the chunk at the represented location.
 
Block getBlock ()
 Gets the block at the represented location.
 
void setX (double x)
 Sets the x-coordinate of this location.
 
double getX ()
 Gets the x-coordinate of this location.
 
int getBlockX ()
 Gets the floored value of the X component, indicating the block that this location is contained with.
 
void setY (double y)
 Sets the y-coordinate of this location.
 
double getY ()
 Gets the y-coordinate of this location.
 
int getBlockY ()
 Gets the floored value of the Y component, indicating the block that this location is contained with.
 
void setZ (double z)
 Sets the z-coordinate of this location.
 
double getZ ()
 Gets the z-coordinate of this location.
 
int getBlockZ ()
 Gets the floored value of the Z component, indicating the block that this location is contained with.
 
void setYaw (float yaw)
 Sets the yaw of this location.
 
float getYaw ()
 Gets the yaw of this location.
 
void setPitch (float pitch)
 Sets the pitch of this location.
 
float getPitch ()
 Gets the pitch of this location.
 
Vector getDirection ()
 Gets a Vector pointing in the direction that this Location is facing.
 
Location add (Location vec)
 Adds the location by another.
 
Location add (Vector vec)
 Adds the location by a vector.
 
Location add (double x, double y, double z)
 Adds the location by another.
 
Location subtract (Location vec)
 Subtracts the location by another.
 
Location subtract (Vector vec)
 Subtracts the location by a vector.
 
Location subtract (double x, double y, double z)
 Subtracts the location by another.
 
double length ()
 Gets the magnitude of the location, defined as sqrt(x^2+y^2+z^2).
 
double lengthSquared ()
 Gets the magnitude of the location squared.
 
double distance (Location o)
 Get the distance between this location and another.
 
double distanceSquared (Location o)
 Get the squared distance between this location and another.
 
Location multiply (double m)
 Performs scalar multiplication, multiplying all components with a scalar.
 
Location zero ()
 Zero this location's components.
 
boolean equals (Object obj)
 
int hashCode ()
 
String toString ()
 
Vector toVector ()
 Constructs a new Vector based on this Location.
 
Location clone ()
 

Static Public Member Functions

static int locToBlock (double loc)
 Safely converts a double (location coordinate) to an int (block coordinate)
 

Detailed Description

Represents a 3-dimensional position in a world.

Definition at line 10 of file Location.java.

Constructor & Destructor Documentation

org.bukkit.Location.Location ( final World  world,
final double  x,
final double  y,
final double  z 
)

Constructs a new Location with the given coordinates.

Parameters
worldThe world in which this location resides
xThe x-coordinate of this new location
yThe y-coordinate of this new location
zThe z-coordinate of this new location

Definition at line 26 of file Location.java.

Referenced by org.bukkit.Location.equals().

org.bukkit.Location.Location ( final World  world,
final double  x,
final double  y,
final double  z,
final float  yaw,
final float  pitch 
)

Constructs a new Location with the given coordinates and direction.

Parameters
worldThe world in which this location resides
xThe x-coordinate of this new location
yThe y-coordinate of this new location
zThe z-coordinate of this new location
yawThe absolute rotation on the x-plane, in degrees
pitchThe absolute rotation on the y-plane, in degrees

Definition at line 40 of file Location.java.

Member Function Documentation

Location org.bukkit.Location.add ( Location  vec)

Adds the location by another.

See Also
Vector
Parameters
vecThe other location
Returns
the same location
Exceptions
IllegalArgumentExceptionfor differing worlds

Definition at line 234 of file Location.java.

References org.bukkit.Location.getWorld().

Location org.bukkit.Location.add ( Vector  vec)

Adds the location by a vector.

See Also
Vector
Parameters
vecVector to use
Returns
the same location

Definition at line 252 of file Location.java.

References org.bukkit.util.Vector.getX(), org.bukkit.util.Vector.getY(), and org.bukkit.util.Vector.getZ().

Location org.bukkit.Location.add ( double  x,
double  y,
double  z 
)

Adds the location by another.

Not world-aware.

See Also
Vector
Parameters
xX coordinate
yY coordinate
zZ coordinate
Returns
the same location

Definition at line 268 of file Location.java.

Location org.bukkit.Location.clone ( )

Definition at line 474 of file Location.java.

References org.bukkit.Location.clone().

Referenced by org.bukkit.Location.clone().

double org.bukkit.Location.distance ( Location  o)

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.

See Also
Vector
Parameters
oThe other location
Returns
the distance
Exceptions
IllegalArgumentExceptionfor differing worlds

Definition at line 363 of file Location.java.

References org.bukkit.Location.distanceSquared().

double org.bukkit.Location.distanceSquared ( Location  o)

Get the squared distance between this location and another.

See Also
Vector
Parameters
oThe other location
Returns
the distance
Exceptions
IllegalArgumentExceptionfor differing worlds

Definition at line 375 of file Location.java.

References org.bukkit.World.getName(), and org.bukkit.Location.getWorld().

Referenced by org.bukkit.Location.distance().

boolean org.bukkit.Location.equals ( Object  obj)

Definition at line 416 of file Location.java.

References org.bukkit.Location.Location().

Block org.bukkit.Location.getBlock ( )

Gets the block at the represented location.

Returns
Block at the represented location

Definition at line 81 of file Location.java.

References org.bukkit.World.getBlockAt().

int org.bukkit.Location.getBlockX ( )

Gets the floored value of the X component, indicating the block that this location is contained with.

Returns
block X

Definition at line 109 of file Location.java.

References org.bukkit.Location.locToBlock().

int org.bukkit.Location.getBlockY ( )

Gets the floored value of the Y component, indicating the block that this location is contained with.

Returns
block y

Definition at line 137 of file Location.java.

References org.bukkit.Location.locToBlock().

int org.bukkit.Location.getBlockZ ( )

Gets the floored value of the Z component, indicating the block that this location is contained with.

Returns
block z

Definition at line 165 of file Location.java.

References org.bukkit.Location.locToBlock().

Chunk org.bukkit.Location.getChunk ( )

Gets the chunk at the represented location.

Returns
Chunk at the represented location

Definition at line 72 of file Location.java.

References org.bukkit.World.getChunkAt().

Vector org.bukkit.Location.getDirection ( )

Gets a Vector pointing in the direction that this Location is facing.

Returns
Vector

Definition at line 210 of file Location.java.

References org.bukkit.Location.getPitch(), org.bukkit.Location.getYaw(), org.bukkit.util.Vector.setX(), org.bukkit.util.Vector.setY(), and org.bukkit.util.Vector.setZ().

Referenced by org.bukkit.util.BlockIterator.BlockIterator().

float org.bukkit.Location.getPitch ( )

Gets the pitch of this location.

Returns
Pitch

Definition at line 201 of file Location.java.

Referenced by org.bukkit.Location.getDirection().

double org.bukkit.Location.getX ( )

Gets the x-coordinate of this location.

Returns
x-coordinate

Definition at line 99 of file Location.java.

Referenced by org.bukkit.command.defaults.SpawnpointCommand.execute(), and org.bukkit.command.defaults.TeleportCommand.execute().

double org.bukkit.Location.getY ( )

Gets the y-coordinate of this location.

Returns
y-coordinate

Definition at line 127 of file Location.java.

Referenced by org.bukkit.command.defaults.SpawnpointCommand.execute(), and org.bukkit.command.defaults.TeleportCommand.execute().

float org.bukkit.Location.getYaw ( )

Gets the yaw of this location.

Returns
Yaw

Definition at line 183 of file Location.java.

Referenced by org.bukkit.Location.getDirection().

double org.bukkit.Location.getZ ( )

Gets the z-coordinate of this location.

Returns
z-coordinate

Definition at line 155 of file Location.java.

Referenced by org.bukkit.command.defaults.SpawnpointCommand.execute(), and org.bukkit.command.defaults.TeleportCommand.execute().

int org.bukkit.Location.hashCode ( )

Definition at line 447 of file Location.java.

double org.bukkit.Location.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.

See Also
Vector
Returns
the magnitude

Definition at line 336 of file Location.java.

double org.bukkit.Location.lengthSquared ( )

Gets the magnitude of the location squared.

Not world-aware and orientation independent.

See Also
Vector
Returns
the magnitude

Definition at line 347 of file Location.java.

static int org.bukkit.Location.locToBlock ( double  loc)
static

Safely converts a double (location coordinate) to an int (block coordinate)

Parameters
locPrecise coordinate
Returns
Block coordinate

Definition at line 488 of file Location.java.

References org.bukkit.util.NumberConversions.floor().

Referenced by org.bukkit.Location.getBlockX(), org.bukkit.Location.getBlockY(), and org.bukkit.Location.getBlockZ().

Location org.bukkit.Location.multiply ( double  m)

Performs scalar multiplication, multiplying all components with a scalar.

Not world-aware.

Parameters
mThe factor
See Also
Vector
Returns
the same location

Definition at line 395 of file Location.java.

void org.bukkit.Location.setPitch ( float  pitch)

Sets the pitch of this location.

Parameters
pitchNew pitch

Definition at line 192 of file Location.java.

void org.bukkit.Location.setWorld ( World  world)

Sets the world that this location resides in.

Parameters
worldNew world that this location resides in

Definition at line 54 of file Location.java.

void org.bukkit.Location.setX ( double  x)

Sets the x-coordinate of this location.

Parameters
xX-coordinate

Definition at line 90 of file Location.java.

Referenced by org.bukkit.command.defaults.TeleportCommand.execute().

void org.bukkit.Location.setY ( double  y)

Sets the y-coordinate of this location.

Parameters
yy-coordinate

Definition at line 118 of file Location.java.

Referenced by org.bukkit.command.defaults.TeleportCommand.execute().

void org.bukkit.Location.setYaw ( float  yaw)

Sets the yaw of this location.

Parameters
yawNew yaw

Definition at line 174 of file Location.java.

void org.bukkit.Location.setZ ( double  z)

Sets the z-coordinate of this location.

Parameters
zz-coordinate

Definition at line 146 of file Location.java.

Referenced by org.bukkit.command.defaults.TeleportCommand.execute().

Location org.bukkit.Location.subtract ( Location  vec)

Subtracts the location by another.

See Also
Vector
Parameters
vecThe other location
Returns
the same location
Exceptions
IllegalArgumentExceptionfor differing worlds

Definition at line 283 of file Location.java.

References org.bukkit.Location.getWorld().

Location org.bukkit.Location.subtract ( Vector  vec)

Subtracts the location by a vector.

See Also
Vector
Parameters
vecThe vector to use
Returns
the same location

Definition at line 301 of file Location.java.

References org.bukkit.util.Vector.getX(), org.bukkit.util.Vector.getY(), and org.bukkit.util.Vector.getZ().

Location org.bukkit.Location.subtract ( double  x,
double  y,
double  z 
)

Subtracts the location by another.

Not world-aware and orientation independent.

See Also
Vector
Parameters
xX coordinate
yY coordinate
zZ coordinate
Returns
the same location

Definition at line 318 of file Location.java.

String org.bukkit.Location.toString ( )

Definition at line 460 of file Location.java.

Vector org.bukkit.Location.toVector ( )

Constructs a new Vector based on this Location.

Returns
New Vector containing the coordinates represented by this Location

Definition at line 469 of file Location.java.

Referenced by org.bukkit.util.BlockIterator.BlockIterator().

Location org.bukkit.Location.zero ( )

Zero this location's components.

Not world-aware.

See Also
Vector
Returns
the same location

Definition at line 408 of file Location.java.


The documentation for this class was generated from the following file: