From c41cf65d4e6c9b33e06a1dfc8dea5ae9be8feb0e Mon Sep 17 00:00:00 2001 From: Purdze <29306641+Purdze@users.noreply.github.com> Date: Tue, 27 Oct 2026 07:50:01 +0000 Subject: [PATCH 1/2] reset ingame test worlds to noon in clear weather between scripts --- tests/ingame/README.md | 3 ++- tools/ingame-test/src/main.rs | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/ingame/README.md b/tests/ingame/README.md index 4fac2cbfa..260f8b71b 100644 --- a/tests/ingame/README.md +++ b/tests/ingame/README.md @@ -43,7 +43,8 @@ The runner (`tools/ingame-test`): (17 for 1.20.x, 21 for 1.21.x, 25 for 26.x): `JAVA_HOME_` if set, else `JAVA_HOME`, else `java` on `PATH`. A newer Java runs older servers. 3. Runs a debug client per script, joining as that version, then resets the - player for the next one. + player for the next one, and the world to noon in clear weather with time + ticking. With `--jobs N`, N workers per version each start their own server and world under `target/ingame/workers///` and take scripts from a shared diff --git a/tools/ingame-test/src/main.rs b/tools/ingame-test/src/main.rs index 7bf79a139..b0bb7302e 100644 --- a/tools/ingame-test/src/main.rs +++ b/tools/ingame-test/src/main.rs @@ -626,10 +626,7 @@ impl Server { // out of the reset's reach; keep the area around spawn loaded. server.command("forceload add -48 -48 47 47"); // Mobs spawning at night attack and push the test player mid-script. - // 26.x renamed the rule; each version rejects the name it lacks. - for rule in ["spawn_mobs", "doMobSpawning"] { - server.command(&format!("gamerule {rule} false")); - } + server.gamerule(["spawn_mobs", "doMobSpawning"], false); Ok(server) } @@ -656,6 +653,14 @@ impl Server { let _ = writeln!(self.stdin, "{command}"); } + /// Sets a game rule by its 26.x and older names; each version rejects + /// the name it lacks. + fn gamerule(&mut self, names: [&str; 2], value: bool) { + for name in names { + self.command(&format!("gamerule {name} {value}")); + } + } + /// Clears what a script left behind. Once the player has left and the /// world is saved, their data is deleted so the next join starts fresh. fn reset_player(&mut self) -> Result<(), String> { @@ -678,6 +683,11 @@ impl Server { for _ in 0..2 { self.command("kill @e[type=!player]"); } + // Noon, clear and ticking, so a script that doesn't set the time or + // weather sees the same sky whichever scripts ran before it. + self.gamerule(["advance_time", "doDaylightCycle"], true); + self.command("time set 6000"); + self.command("weather clear"); Ok(()) } From f597fe293a643d0447711fb145406f4a3a915462 Mon Sep 17 00:00:00 2001 From: Purdze <29306641+Purdze@users.noreply.github.com> Date: Tue, 27 Oct 2026 08:08:05 +0000 Subject: [PATCH 2/2] reset the world when an ingame test server starts too --- tools/ingame-test/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/ingame-test/src/main.rs b/tools/ingame-test/src/main.rs index b0bb7302e..b1d5fdc9a 100644 --- a/tools/ingame-test/src/main.rs +++ b/tools/ingame-test/src/main.rs @@ -627,6 +627,7 @@ impl Server { server.command("forceload add -48 -48 47 47"); // Mobs spawning at night attack and push the test player mid-script. server.gamerule(["spawn_mobs", "doMobSpawning"], false); + server.reset_world(); Ok(server) } @@ -683,12 +684,16 @@ impl Server { for _ in 0..2 { self.command("kill @e[type=!player]"); } - // Noon, clear and ticking, so a script that doesn't set the time or - // weather sees the same sky whichever scripts ran before it. + self.reset_world(); + Ok(()) + } + + /// Noon, clear and ticking, so a script that doesn't set the time or + /// weather sees the same sky whether it runs first or after others. + fn reset_world(&mut self) { self.gamerule(["advance_time", "doDaylightCycle"], true); self.command("time set 6000"); self.command("weather clear"); - Ok(()) } /// Blocks until the server exits (Ctrl+C or `stop`).