Class CoordConversionUtils

java.lang.Object
net.minestom.server.coordinate.CoordConversionUtils

public final class CoordConversionUtils extends Object
  • Constructor Details

    • CoordConversionUtils

      public CoordConversionUtils()
  • Method Details

    • globalToChunk

      public static int globalToChunk(double xz)
    • globalToChunk

      public static int globalToChunk(int xz)
    • globalToSection

      public static int globalToSection(int xyz)
    • chunkIndex

      public static long chunkIndex(int chunkX, int chunkZ)
      Gets the chunk index of chunk coordinates.

      Used when you want to store a chunk somewhere without using a reference to the whole object (as this can lead to memory leaks).

      Parameters:
      chunkX - the chunk X
      chunkZ - the chunk Z
      Returns:
      a number storing the chunk X and Z
    • chunkIndex

      public static long chunkIndex(@NotNull @NotNull Point point)
    • chunkIndexToChunkX

      public static int chunkIndexToChunkX(long index)
      Converts a chunk index to its chunk X position.
      Parameters:
      index - the chunk index computed by chunkIndex(int, int)
      Returns:
      the chunk X based on the index
    • chunkIndexToChunkZ

      public static int chunkIndexToChunkZ(long index)
      Converts a chunk index to its chunk Z position.
      Parameters:
      index - the chunk index computed by chunkIndex(int, int)
      Returns:
      the chunk Z based on the index
    • blockIndex

      public static int blockIndex(int x, int y, int z)
      Gets the block index of a position.
      Parameters:
      x - the block X
      y - the block Y
      z - the block Z
      Returns:
      an index which can be used to store and retrieve later data linked to a block position
    • blockIndexToChunkPositionX

      public static int blockIndexToChunkPositionX(int index)
      Converts a block index to a chunk position X.
      Parameters:
      index - an index computed from blockIndex(int, int, int)
      Returns:
      the chunk position X (O-15) of the specified index
    • blockIndexToChunkPositionY

      public static int blockIndexToChunkPositionY(int index)
      Converts a block index to a chunk position Y.
      Parameters:
      index - an index computed from blockIndex(int, int, int)
      Returns:
      the chunk position Y of the specified index
    • blockIndexToChunkPositionZ

      public static int blockIndexToChunkPositionZ(int index)
      Converts a block index to a chunk position Z.
      Parameters:
      index - an index computed from blockIndex(int, int, int)
      Returns:
      the chunk position Z (O-15) of the specified index
    • blockIndexToGlobal

      @NotNull public static @NotNull Point blockIndexToGlobal(int index, int chunkX, int chunkZ)
      Parameters:
      index - an index computed from blockIndex(int, int, int)
      chunkX - the chunk X
      chunkZ - the chunk Z
      Returns:
      the instance position of the block located in index
    • globalToSectionRelative

      public static int globalToSectionRelative(int xyz)
    • chunkToRegion

      public static int chunkToRegion(int chunkCoordinate)
    • chunkToRegionLocal

      public static int chunkToRegionLocal(int chunkCoordinate)
    • floorSection

      public static int floorSection(int coordinate)
    • ceilSection

      public static int ceilSection(int coordinate)