Class Location


public class Location extends Vector3Impl
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, Vector3.hashCode() and equals(Object) are subject to minor differences caused by floating point errors.

  • 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
    • 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
    • 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
    • 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
    • clampY

      public Location clampY(int min, int max)
      Description copied from class: Vector3
      Clamp the Y component.
      Overrides:
      clampY in class Vector3
      Parameters:
      min - the minimum value
      max - the maximum value
      Returns:
      a new vector
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Vector3