Record Class BlockVec

java.lang.Object
java.lang.Record
net.minestom.server.coordinate.BlockVec
All Implemented Interfaces:
Point

public record BlockVec(double x, double y, double z) extends Record implements Point
Represents an immutable block position. Usage note: If you accept a block position as an argument to a method, it's usually better to accept a Point rather than a BlockVec to avoid callers continually having to convert.
  • Constructor Details

    • BlockVec

      public BlockVec(double x, double y, double z)
      Creates an instance of a BlockVec record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
      z - the value for the z record component
    • BlockVec

      public BlockVec(int x, int y, int z)
    • BlockVec

      public BlockVec(@NotNull @NotNull Point point)
  • Method Details

    • withX

      @NotNull public @NotNull Point withX(@NotNull @NotNull DoubleUnaryOperator operator)
      Description copied from interface: Point
      Creates a point with a modified X coordinate based on its value.
      Specified by:
      withX in interface Point
      Parameters:
      operator - the operator providing the current X coordinate and returning the new
      Returns:
      a new point
    • withX

      @NotNull public @NotNull Point withX(double x)
      Description copied from interface: Point
      Creates a point with the specified X coordinate.
      Specified by:
      withX in interface Point
      Parameters:
      x - the new X coordinate
      Returns:
      a new point
    • withBlockX

      @Contract(pure=true) @NotNull public @NotNull BlockVec withBlockX(int x)
    • withY

      @NotNull public @NotNull Point withY(@NotNull @NotNull DoubleUnaryOperator operator)
      Description copied from interface: Point
      Creates a point with a modified Y coordinate based on its value.
      Specified by:
      withY in interface Point
      Parameters:
      operator - the operator providing the current Y coordinate and returning the new
      Returns:
      a new point
    • withY

      @NotNull public @NotNull Point withY(double y)
      Description copied from interface: Point
      Creates a point with the specified Y coordinate.
      Specified by:
      withY in interface Point
      Parameters:
      y - the new Y coordinate
      Returns:
      a new point
    • withBlockY

      @Contract(pure=true) @NotNull public @NotNull BlockVec withBlockY(int y)
    • withZ

      @NotNull public @NotNull Point withZ(@NotNull @NotNull DoubleUnaryOperator operator)
      Description copied from interface: Point
      Creates a point with a modified Z coordinate based on its value.
      Specified by:
      withZ in interface Point
      Parameters:
      operator - the operator providing the current Z coordinate and returning the new
      Returns:
      a new point
    • withZ

      @NotNull public @NotNull Point withZ(double z)
      Description copied from interface: Point
      Creates a point with the specified Z coordinate.
      Specified by:
      withZ in interface Point
      Parameters:
      z - the new Z coordinate
      Returns:
      a new point
    • withBlockZ

      @Contract(pure=true) @NotNull public @NotNull BlockVec withBlockZ(int z)
    • add

      @NotNull public @NotNull Point add(double x, double y, double z)
      Specified by:
      add in interface Point
    • add

      @Contract(pure=true) @NotNull public @NotNull BlockVec add(int x, int y, int z)
    • add

      @NotNull public @NotNull Point add(@NotNull @NotNull Point point)
      Specified by:
      add in interface Point
    • add

      @Contract(pure=true) @NotNull public @NotNull BlockVec add(@NotNull @NotNull BlockVec blockVec)
    • add

      @NotNull public @NotNull Point add(double value)
      Specified by:
      add in interface Point
    • add

      @Contract(pure=true) @NotNull public @NotNull BlockVec add(int value)
    • sub

      @NotNull public @NotNull Point sub(double x, double y, double z)
      Specified by:
      sub in interface Point
    • sub

      @Contract(pure=true) @NotNull public @NotNull BlockVec sub(int x, int y, int z)
    • sub

      @NotNull public @NotNull Point sub(@NotNull @NotNull Point point)
      Specified by:
      sub in interface Point
    • sub

      @Contract(pure=true) @NotNull public @NotNull BlockVec sub(@NotNull @NotNull BlockVec blockVec)
    • sub

      @NotNull public @NotNull Point sub(double value)
      Specified by:
      sub in interface Point
    • sub

      @Contract(pure=true) @NotNull public @NotNull BlockVec sub(int value)
    • mul

      @NotNull public @NotNull Point mul(double x, double y, double z)
      Specified by:
      mul in interface Point
    • mul

      @NotNull public @NotNull Point mul(@NotNull @NotNull Point point)
      Specified by:
      mul in interface Point
    • mul

      @NotNull public @NotNull Point mul(double value)
      Specified by:
      mul in interface Point
    • div

      @NotNull public @NotNull Point div(double x, double y, double z)
      Specified by:
      div in interface Point
    • div

      @NotNull public @NotNull Point div(@NotNull @NotNull Point point)
      Specified by:
      div in interface Point
    • div

      @NotNull public @NotNull Point div(double value)
      Specified by:
      div in interface Point
    • relative

      @Contract(pure=true) @NotNull public @NotNull BlockVec relative(@NotNull @NotNull BlockFace face)
      Specified by:
      relative in interface Point
    • asVec

      @Contract(pure=true) @NotNull public @NotNull Vec asVec()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • x

      public double x()
      Returns the value of the x record component.
      Specified by:
      x in interface Point
      Returns:
      the value of the x record component
    • y

      public double y()
      Returns the value of the y record component.
      Specified by:
      y in interface Point
      Returns:
      the value of the y record component
    • z

      public double z()
      Returns the value of the z record component.
      Specified by:
      z in interface Point
      Returns:
      the value of the z record component