Class LocationUtil

java.lang.Object
nl.pim16aap2.animatedarchitecture.core.util.LocationUtil

public final class LocationUtil extends Object
Utility class for operations related to locations (and chunks).
  • Method Details

    • getChunkId

      public static long getChunkId(Vector3Di position)
      Gets the ID of the chunk associated with a position.

      The upper 32 bits store the x-coordinate of the chunk, and the lower 32 bits store the z coordinate.

      Parameters:
      position - The position from which to retrieve the chunk.
      Returns:
      The ID of the chunk.
    • getChunkId

      public static long getChunkId(Vector2Di chunkCoordinates)
      Gets the ID of the chunk from its coordinates.

      The upper 32 bits store the x-coordinate of the chunk, and the lower 32 bits store the z coordinate.

      Parameters:
      chunkCoordinates - The coordinates of the chunk.
      Returns:
      The ID of the chunk.
    • getChunkId

      public static long getChunkId(int chunkX, int chunkZ)
      Gets the ID of the chunk from its coordinates.

      The upper 32 bits store the x-coordinate of the chunk, and the lower 32 bits store the z coordinate.

      Parameters:
      chunkX - The x-coordinate of the chunk.
      chunkZ - The z-coordinate of the chunk.
      Returns:
      The ID of the chunk.
    • getChunkFromId

      public static Vector2Di getChunkFromId(long chunkId)
      Retrieves the chunk coordinates from the chunk's ID. See getChunkId(Vector2Di).
      Parameters:
      chunkId - The ID of the chunk.
      Returns:
      The x/z coordinates of the chunk.
    • getChunkCoords

      public static Vector2Di getChunkCoords(Vector3Di position)
      Gets the chunk coordinates of a position.
      Parameters:
      position - The position.
      Returns:
      The chunk coordinates.
    • simpleChunkSpaceLocationHash

      public static int simpleChunkSpaceLocationHash(int x, int y, int z)
      Gets the 'simple' hash of a location in chunk-space. 'simple' here refers to the fact that the world of this location will not be taken into account.
      Parameters:
      x - The x-coordinate of the location.
      y - The z-coordinate of the location.
      z - The z-coordinate of the location.
      Returns:
      The simple hash of the location in chunk-space.