Repository navigation
Description
Version
- Lithium 0.26.2+mc26.3 (Fabric,
lithium-fabric-0.26.2+mc26.3.jar) - Minecraft 26.3, Fabric Loader 0.19.5, Java 25
- Option involved:
mixin.world.tick_scheduler(default on). With it set tofalsethe crash does not happen
What happens
On the server thread, when something like a very large structure template is placed and schedules >65536 block ticks for a single game tick, and then some of the blocks are cleared before all of the block ticks finish processing, predicate.test throws a NullPointerException:
java.lang.NullPointerException: Cannot invoke "net.minecraft.world.ticks.ScheduledTick.pos()" because "t" is null
at net.minecraft.world.ticks.LevelTicks.lambda$clearArea$0(LevelTicks.java:269)
at net.minecraft.world.ticks.LevelChunkTicks.removeIf(LevelChunkTicks.java:700)
at net.minecraft.world.ticks.LevelTicks.lambda$clearArea$1(LevelTicks.java:272)
at net.minecraft.world.ticks.LevelTicks.forContainersInArea(LevelTicks.java:262)
at net.minecraft.world.ticks.LevelTicks.clearArea(LevelTicks.java:270)
Cause
LevelChunkTicksMixin.removeIf does, for each OrderedTickQueue bucket:
queue.sort();
for (int i = 0; i < queue.size(); i++) {
ScheduledTick<T> tick = queue.getTickAtIndex(i);
if (predicate.test(tick)) { queue.setTickAtIndex(i, null); allTicks.remove(...); removed = true; }
}
if (removed) queue.removeNullsAndConsumed();OrderedTickQueue.poll() takes the head by advancing firstIndex and nulling arr[firstIndex - 1]; it does not compact. sort() returns at once when the queue is already sorted, so it does not compact either. getTickAtIndex(i) reads arr[i], not arr[firstIndex + i]. So once a sorted bucket has been partly polled, removeIf reads the emptied slots arr[0 .. firstIndex - 1] and passes null to the predicate, which throws with a NullPointerException.
A bucket stays partly polled across ticks whenever LevelTicks.tick stops at its maxTicksToProcess (65536/tick in ServerLevel.tick) in the middle of a bucket. Any clearArea on that chunk before the bucket is drained then throws (vanilla callers: StructureUtils.clearSpaceForStructure, GameTestInfo; mods that reset areas call it too - I found this bug while working on a mod of my own!).
How to reproduce
Minimal code required to reproduce the crash:
LevelTicks<Block> ticks = new LevelTicks<>(chunk -> true);
LevelChunkTicks<Block> container = new LevelChunkTicks<>();
ticks.addContainer(new ChunkPos(0, 0), container);
for (int i = 0; i < 3; i++) {
ticks.schedule(new ScheduledTick<>(Blocks.STONE, new BlockPos(i, 0, 0), 1L, TickPriority.NORMAL, i));
}
ticks.tick(1L, 1, (pos, block) -> {}); // at most one tick: the (1, NORMAL) bucket is left partly polled
ticks.clearArea(new BoundingBox(0, 0, 0, 15, 0, 15)); // NullPointerException with Lithium; vanilla removes the two ticksMinimal gameplay required to reproduce the crash:
Schedule more than 65536 block ticks for the same game tick, let one server tick run (processing stops at 65536, leaving a bucket partly polled), then clear an area covering the chunk where it stopped, e.g. /test clearall over a test structure there. Mods that clear fluid ticks with getFluidTicks().clearArea hit the same crash with fluid ticks, which is how I found it (large water-filled structure from a mod of mine).
Note
LevelChunkTicks.poll() on an empty container throws with Lithium (this.nextTickQueue is null), where vanilla's returns null. Thought this was worth mentioning, probably worth fixing (I can add it to this issue/PR I'm about to file if desired). Vanilla's own callers always peek() first, so this only affects mods that call poll() directly.
Activity
Add tick scheduler test from issue 800
2No2Name commentedon Nov 12, 2026
Thank you for reporting this. I have cleaned up the file and added some tests alongside your crash reproduction code.