Record Class BlockVec

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

public record BlockVec(int blockX, int blockY, int blockZ) 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.

  • Field Details

    • ZERO

      public static final BlockVec ZERO
    • ONE

      public static final BlockVec ONE
    • SECTION

      public static final BlockVec SECTION
  • Constructor Details

    • BlockVec

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

      public BlockVec(Point point)
    • BlockVec

      public BlockVec(int value)
    • BlockVec

      public BlockVec(double value)
    • BlockVec

      public BlockVec(int blockX, int blockY, int blockZ)
      Creates an instance of a BlockVec record class.
      Parameters:
      blockX - the value for the blockX record component
      blockY - the value for the blockY record component
      blockZ - the value for the blockZ record component
  • Method Details

    • x

      public double x()
      Description copied from interface: Point
      Gets the X coordinate.
      Specified by:
      x in interface Point
      Returns:
      the X coordinate
    • y

      public double y()
      Description copied from interface: Point
      Gets the Y coordinate.
      Specified by:
      y in interface Point
      Returns:
      the Y coordinate
    • z

      public double z()
      Description copied from interface: Point
      Gets the Z coordinate.
      Specified by:
      z in interface Point
      Returns:
      the Z coordinate
    • withX

      public Point withX(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

      public 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) public BlockVec withBlockX(int x)
    • withY

      public Point withY(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

      public 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) public BlockVec withBlockY(int y)
    • withZ

      public Point withZ(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

      public 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) public BlockVec withBlockZ(int z)
    • add

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      @Contract(pure=true) public BlockVec mul(BlockVec blockVec)
    • mul

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

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

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

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

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

      @Contract(pure=true) public BlockVec div(BlockVec blockVec)
    • div

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

      @Contract(pure=true) public BlockVec div(int value)
    • relative

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

      @Contract(pure=true) public BlockVec neg()
    • abs

      @Contract(pure=true) public BlockVec abs()
    • min

      @Contract(pure=true) public Point min(Point point)
    • min

      @Contract(pure=true) public BlockVec min(BlockVec point)
    • min

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

      @Contract(pure=true) public BlockVec min(int value)
    • max

      @Contract(pure=true) public Point max(Point point)
    • max

      @Contract(pure=true) public BlockVec max(BlockVec point)
    • max

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

      @Contract(pure=true) public BlockVec max(int value)
    • samePoint

      @Contract(pure=true) public boolean samePoint(int x, int y, int z)
    • samePoint

      @Contract(pure=true) public boolean samePoint(BlockVec blockVec)
    • 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.
    • blockX

      public int blockX()
      Returns the value of the blockX record component.
      Specified by:
      blockX in interface Point
      Returns:
      the value of the blockX record component
    • blockY

      public int blockY()
      Returns the value of the blockY record component.
      Specified by:
      blockY in interface Point
      Returns:
      the value of the blockY record component
    • blockZ

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