Class Utils.ChunkUtils

java.lang.Object
net.risingworld.api.utils.Utils.ChunkUtils
Enclosing class:
Utils

public abstract static class Utils.ChunkUtils extends Object
Chunk related functions, including conversion of global positions to chunk/block positions and vice versa.
  • Field Details

    • CHUNK_SIZE_X

      public static final int CHUNK_SIZE_X
      Horizontal (x) size of a chunk (amount of blocks)
    • CHUNK_SIZE_Y

      public static final int CHUNK_SIZE_Y
      Vertical (y) size of a chunk (amount of blocks)
    • CHUNK_SIZE_Z

      public static final int CHUNK_SIZE_Z
      Horizontal (z) size of a chunk (amount of blocks)
    • CHUNK_INV_SIZE_X

      public static final float CHUNK_INV_SIZE_X
      Inverse x size of a chunk (1.0 / size)
    • CHUNK_INV_SIZE_Y

      public static final float CHUNK_INV_SIZE_Y
      Inverse y size of a chunk (1.0 / size)
    • CHUNK_INV_SIZE_Z

      public static final float CHUNK_INV_SIZE_Z
      Inverse z size of a chunk (1.0 / size)
  • Constructor Details

    • ChunkUtils

      public ChunkUtils()
  • Method Details

    • getChunkPosition

      public static Vector3i getChunkPosition(Vector3f globalPosition)
      Calculates a chunk offset from a given global position and stores the result in a Vector3i.
      Parameters:
      globalPosition - the global position.
      Returns:
      a new Vector3i containing the chunk offset.
    • getChunkPosition

      public static Vector3i getChunkPosition(Vector3f globalPosition, Vector3i storeTo)
      Calculates a chunk offset from a given global position and stores the result in the provided Vector3i.
      Parameters:
      globalPosition - the global position.
      storeTo - the Vector3i you want to store the result in.
      Returns:
      the Vector3i containing the chunk offset.
    • getChunkPosition

      public static Vector3i getChunkPosition(float x, float y, float z)
      Calculates a chunk offset from a given global position and stores the result in a Vector3i.
      Parameters:
      x - the global x position.
      y - the global y position.
      z - the global z position.
      Returns:
      a new Vector3i containing the chunk offset.
    • getChunkPosition

      public static Vector3i getChunkPosition(float x, float y, float z, Vector3i storeTo)
      Calculates a chunk offset from a given global position and stores the result in the provided Vector3i.
      Parameters:
      x - the global x position.
      y - the global y position.
      z - the global z position.
      storeTo - the Vector3i you want to store the result in.
      Returns:
      the Vector3i containing the chunk offset.
    • getChunkPositionX

      public static int getChunkPositionX(float x)
      Calculates the x chunk offset from a given global position (x).
      Parameters:
      x - the global x position.
      Returns:
      the x chunk offset.
    • getChunkPositionY

      public static int getChunkPositionY(float y)
      Calculates the y chunk offset from a given global position (y).
      Parameters:
      y - the global y position.
      Returns:
      the y chunk offset.
    • getChunkPositionZ

      public static int getChunkPositionZ(float z)
      Calculates the z chunk offset from a given global position (z).
      Parameters:
      z - the global z position.
      Returns:
      the z chunk offset.
    • getRelativePositionX

      public static float getRelativePositionX(float x, int cx)
    • getRelativePositionY

      public static float getRelativePositionY(float y, int cy)
    • getRelativePositionZ

      public static float getRelativePositionZ(float z, int cz)
    • getChunkAndBlockPosition

      public static void getChunkAndBlockPosition(Vector3f globalPosition, Vector3i chunkPositionStore, Vector3i blockPositionStore)
      Calculates a chunk offset and the according block position (within this chunk) from a given global position and stores the results in the provided Vector3i's.
      Parameters:
      globalPosition - the global position.
      chunkPositionStore - Vector3i you want to store the chunk offset in.
      blockPositionStore - Vector3i you want to store the block position in.
    • getChunkAndBlockPosition

      public static void getChunkAndBlockPosition(float x, float y, float z, Vector3i chunkPositionStore, Vector3i blockPositionStore)
      Calculates a chunk offset and the according block position (within this chunk) from a given global position and stores the results in the provided Vector3i's.
      Parameters:
      x - the global x position.
      y - the global y position.
      z - the global z position.
      chunkPositionStore - Vector3i you want to store the chunk offset in.
      blockPositionStore - Vector3i you want to store the block position in.
    • getBlockPosition

      public static Vector3i getBlockPosition(Vector3f globalPosition, Vector3i chunkPosition)
      Calculates a block position (within the provided chunk position)
      Parameters:
      globalPosition - the global position.
      chunkPosition - the chunk offset.
      Returns:
      a new Vector3i containing the block position within the provided chunk.
    • getBlockPositionX

      public static int getBlockPositionX(float x, int chunkPositionX)
      Calculates the x block position within a given chunk position.
      Parameters:
      x - the global x position.
      chunkPositionX - the x chunk position, see getChunkPositionX(float)
      Returns:
      the x block position.
    • getBlockPositionY

      public static int getBlockPositionY(float y, int chunkPositionY)
      Calculates the y block position within a given chunk position.
      Parameters:
      y - the global y position.
      chunkPositionY - the y chunk position, see getChunkPositionY(float)
      Returns:
      the y block position.
    • getBlockPositionZ

      public static int getBlockPositionZ(float z, int chunkPositionZ)
      Calculates the z block position within a given chunk position.
      Parameters:
      z - the global y position.
      chunkPositionZ - the z chunk position, see getChunkPositionZ(float)
      Returns:
      the z block position.
    • getGlobalPosition

      public static Vector3f getGlobalPosition(Vector3i chunkPosition, Vector3i blockPosition)
    • getGlobalPosition

      public static Vector3f getGlobalPosition(Vector3i chunkPosition, Vector3i blockPosition, Vector3f storeTo)
    • getGlobalBlockPosition

      public static Vector3i getGlobalBlockPosition(Vector3i chunkPosition, Vector3i blockPosition)
    • getGlobalBlockPosition

      public static Vector3i getGlobalBlockPosition(int cx, int cy, int cz, int bx, int by, int bz)