fix index out of bounds for blocks at world max height

This commit is contained in:
nossr50
2024-11-25 12:24:39 -08:00
parent 1b6b127ef4
commit 6dd175331c
3 changed files with 13 additions and 4 deletions

View File

@ -102,7 +102,7 @@ public class BitSetChunkStore implements ChunkStore {
}
private static int coordToIndex(int x, int y, int z, int worldMin, int worldMax) {
if (x < 0 || x >= 16 || y < worldMin || y >= worldMax || z < 0 || z >= 16)
if (x < 0 || x >= 16 || y < worldMin || y > worldMax || z < 0 || z >= 16)
throw new IndexOutOfBoundsException(String.format("x: %d y: %d z: %d World Min: %d World Max: %d", x, y, z, worldMin, worldMax));
int yOffset = -worldMin; // Ensures y multiplier remains positive
return (z * 16 + x) + (256 * (y + yOffset));