Class Location

java.lang.Object
com.sk89q.worldedit.util.Location

public class Location extends Object
Represents a location in a world with has a direction.

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 Summary

    Constructors
    Constructor
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
    Get the rounded X component of the position vector.
    int
    Get the rounded Y component of the position vector.
    int
    Get the rounded Z component of the position vector.
    Get the direction vector.
    Get the direction as a Direction.
    Get the extent.
    float
    Get the pitch in degrees.
    double
    Get the X component of the position vector.
    double
    Get the Y component of the position vector.
    float
    Get the yaw in degrees.
    double
    Get the Z component of the position vector.
    int
     
    setDirection(float yaw, float pitch)
    Create a clone of this object with the given yaw and pitch.
    setDirection(Vector3 direction)
    Create a clone of this object with the given direction.
    setExtent(Extent extent)
    Create a clone of this object with the given extent.
    setPitch(float pitch)
    Create a clone of this object with the given pitch.
    setPosition(Vector3 position)
    Return a copy of this object with the position set to the given value.
    setX(double x)
    Return a copy of this object with the X component of the new object set to the given value.
    setY(double y)
    Return a copy of this object with the Y component of the new object set to the given value.
    setYaw(float yaw)
    Create a clone of this object with the given yaw.
    setZ(double z)
    Return a copy of this object with the Z component of the new object set to the given value.
    Get a Vector3 form of this location's position.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Location

      public Location(Extent extent)
      Create a new instance in the given extent at 0, 0, 0 with a direction vector of 0, 0, 0.
      Parameters:
      extent - the extent
    • Location

      public 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.
      Parameters:
      extent - the extent
      x - the X coordinate
      y - the Y coordinate
      z - the Z coordinate
    • Location

      public 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.
      Parameters:
      extent - the extent
      position - the position vector
    • Location

      public 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.
      Parameters:
      extent - the extent
      x - the X coordinate
      y - the Y coordinate
      z - the Z coordinate
      direction - the direction vector
    • Location

      public 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.
      Parameters:
      extent - the extent
      x - the X coordinate
      y - the Y coordinate
      z - the Z coordinate
      yaw - the yaw, in degrees
      pitch - the pitch, in degrees
    • Location

      public 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.
      Parameters:
      extent - the extent
      position - the position vector
      direction - the direction vector
    • Location

      public 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.
      Parameters:
      extent - the extent
      position - the position vector
      yaw - the yaw, in degrees
      pitch - the pitch, in degrees
  • Method Details

    • getExtent

      public Extent getExtent()
      Get the extent.
      Returns:
      the extent
    • setExtent

      public Location setExtent(Extent extent)
      Create a clone of this object with the given extent.
      Parameters:
      extent - the new extent
      Returns:
      the new instance
    • getYaw

      public float getYaw()
      Get the yaw in degrees.
      Returns:
      the yaw in degrees
    • setYaw

      public Location setYaw(float yaw)
      Create a clone of this object with the given yaw.
      Parameters:
      yaw - the new yaw
      Returns:
      the new instance
    • getPitch

      public float getPitch()
      Get the pitch in degrees.
      Returns:
      the pitch in degrees
    • setPitch

      public Location setPitch(float pitch)
      Create a clone of this object with the given pitch.
      Parameters:
      pitch - the new yaw
      Returns:
      the new instance
    • setDirection

      public Location setDirection(float yaw, float pitch)
      Create a clone of this object with the given yaw and pitch.
      Parameters:
      yaw - the new yaw
      pitch - the new pitch
      Returns:
      the new instance
    • getDirection

      public Vector3 getDirection()
      Get the direction vector.
      Returns:
      the direction vector
    • getDirectionEnum

      public Direction getDirectionEnum()
      Get the direction as a Direction.
      Returns:
      The direction
    • setDirection

      public Location setDirection(Vector3 direction)
      Create a clone of this object with the given direction.
      Parameters:
      direction - the new direction
      Returns:
      the new instance
    • toVector

      public Vector3 toVector()
      Get a Vector3 form of this location's position.
      Returns:
      a vector
    • getX

      public double getX()
      Get the X component of the position vector.
      Returns:
      the X component
    • getBlockX

      public int getBlockX()
      Get the rounded X component of the position vector.
      Returns:
      the rounded X component
    • setX

      public Location setX(double x)
      Return a copy of this object with the X component of the new object set to the given value.
      Parameters:
      x - the new value for the X component
      Returns:
      a new immutable instance
    • getY

      public double getY()
      Get the Y component of the position vector.
      Returns:
      the Y component
    • getBlockY

      public int getBlockY()
      Get the rounded Y component of the position vector.
      Returns:
      the rounded Y component
    • setY

      public Location setY(double y)
      Return a copy of this object with the Y component of the new object set to the given value.
      Parameters:
      y - the new value for the Y component
      Returns:
      a new immutable instance
    • getZ

      public double getZ()
      Get the Z component of the position vector.
      Returns:
      the Z component
    • getBlockZ

      public int getBlockZ()
      Get the rounded Z component of the position vector.
      Returns:
      the rounded Z component
    • setZ

      public Location setZ(double z)
      Return a copy of this object with the Z component of the new object set to the given value.
      Parameters:
      z - the new value for the Y component
      Returns:
      a new immutable instance
    • setPosition

      public Location setPosition(Vector3 position)
      Return a copy of this object with the position set to the given value.
      Parameters:
      position - The new position
      Returns:
      a new immutable instance
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object