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
FieldsModifier and TypeFieldDescriptionstatic final floatInverse x size of a chunk (1.0 / size)static final floatInverse y size of a chunk (1.0 / size)static final floatInverse z size of a chunk (1.0 / size)static final intHorizontal (x) size of a chunk (amount of blocks)static final intVertical (y) size of a chunk (amount of blocks)static final intHorizontal (z) size of a chunk (amount of blocks) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Vector3igetBlockPosition(Vector3f globalPosition, Vector3i chunkPosition) Calculates a block position (within the provided chunk position)static intgetBlockPositionX(float x, int chunkPositionX) Calculates the x block position within a given chunk position.static intgetBlockPositionY(float y, int chunkPositionY) Calculates the y block position within a given chunk position.static intgetBlockPositionZ(float z, int chunkPositionZ) Calculates the z block position within a given chunk position.static voidgetChunkAndBlockPosition(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 voidgetChunkAndBlockPosition(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 Vector3igetChunkPosition(float x, float y, float z) Calculates a chunk offset from a given global position and stores the result in aVector3i.static Vector3igetChunkPosition(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 Vector3igetChunkPosition(Vector3f globalPosition) Calculates a chunk offset from a given global position and stores the result in aVector3i.static Vector3igetChunkPosition(Vector3f globalPosition, Vector3i storeTo) Calculates a chunk offset from a given global position and stores the result in the providedVector3i.static intgetChunkPositionX(float x) Calculates the x chunk offset from a given global position (x).static intgetChunkPositionY(float y) Calculates the y chunk offset from a given global position (y).static intgetChunkPositionZ(float z) Calculates the z chunk offset from a given global position (z).static Vector3igetGlobalBlockPosition(int cx, int cy, int cz, int bx, int by, int bz) static Vector3igetGlobalBlockPosition(Vector3i chunkPosition, Vector3i blockPosition) static Vector3fgetGlobalPosition(Vector3i chunkPosition, Vector3i blockPosition) static Vector3fgetGlobalPosition(Vector3i chunkPosition, Vector3i blockPosition, Vector3f storeTo) static floatgetRelativePositionX(float x, int cx) static floatgetRelativePositionY(float y, int cy) static floatgetRelativePositionZ(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
Vector3icontaining 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- theVector3iyou want to store the result in.- Returns:
- the
Vector3icontaining 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
Vector3icontaining 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- theVector3iyou want to store the result in.- Returns:
- the
Vector3icontaining 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-Vector3iyou want to store the chunk offset in.blockPositionStore-Vector3iyou 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-Vector3iyou want to store the chunk offset in.blockPositionStore-Vector3iyou 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
Vector3icontaining 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
-