Package net.risingworld.api.utils
Class Utils.ChunkUtils
java.lang.Object
net.risingworld.api.utils.Utils.ChunkUtils
- Enclosing class:
Utils
Chunk related functions, including conversion of global positions to
chunk/block positions and vice versa.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final float
Inverse x size of a chunk (1.0 / size)static final float
Inverse y size of a chunk (1.0 / size)static final float
Inverse z size of a chunk (1.0 / size)static final int
Horizontal (x) size of a chunk (amount of blocks)static final int
Vertical (y) size of a chunk (amount of blocks)static final int
Horizontal (z) size of a chunk (amount of blocks) -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Vector3i
getBlockPosition
(Vector3f globalPosition, Vector3i chunkPosition) Calculates a block position (within the provided chunk position)static int
getBlockPositionX
(float x, int chunkPositionX) Calculates the x block position within a given chunk position.static int
getBlockPositionY
(float y, int chunkPositionY) Calculates the y block position within a given chunk position.static int
getBlockPositionZ
(float z, int chunkPositionZ) Calculates the z block position within a given chunk position.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 providedVector3i's
.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 providedVector3i's
.static Vector3i
getChunkPosition
(float x, float y, float z) Calculates a chunk offset from a given global position and stores the result in aVector3i
.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 providedVector3i
.static Vector3i
getChunkPosition
(Vector3f globalPosition) Calculates a chunk offset from a given global position and stores the result in aVector3i
.static Vector3i
getChunkPosition
(Vector3f globalPosition, Vector3i storeTo) Calculates a chunk offset from a given global position and stores the result in the providedVector3i
.static int
getChunkPositionX
(float x) Calculates the x chunk offset from a given global position (x).static int
getChunkPositionY
(float y) Calculates the y chunk offset from a given global position (y).static int
getChunkPositionZ
(float z) Calculates the z chunk offset from a given global position (z).static Vector3i
getGlobalBlockPosition
(int cx, int cy, int cz, int bx, int by, int bz) static Vector3i
getGlobalBlockPosition
(Vector3i chunkPosition, Vector3i blockPosition) static Vector3f
getGlobalPosition
(Vector3i chunkPosition, Vector3i blockPosition) static Vector3f
getGlobalPosition
(Vector3i chunkPosition, Vector3i blockPosition, Vector3f storeTo) static float
getRelativePositionX
(float x, int cx) static float
getRelativePositionY
(float y, int cy) static float
getRelativePositionZ
(float z, int cz)
-
Field Details
-
CHUNK_SIZE_X
public static final int CHUNK_SIZE_XHorizontal (x) size of a chunk (amount of blocks) -
CHUNK_SIZE_Y
public static final int CHUNK_SIZE_YVertical (y) size of a chunk (amount of blocks) -
CHUNK_SIZE_Z
public static final int CHUNK_SIZE_ZHorizontal (z) size of a chunk (amount of blocks) -
CHUNK_INV_SIZE_X
public static final float CHUNK_INV_SIZE_XInverse x size of a chunk (1.0 / size) -
CHUNK_INV_SIZE_Y
public static final float CHUNK_INV_SIZE_YInverse y size of a chunk (1.0 / size) -
CHUNK_INV_SIZE_Z
public static final float CHUNK_INV_SIZE_ZInverse z size of a chunk (1.0 / size)
-
-
Constructor Details
-
ChunkUtils
public ChunkUtils()
-
-
Method Details
-
getChunkPosition
Calculates a chunk offset from a given global position and stores the result in aVector3i
.- Parameters:
globalPosition
- the global position.- Returns:
- a new
Vector3i
containing the chunk offset.
-
getChunkPosition
Calculates a chunk offset from a given global position and stores the result in the providedVector3i
.- Parameters:
globalPosition
- the global position.storeTo
- theVector3i
you want to store the result in.- Returns:
- the
Vector3i
containing the chunk offset.
-
getChunkPosition
Calculates a chunk offset from a given global position and stores the result in aVector3i
.- 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
Calculates a chunk offset from a given global position and stores the result in the providedVector3i
.- Parameters:
x
- the global x position.y
- the global y position.z
- the global z position.storeTo
- theVector3i
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 providedVector3i'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 providedVector3i'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
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, seegetChunkPositionX(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, seegetChunkPositionY(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, seegetChunkPositionZ(float)
- Returns:
- the z block position.
-
getGlobalPosition
-
getGlobalPosition
-
getGlobalBlockPosition
-
getGlobalBlockPosition
-