Interface Point

All Known Implementing Classes:
Pos, Vec

public sealed interface Point permits Vec, Pos
Represents a 3D point.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Point
    add(double value)
     
    @NotNull Point
    add(double x, double y, double z)
     
    @NotNull Point
    add(@NotNull Point point)
     
    default int
    Gets the floored value of the X component
    default int
    Gets the floored value of the X component
    default int
    Gets the floored value of the X component
    default int
     
    default int
     
    default double
    distance(double x, double y, double z)
     
    default double
    distance(@NotNull Point point)
    Gets the distance between this point and another.
    default double
    distanceSquared(double x, double y, double z)
     
    default double
    distanceSquared(@NotNull Point point)
    Gets the squared distance between this point and another.
    @NotNull Point
    div(double value)
     
    @NotNull Point
    div(double x, double y, double z)
     
    @NotNull Point
    div(@NotNull Point point)
     
    default boolean
    Checks if the three coordinates x(), y() and z() are equal to 0.
    @NotNull Point
    mul(double value)
     
    @NotNull Point
    mul(double x, double y, double z)
     
    @NotNull Point
    mul(@NotNull Point point)
     
    default @NotNull Point
    relative(@NotNull BlockFace face)
     
    default boolean
    sameBlock(int blockX, int blockY, int blockZ)
     
    default boolean
    sameBlock(@NotNull Point point)
    Checks if two points are in the same block.
    default boolean
    sameChunk(@NotNull Point point)
    Checks if two points are in the same chunk.
    default boolean
    samePoint(double x, double y, double z)
     
    default boolean
    samePoint(@NotNull Point point)
    Checks it two points have similar (x/y/z).
    default int
     
    @NotNull Point
    sub(double value)
     
    @NotNull Point
    sub(double x, double y, double z)
     
    @NotNull Point
    sub(@NotNull Point point)
     
    @NotNull Point
    withX(double x)
    Creates a point with the specified X coordinate.
    @NotNull Point
    withX(@NotNull DoubleUnaryOperator operator)
    Creates a point with a modified X coordinate based on its value.
    @NotNull Point
    withY(double y)
    Creates a point with the specified Y coordinate.
    @NotNull Point
    withY(@NotNull DoubleUnaryOperator operator)
    Creates a point with a modified Y coordinate based on its value.
    @NotNull Point
    withZ(double z)
    Creates a point with the specified Z coordinate.
    @NotNull Point
    withZ(@NotNull DoubleUnaryOperator operator)
    Creates a point with a modified Z coordinate based on its value.
    double
    x()
    Gets the X coordinate.
    double
    y()
    Gets the Y coordinate.
    double
    z()
    Gets the Z coordinate.
  • Method Details

    • x

      @Contract(pure=true) double x()
      Gets the X coordinate.
      Returns:
      the X coordinate
    • y

      @Contract(pure=true) double y()
      Gets the Y coordinate.
      Returns:
      the Y coordinate
    • z

      @Contract(pure=true) double z()
      Gets the Z coordinate.
      Returns:
      the Z coordinate
    • blockX

      @Contract(pure=true) default int blockX()
      Gets the floored value of the X component
      Returns:
      the block X
    • blockY

      @Contract(pure=true) default int blockY()
      Gets the floored value of the X component
      Returns:
      the block X
    • blockZ

      @Contract(pure=true) default int blockZ()
      Gets the floored value of the X component
      Returns:
      the block X
    • chunkX

      @Contract(pure=true) default int chunkX()
    • section

      @Contract(pure=true) @Experimental default int section()
    • chunkZ

      @Contract(pure=true) default int chunkZ()
    • withX

      @Contract(pure=true) @NotNull @NotNull Point withX(@NotNull @NotNull DoubleUnaryOperator operator)
      Creates a point with a modified X coordinate based on its value.
      Parameters:
      operator - the operator providing the current X coordinate and returning the new
      Returns:
      a new point
    • withX

      @Contract(pure=true) @NotNull @NotNull Point withX(double x)
      Creates a point with the specified X coordinate.
      Parameters:
      x - the new X coordinate
      Returns:
      a new point
    • withY

      @Contract(pure=true) @NotNull @NotNull Point withY(@NotNull @NotNull DoubleUnaryOperator operator)
      Creates a point with a modified Y coordinate based on its value.
      Parameters:
      operator - the operator providing the current Y coordinate and returning the new
      Returns:
      a new point
    • withY

      @Contract(pure=true) @NotNull @NotNull Point withY(double y)
      Creates a point with the specified Y coordinate.
      Parameters:
      y - the new Y coordinate
      Returns:
      a new point
    • withZ

      @Contract(pure=true) @NotNull @NotNull Point withZ(@NotNull @NotNull DoubleUnaryOperator operator)
      Creates a point with a modified Z coordinate based on its value.
      Parameters:
      operator - the operator providing the current Z coordinate and returning the new
      Returns:
      a new point
    • withZ

      @Contract(pure=true) @NotNull @NotNull Point withZ(double z)
      Creates a point with the specified Z coordinate.
      Parameters:
      z - the new Z coordinate
      Returns:
      a new point
    • add

      @Contract(pure=true) @NotNull @NotNull Point add(double x, double y, double z)
    • add

      @Contract(pure=true) @NotNull @NotNull Point add(@NotNull @NotNull Point point)
    • add

      @Contract(pure=true) @NotNull @NotNull Point add(double value)
    • sub

      @Contract(pure=true) @NotNull @NotNull Point sub(double x, double y, double z)
    • sub

      @Contract(pure=true) @NotNull @NotNull Point sub(@NotNull @NotNull Point point)
    • sub

      @Contract(pure=true) @NotNull @NotNull Point sub(double value)
    • mul

      @Contract(pure=true) @NotNull @NotNull Point mul(double x, double y, double z)
    • mul

      @Contract(pure=true) @NotNull @NotNull Point mul(@NotNull @NotNull Point point)
    • mul

      @Contract(pure=true) @NotNull @NotNull Point mul(double value)
    • div

      @Contract(pure=true) @NotNull @NotNull Point div(double x, double y, double z)
    • div

      @Contract(pure=true) @NotNull @NotNull Point div(@NotNull @NotNull Point point)
    • div

      @Contract(pure=true) @NotNull @NotNull Point div(double value)
    • relative

      @Contract(pure=true) @NotNull default @NotNull Point relative(@NotNull @NotNull BlockFace face)
    • distanceSquared

      @Contract(pure=true) default double distanceSquared(double x, double y, double z)
    • distanceSquared

      @Contract(pure=true) default double distanceSquared(@NotNull @NotNull Point point)
      Gets the squared distance between this point and another.
      Parameters:
      point - the other point
      Returns:
      the squared distance
    • distance

      @Contract(pure=true) default double distance(double x, double y, double z)
    • distance

      @Contract(pure=true) default double distance(@NotNull @NotNull Point point)
      Gets the distance between this point 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 vector'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.
      Parameters:
      point - the other point
      Returns:
      the distance
    • samePoint

      default boolean samePoint(double x, double y, double z)
    • samePoint

      default boolean samePoint(@NotNull @NotNull Point point)
      Checks it two points have similar (x/y/z).
      Parameters:
      point - the point to compare
      Returns:
      true if the two positions are similar
    • isZero

      default boolean isZero()
      Checks if the three coordinates x(), y() and z() are equal to 0.
      Returns:
      true if the three coordinates are zero
    • sameChunk

      default boolean sameChunk(@NotNull @NotNull Point point)
      Checks if two points are in the same chunk.
      Parameters:
      point - the point to compare to
      Returns:
      true if 'this' is in the same chunk as point
    • sameBlock

      default boolean sameBlock(int blockX, int blockY, int blockZ)
    • sameBlock

      default boolean sameBlock(@NotNull @NotNull Point point)
      Checks if two points are in the same block.
      Parameters:
      point - the point to compare to
      Returns:
      true if 'this' is in the same block as point