Interface Position

All Known Subinterfaces:
BlockPosition, FinePosition
All Known Implementing Classes:
Location

@Experimental @NullMarked public interface Position
Common interface for FinePosition and BlockPosition.

May see breaking changes until Experimental annotation is removed.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BlockPosition
     
    static final FinePosition
     
  • Method Summary

    Modifier and Type
    Method
    Description
    block(int x, int y, int z)
    Creates a position at the coordinates
    block(Location location)
    Creates a position from the location.
    int
    Gets the block x value for this position
    int
    Gets the block x value for this position
    int
    Gets the block x value for this position
    fine(double x, double y, double z)
    Creates a position at the coordinates
    fine(Location location)
    Creates a position from the location.
    boolean
    Checks of this position represents a BlockPosition
    boolean
    Checks if this position represents a FinePosition
    default boolean
    Checks if each component of this position is finite.
    offset(double x, double y, double z)
    Returns a position offset by the specified amounts.
    offset(int x, int y, int z)
    Returns a position offset by the specified amounts.
    Returns the block position of this position or itself if it already is a block position
    default FinePosition
    Returns a new position at the center of the block position this represents
    default Location
    Creates a new location object at this position with the specified world
    default Vector
    Converts this position to a vector
    double
    x()
    Gets the x value for this position
    double
    y()
    Gets the y value for this position
    double
    z()
    Gets the z value for this position
  • Field Details

  • Method Details

    • blockX

      int blockX()
      Gets the block x value for this position
      Returns:
      the block x value
    • blockY

      int blockY()
      Gets the block x value for this position
      Returns:
      the block x value
    • blockZ

      int blockZ()
      Gets the block x value for this position
      Returns:
      the block x value
    • x

      double x()
      Gets the x value for this position
      Returns:
      the x value
    • y

      double y()
      Gets the y value for this position
      Returns:
      the y value
    • z

      double z()
      Gets the z value for this position
      Returns:
      the z value
    • isBlock

      boolean isBlock()
      Checks of this position represents a BlockPosition
      Returns:
      true if block
    • isFine

      boolean isFine()
      Checks if this position represents a FinePosition
      Returns:
      true if fine
    • isFinite

      default boolean isFinite()
      Checks if each component of this position is finite.
    • offset

      Position offset(int x, int y, int z)
      Returns a position offset by the specified amounts.
      Parameters:
      x - x value to offset
      y - y value to offset
      z - z value to offset
      Returns:
      the offset position
    • offset

      FinePosition offset(double x, double y, double z)
      Returns a position offset by the specified amounts.
      Parameters:
      x - x value to offset
      y - y value to offset
      z - z value to offset
      Returns:
      the offset position
    • toCenter

      @Contract(value="-> new", pure=true) default FinePosition toCenter()
      Returns a new position at the center of the block position this represents
      Returns:
      a new center position
    • toBlock

      @Contract(pure=true) BlockPosition toBlock()
      Returns the block position of this position or itself if it already is a block position
      Returns:
      the block position
    • toVector

      @Contract(value="-> new", pure=true) default Vector toVector()
      Converts this position to a vector
      Returns:
      a new vector
    • toLocation

      @Contract(value="_ -> new", pure=true) default Location toLocation(World world)
      Creates a new location object at this position with the specified world
      Parameters:
      world - the world for the location object
      Returns:
      a new location
    • block

      @Contract(value="_, _, _ -> new", pure=true) static BlockPosition block(int x, int y, int z)
      Creates a position at the coordinates
      Parameters:
      x - x coord
      y - y coord
      z - z coord
      Returns:
      a position with those coords
    • block

      @Contract(value="_ -> new", pure=true) static BlockPosition block(Location location)
      Creates a position from the location.
      Parameters:
      location - the location to copy the position of
      Returns:
      a new position at that location
    • fine

      @Contract(value="_, _, _ -> new", pure=true) static FinePosition fine(double x, double y, double z)
      Creates a position at the coordinates
      Parameters:
      x - x coord
      y - y coord
      z - z coord
      Returns:
      a position with those coords
    • fine

      @Contract(value="_ -> new", pure=true) static FinePosition fine(Location location)
      Creates a position from the location.
      Parameters:
      location - the location to copy the position of
      Returns:
      a new position at that location