Interface Location

All Superinterfaces:
FinePosition, Position

public sealed interface Location extends FinePosition
A fine position in a given world, along with a rotation.
Since:
0.1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    default double
    Computes the squared distance between this location and another one in the same world.
    static Location
    of(World world, double x, double y, double z)
    Creates a location at the given coordinates, facing a yaw and pitch of 0.
    static Location
    of(World world, double x, double y, double z, float yaw, float pitch)
    Creates a location at the given coordinates and rotation.
    offset(double x, double y, double z)
    Moves this position along all three axes.
    offset(int x, int y, int z)
    Moves this position along all three axes by a whole number of blocks.
    offsetX(double x)
    Moves this position along the X axis.
    offsetX(int x)
    Moves this position along the X axis by a whole number of blocks.
    offsetY(double y)
    Moves this position along the Y axis.
    offsetY(int y)
    Moves this position along the Y axis by a whole number of blocks.
    offsetZ(double z)
    Moves this position along the Z axis.
    offsetZ(int z)
    Moves this position along the Z axis by a whole number of blocks.
    float
    Gets the pitch of this location, which is its vertical rotation.
    Moves this position by one block in the direction of the given face.
    relative(BlockFace face, int distance)
    Moves this position by the defined distance in the direction of the given face.
    Gets the rotation of this location.
    with(double x, double y, double z)
    Copies this position with different coordinates.
    with(double x, double y, double z, float yaw, float pitch)
    Copies this location with different coordinates and rotation, in the same world.
    with(int x, int y, int z)
    Copies this position with different whole coordinates.
    withRotation(float yaw, float pitch)
    Copies this location with a different rotation, at the same coordinates and in the same world.
    Copies this location with a different rotation, at the same coordinates and in the same world.
    withX(double x)
    Copies this position with a different X coordinate.
    withX(int x)
    Copies this position with a different whole X coordinate.
    withY(double y)
    Copies this position with a different Y coordinate.
    withY(int y)
    Copies this position with a different whole Y coordinate.
    withZ(double z)
    Copies this position with a different Z coordinate.
    withZ(int z)
    Copies this position with a different whole Z coordinate.
    Gets the world this location is in.
    float
    yaw()
    Gets the yaw of this location, which is its horizontal rotation.

    Methods inherited from interface Position

    blockX, blockY, blockZ, chunk, chunkX, chunkZ, distanceSquared, localX, localZ, toLocation, x, y, z
  • Method Details

    • of

      @Contract(value="_, _, _, _ -> new", pure=true) static Location of(World world, double x, double y, double z)
      Creates a location at the given coordinates, facing a yaw and pitch of 0.
      Parameters:
      world - the world of the location
      x - the X coordinate
      y - the Y coordinate
      z - the Z coordinate
      Returns:
      a new location at the given coordinates, with a yaw and pitch of 0
      Since:
      0.1.0
    • of

      @Contract(value="_, _, _, _, _, _ -> new", pure=true) static Location of(World world, double x, double y, double z, float yaw, float pitch)
      Creates a location at the given coordinates and rotation.
      Parameters:
      world - the world of the location
      x - the X coordinate
      y - the Y coordinate
      z - the Z coordinate
      yaw - the yaw, in degrees
      pitch - the pitch, in degrees
      Returns:
      a new location at the given coordinates and rotation
      Since:
      0.1.0
    • relative

      @Contract(value="_, _ -> new", pure=true) Location relative(BlockFace face, int distance)
      Description copied from interface: Position
      Moves this position by the defined distance in the direction of the given face.
      Specified by:
      relative in interface FinePosition
      Specified by:
      relative in interface Position
      Parameters:
      face - the direction to move towards
      distance - the offset distance
      Returns:
      a new position moved by one block towards the given face
    • relative

      @Contract(value="_ -> new", pure=true) Location relative(BlockFace face)
      Description copied from interface: Position
      Moves this position by one block in the direction of the given face.
      Specified by:
      relative in interface FinePosition
      Specified by:
      relative in interface Position
      Parameters:
      face - the direction to move towards
      Returns:
      a new position moved by one block towards the given face
      See Also:
    • offsetX

      @Contract(value="_ -> new", pure=true) Location offsetX(double x)
      Description copied from interface: Position
      Moves this position along the X axis.
      Specified by:
      offsetX in interface Position
      Parameters:
      x - the amount to add to the X coordinate
      Returns:
      a new position with the given amount added to the X coordinate
    • offsetY

      @Contract(value="_ -> new", pure=true) Location offsetY(double y)
      Description copied from interface: Position
      Moves this position along the Y axis.
      Specified by:
      offsetY in interface Position
      Parameters:
      y - the amount to add to the Y coordinate
      Returns:
      a new position with the given amount added to the Y coordinate
    • offsetZ

      @Contract(value="_ -> new", pure=true) Location offsetZ(double z)
      Description copied from interface: Position
      Moves this position along the Z axis.
      Specified by:
      offsetZ in interface Position
      Parameters:
      z - the amount to add to the Z coordinate
      Returns:
      a new position with the given amount added to the Z coordinate
    • offset

      @Contract(value="_, _, _ -> new", pure=true) Location offset(double x, double y, double z)
      Description copied from interface: Position
      Moves this position along all three axes.
      Specified by:
      offset in interface Position
      Parameters:
      x - the amount to add to the X coordinate
      y - the amount to add to the Y coordinate
      z - the amount to add to the Z coordinate
      Returns:
      a new position with the given amounts added to each coordinate
    • offsetX

      @Contract(value="_ -> new", pure=true) Location offsetX(int x)
      Description copied from interface: Position
      Moves this position along the X axis by a whole number of blocks.
      Specified by:
      offsetX in interface FinePosition
      Specified by:
      offsetX in interface Position
      Parameters:
      x - the amount to add to the X coordinate
      Returns:
      a new position of the same kind with the given amount added to the X coordinate
    • offsetY

      @Contract(value="_ -> new", pure=true) Location offsetY(int y)
      Description copied from interface: Position
      Moves this position along the Y axis by a whole number of blocks.
      Specified by:
      offsetY in interface FinePosition
      Specified by:
      offsetY in interface Position
      Parameters:
      y - the amount to add to the Y coordinate
      Returns:
      a new position of the same kind with the given amount added to the Y coordinate
    • offsetZ

      @Contract(value="_ -> new", pure=true) Location offsetZ(int z)
      Description copied from interface: Position
      Moves this position along the Z axis by a whole number of blocks.
      Specified by:
      offsetZ in interface FinePosition
      Specified by:
      offsetZ in interface Position
      Parameters:
      z - the amount to add to the Z coordinate
      Returns:
      a new position of the same kind with the given amount added to the Z coordinate
    • offset

      @Contract(value="_, _, _ -> new", pure=true) Location offset(int x, int y, int z)
      Description copied from interface: Position
      Moves this position along all three axes by a whole number of blocks.
      Specified by:
      offset in interface FinePosition
      Specified by:
      offset in interface Position
      Parameters:
      x - the amount to add to the X coordinate
      y - the amount to add to the Y coordinate
      z - the amount to add to the Z coordinate
      Returns:
      a new position of the same kind with the given amounts added to each coordinate
    • withX

      @Contract(value="_ -> new", pure=true) Location withX(double x)
      Description copied from interface: Position
      Copies this position with a different X coordinate.
      Specified by:
      withX in interface Position
      Parameters:
      x - the new X coordinate
      Returns:
      a new position with the X coordinate replaced
    • withY

      @Contract(value="_ -> new", pure=true) Location withY(double y)
      Description copied from interface: Position
      Copies this position with a different Y coordinate.
      Specified by:
      withY in interface Position
      Parameters:
      y - the new Y coordinate
      Returns:
      a new position with the Y coordinate replaced
    • withZ

      @Contract(value="_ -> new", pure=true) Location withZ(double z)
      Description copied from interface: Position
      Copies this position with a different Z coordinate.
      Specified by:
      withZ in interface Position
      Parameters:
      z - the new Z coordinate
      Returns:
      a new position with the Z coordinate replaced
    • with

      @Contract(value="_, _, _ -> new", pure=true) Location with(double x, double y, double z)
      Description copied from interface: Position
      Copies this position with different coordinates.
      Specified by:
      with in interface Position
      Parameters:
      x - the new X coordinate
      y - the new Y coordinate
      z - the new Z coordinate
      Returns:
      a new position with all coordinates replaced
    • with

      @Contract(value="_, _, _, _, _ -> new", pure=true) Location with(double x, double y, double z, float yaw, float pitch)
      Copies this location with different coordinates and rotation, in the same world.
      Parameters:
      x - the new X coordinate
      y - the new Y coordinate
      z - the new Z coordinate
      yaw - the new yaw, in degrees
      pitch - the new pitch, in degrees
      Returns:
      a new location in the same world with all coordinates and the rotation replaced
      Since:
      0.1.0
    • withX

      @Contract(value="_ -> new", pure=true) Location withX(int x)
      Description copied from interface: Position
      Copies this position with a different whole X coordinate.
      Specified by:
      withX in interface FinePosition
      Specified by:
      withX in interface Position
      Parameters:
      x - the new X coordinate
      Returns:
      a new position of the same kind with the X coordinate replaced
    • withY

      @Contract(value="_ -> new", pure=true) Location withY(int y)
      Description copied from interface: Position
      Copies this position with a different whole Y coordinate.
      Specified by:
      withY in interface FinePosition
      Specified by:
      withY in interface Position
      Parameters:
      y - the new Y coordinate
      Returns:
      a new position of the same kind with the Y coordinate replaced
    • withZ

      @Contract(value="_ -> new", pure=true) Location withZ(int z)
      Description copied from interface: Position
      Copies this position with a different whole Z coordinate.
      Specified by:
      withZ in interface FinePosition
      Specified by:
      withZ in interface Position
      Parameters:
      z - the new Z coordinate
      Returns:
      a new position of the same kind with the Z coordinate replaced
    • with

      @Contract(value="_, _, _ -> new", pure=true) Location with(int x, int y, int z)
      Description copied from interface: Position
      Copies this position with different whole coordinates.
      Specified by:
      with in interface FinePosition
      Specified by:
      with in interface Position
      Parameters:
      x - the new X coordinate
      y - the new Y coordinate
      z - the new Z coordinate
      Returns:
      a new position of the same kind with all coordinates replaced
    • rotation

      @Contract(value=" -> new", pure=true) Rotation rotation()
      Gets the rotation of this location.
      Returns:
      the yaw and pitch of this location
      Since:
      0.1.0
    • withRotation

      @Contract(value="_ -> new", pure=true) Location withRotation(Rotation rotation)
      Copies this location with a different rotation, at the same coordinates and in the same world.
      Parameters:
      rotation - the new rotation
      Returns:
      a new location at the same coordinates with the rotation replaced
      Since:
      0.1.0
    • withRotation

      @Contract(value="_, _ -> new", pure=true) Location withRotation(float yaw, float pitch)
      Copies this location with a different rotation, at the same coordinates and in the same world.
      Parameters:
      yaw - the new yaw, in degrees
      pitch - the new pitch, in degrees
      Returns:
      a new location at the same coordinates with the rotation replaced
      Since:
      0.1.0
    • world

      @Contract(pure=true) World world()
      Gets the world this location is in.
      Returns:
      the world of this location
      Since:
      0.1.0
    • pitch

      @Contract(pure=true) float pitch()
      Gets the pitch of this location, which is its vertical rotation.
      Returns:
      the pitch of this location, in degrees
      Since:
      0.1.0
    • yaw

      @Contract(pure=true) float yaw()
      Gets the yaw of this location, which is its horizontal rotation.
      Returns:
      the yaw of this location, in degrees
      Since:
      0.1.0
    • distanceSquared

      @Contract(pure=true) default double distanceSquared(Location other)
      Computes the squared distance between this location and another one in the same world.
      Parameters:
      other - the location to measure the distance to
      Returns:
      the squared euclidean distance between this location and another
      Throws:
      IllegalArgumentException - if the other location is in a different world
      Since:
      0.1.0
      See Also: