Skip to content

Commit dd64534

Browse files
committed
Fix index out of bounds when entity Y outside the 0-255 range.
1 parent cd1bb22 commit dd64534

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/io/totemo/ec/ChunkCount.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public ChunkCount(Chunk chunk) {
2020
for (Entity entity : chunk.getEntities()) {
2121
Location loc = entity.getLocation();
2222
int boxIndex = loc.getBlockY() / 16;
23+
if (boxIndex < 0) {
24+
boxIndex = 0;
25+
} else if (boxIndex > 15) {
26+
boxIndex = 15;
27+
}
2328
getBox(boxIndex).countEntity(entity);
2429
}
2530
}

0 commit comments

Comments
 (0)