Use chunk size constant instead of magic values

This commit is contained in:
themode 2020-08-19 01:51:22 +02:00
parent 8b30caa8c8
commit c1f520143b

View File

@ -89,8 +89,8 @@ public final class ChunkUtils {
} }
public static short getLocalBlockPosAsShort(int x, int y, int z) { public static short getLocalBlockPosAsShort(int x, int y, int z) {
x = x % 16; x = x % Chunk.CHUNK_SIZE_X;
z = z % 16; z = z % Chunk.CHUNK_SIZE_Z;
return (short) (x << 8 | y << 4 | z); return (short) (x << 8 | y << 4 | z);
} }
@ -196,7 +196,7 @@ public final class ChunkUtils {
*/ */
public static int blockIndexToPositionX(int index, int chunkX) { public static int blockIndexToPositionX(int index, int chunkX) {
int x = (byte) (index & 0xF); int x = (byte) (index & 0xF);
x += 16 * chunkX; x += Chunk.CHUNK_SIZE_X * chunkX;
return x; return x;
} }
@ -219,7 +219,7 @@ public final class ChunkUtils {
*/ */
public static int blockIndexToPositionZ(int index, int chunkZ) { public static int blockIndexToPositionZ(int index, int chunkZ) {
int z = (byte) (index >> 12 & 0xF); int z = (byte) (index >> 12 & 0xF);
z += 16 * chunkZ; z += Chunk.CHUNK_SIZE_Z * chunkZ;
return z; return z;
} }