Class LocationUtil
java.lang.Object
nl.pim16aap2.animatedarchitecture.core.util.LocationUtil
Utility class for operations related to locations (and chunks).
-
Method Summary
Modifier and TypeMethodDescriptionstatic Vector2DigetChunkCoords(Vector3Di position) Gets the chunk coordinates of a position.static Vector2DigetChunkFromId(long chunkId) Retrieves the chunk coordinates from the chunk's ID.static longgetChunkId(int chunkX, int chunkZ) Gets the ID of the chunk from its coordinates.static longgetChunkId(Vector2Di chunkCoords) Gets the ID of the chunk from its coordinates.static longgetChunkId(Vector3Di position) Gets the ID of the chunk associated with a position.static intsimpleChunkSpaceLocationHash(int x, int y, int z) Gets the 'simple' hash of a location in chunk-space.
-
Method Details
-
getChunkId
Gets the ID of the chunk associated with a position.- Parameters:
position- The position from which to retrieve the chunk.- Returns:
- The ID of the chunk.
-
getChunkId
Gets the ID of the chunk from its coordinates.- Parameters:
chunkCoords- 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
Retrieves the chunk coordinates from the chunk's ID. SeegetChunkId(Vector2Di).- Parameters:
chunkId- The ID of the chunk.- Returns:
- The x/z coordinates of the chunk.
-
getChunkCoords
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.
-