Add regression tests and per-dimension progress diagnostics. Document the unresolved C2ME random-initialization redirect conflict.
43 lines
2.1 KiB
Java
43 lines
2.1 KiB
Java
package dev.modzuozhi;
|
|
|
|
import net.neoforged.bus.api.SubscribeEvent;
|
|
import net.neoforged.fml.common.EventBusSubscriber;
|
|
import net.neoforged.neoforge.event.tick.ServerTickEvent;
|
|
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
|
import dev.modzuozhi.core.dimthread.FineGrainScheduler;
|
|
import dev.modzuozhi.core.dimthread.DimThreadCore;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.server.level.ClientInformation;
|
|
import com.mojang.authlib.GameProfile;
|
|
import java.util.UUID;
|
|
|
|
/** Runtime regression fixture; deliberately outside production source sets. */
|
|
@EventBusSubscriber(modid = "dimensionalripper")
|
|
public final class ChunkHandoffRegression {
|
|
private static int rounds;
|
|
@SubscribeEvent
|
|
public static void tick(ServerTickEvent.Post event) {
|
|
var server = event.getServer();
|
|
if (server.getTickCount() < 10) return;
|
|
if (rounds % 10 == 0) {
|
|
DimThreadCore.MANAGER.setPaused(server, true);
|
|
if (DimThreadCore.MANAGER.isLoopScheduled(server.overworld()))
|
|
throw new AssertionError("Paused idle loop still owns chunk queue");
|
|
// Exercise the actual login constructor from the reported waiting stack.
|
|
new ServerPlayer(server, server.overworld(), new GameProfile(UUID.randomUUID(), "PauseRegression"),
|
|
ClientInformation.createDefault());
|
|
server.overworld().getChunkSource().getChunk(20 + rounds, 0, ChunkStatus.FULL, true);
|
|
DimThreadCore.MANAGER.setPaused(server, false);
|
|
}
|
|
for (int i = 0; i < 100; i++) {
|
|
if (server.overworld().getChunkSource().getChunk(0, 0, ChunkStatus.FULL, true) == null)
|
|
throw new AssertionError("Missing requested chunk");
|
|
}
|
|
if (++rounds == 100) {
|
|
if (!FineGrainScheduler.isEnabled()) throw new AssertionError("Test silently degraded");
|
|
ModZuozhi.LOGGER.info("REGRESSION PASS: 10 paused login constructors, paused generation, resume, 10000 running chunk requests; fine enabled");
|
|
server.halt(false);
|
|
}
|
|
}
|
|
}
|