9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00

fix boundary of optimize random tick

This commit is contained in:
hayanesuru
2025-06-21 02:01:56 +09:00
parent 91a911a60f
commit 5311ae81c6

View File

@@ -85,7 +85,7 @@ public final class RandomTickSystem {
if (chunk4 != null) tickBlock(world, chunk4, random);
}
for (k = queue.size(); j < k; j++) {
LevelChunk chunk = getChunk(world, queueRaw[j]);
final LevelChunk chunk = getChunk(world, queueRaw[j]);
if (chunk != null) tickBlock(world, chunk, random);
}
@@ -100,7 +100,11 @@ public final class RandomTickSystem {
}
private static void tickBlock(ServerLevel world, LevelChunk chunk, RandomSource random) {
OptionalLong optionalPos = chunk.leaf$getTickingPos(random.nextInt(chunk.leaf$tickingBlocksCount()));
int count = chunk.leaf$tickingBlocksCount();
if (count == 0) {
return;
}
OptionalLong optionalPos = chunk.leaf$getTickingPos(random.nextInt(count));
if (optionalPos.isEmpty()) {
return;
}