Record Class ChunkPos

java.lang.Object
java.lang.Record
net.minecraft.world.level.ChunkPos

public record ChunkPos(int x, int z) extends Record
  • Field Details

    • x

      private final int x
      The field for the x record component.
    • z

      private final int z
      The field for the z record component.
    • CODEC

      public static final com.mojang.serialization.Codec<ChunkPos> CODEC
    • STREAM_CODEC

      public static final StreamCodec<io.netty.buffer.ByteBuf, ChunkPos> STREAM_CODEC
    • SAFETY_MARGIN

      private static final int SAFETY_MARGIN
      See Also:
    • INVALID_CHUNK_POS

      public static final long INVALID_CHUNK_POS
      Value representing an absent or invalid chunkpos
    • SAFETY_MARGIN_CHUNKS

      private static final int SAFETY_MARGIN_CHUNKS
    • MAX_COORDINATE_VALUE

      public static final int MAX_COORDINATE_VALUE
    • ZERO

      public static final ChunkPos ZERO
    • COORD_BITS

      private static final long COORD_BITS
      See Also:
    • COORD_MASK

      private static final long COORD_MASK
      See Also:
    • REGION_BITS

      private static final int REGION_BITS
      See Also:
    • REGION_SIZE

      public static final int REGION_SIZE
      See Also:
    • REGION_MASK

      private static final int REGION_MASK
      See Also:
    • REGION_MAX_INDEX

      public static final int REGION_MAX_INDEX
      See Also:
    • HASH_A

      private static final int HASH_A
      See Also:
    • HASH_C

      private static final int HASH_C
      See Also:
    • HASH_Z_XOR

      private static final int HASH_Z_XOR
      See Also:
  • Constructor Details

    • ChunkPos

      public ChunkPos(int x, int z)
      Creates an instance of a ChunkPos record class.
      Parameters:
      x - the value for the x record component
      z - the value for the z record component
  • Method Details

    • containing

      public static ChunkPos containing(BlockPos pos)
    • unpack

      public static ChunkPos unpack(long key)
    • minFromRegion

      public static ChunkPos minFromRegion(int regionX, int regionZ)
    • maxFromRegion

      public static ChunkPos maxFromRegion(int regionX, int regionZ)
    • isValid

      public boolean isValid()
    • isValid

      public static boolean isValid(int x, int z)
    • pack

      public long pack()
    • pack

      public static long pack(int x, int z)
    • pack

      public static long pack(BlockPos pos)
    • getX

      public static int getX(long pos)
    • getZ

      public static int getZ(long pos)
    • hashCode

      public 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
    • hash

      public static int hash(int x, int z)
    • getMiddleBlockX

      public int getMiddleBlockX()
    • getMiddleBlockZ

      public int getMiddleBlockZ()
    • getMinBlockX

      public int getMinBlockX()
    • getMinBlockZ

      public int getMinBlockZ()
    • getMaxBlockX

      public int getMaxBlockX()
    • getMaxBlockZ

      public int getMaxBlockZ()
    • getRegionX

      public int getRegionX()
    • getRegionZ

      public int getRegionZ()
    • getRegionX

      public static int getRegionX(long pos)
    • getRegionZ

      public static int getRegionZ(long pos)
    • getRegionLocalX

      public int getRegionLocalX()
    • getRegionLocalZ

      public int getRegionLocalZ()
    • getBlockAt

      public BlockPos getBlockAt(int x, int y, int z)
    • getBlockX

      public int getBlockX(int offset)
    • getBlockZ

      public int getBlockZ(int offset)
    • getMiddleBlockPosition

      public BlockPos getMiddleBlockPosition(int y)
    • contains

      public boolean contains(BlockPos pos)
    • toString

      public 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
    • getWorldPosition

      public BlockPos getWorldPosition()
    • getChessboardDistance

      public int getChessboardDistance(ChunkPos pos)
    • getChessboardDistance

      public int getChessboardDistance(int x, int z)
    • distanceSquared

      public int distanceSquared(ChunkPos pos)
    • distanceSquared

      public int distanceSquared(long pos)
    • distanceSquared

      private int distanceSquared(int x, int z)
    • rangeClosed

      public static Stream<ChunkPos> rangeClosed(ChunkPos center, int radius)
    • rangeClosed

      public static Stream<ChunkPos> rangeClosed(ChunkPos from, ChunkPos to)
    • 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
    • z

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