Record Class BlockPos

java.lang.Object
java.lang.Record
fr.fidorial.world.BlockPos
Record Components:
x - the block X coordinate
y - the block Y coordinate
z - the block Z coordinate

public record BlockPos(int x, int y, int z) extends Record
The integer coordinates of a block, independent of any world.
Since:
0.1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockPos(int x, int y, int z)
    Creates an instance of a BlockPos record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the position of the chunk holding this block.
    int
    Returns the X coordinate of the chunk holding this block.
    int
    Returns the Z coordinate of the chunk holding this block.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the X coordinate of this block inside its chunk, 0 to 15.
    int
    Returns the Z coordinate of this block inside its chunk, 0 to 15.
    offset(int dx, int dy, int dz)
    Returns this position moved by the given amounts.
    Returns the position of the neighbouring block on the given side.
    final String
    Returns a string representation of this record class.
    int
    x()
    Returns the value of the x record component.
    int
    y()
    Returns the value of the y record component.
    int
    z()
    Returns the value of the z record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BlockPos

      public BlockPos(int x, int y, int z)
      Creates an instance of a BlockPos 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
  • Method Details

    • relative

      public BlockPos relative(BlockFace face)
      Returns the position of the neighbouring block on the given side.
      Parameters:
      face - the side to step towards
      Returns:
      the position of the neighbouring block on the given side
      Since:
      0.1.0
    • offset

      public BlockPos offset(int dx, int dy, int dz)
      Returns this position moved by the given amounts.
      Parameters:
      dx - the offset on the X axis
      dy - the offset on the Y axis
      dz - the offset on the Z axis
      Returns:
      this position moved by the given amounts
      Since:
      0.1.0
    • chunkX

      public int chunkX()
      Returns the X coordinate of the chunk holding this block.
      Returns:
      the X coordinate of the chunk holding this block
      Since:
      0.1.0
    • chunkZ

      public int chunkZ()
      Returns the Z coordinate of the chunk holding this block.
      Returns:
      the Z coordinate of the chunk holding this block
      Since:
      0.1.0
    • localX

      public int localX()
      Returns the X coordinate of this block inside its chunk, 0 to 15.
      Returns:
      the X coordinate of this block inside its chunk, 0 to 15
      Since:
      0.1.0
    • localZ

      public int localZ()
      Returns the Z coordinate of this block inside its chunk, 0 to 15.
      Returns:
      the Z coordinate of this block inside its chunk, 0 to 15
      Since:
      0.1.0
    • chunk

      public ChunkPos chunk()
      Returns the position of the chunk holding this block.
      Returns:
      the position of the chunk holding this block
      Since:
      0.1.0
    • 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 the compare method from their corresponding wrapper classes.
      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 int x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public int y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • z

      public int z()
      Returns the value of the z record component.
      Returns:
      the value of the z record component