Make getChunkCoordinate smarter and more efficient

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-09-09 06:57:46 +02:00
parent 6ab94bb778
commit 1c719a2fd7

View File

@ -99,8 +99,8 @@ public final class ChunkUtils {
* @return the chunk X or Z based on the argument * @return the chunk X or Z based on the argument
*/ */
public static int getChunkCoordinate(double xz) { public static int getChunkCoordinate(double xz) {
assert Chunk.CHUNK_SIZE_X == Chunk.CHUNK_SIZE_Z; // Assume chunk horizontal size being 16 (4 bits)
return Math.floorDiv((int) Math.floor(xz), Chunk.CHUNK_SIZE_X); return (int) Math.floor(xz) >> 4;
} }
/** /**