[PR #3585] [MERGED] Single player: save when the game pauses #5075

Closed
opened 2026-11-03 05:10:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3585
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix-3280


📝 Commits (1)

  • ced6323 Single player: save when the game pauses

📊 Changes

2 files changed (+33 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/integrated.rs (+9 -0)
📝 tools/agent_control_e2e.py (+24 -1)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Fixes #3280

In vanilla, pausing single player saves the world: the log shows Saving and pausing game..., and the world is on disk while the pause menu is open. Horizon didn't save on pause. The server thread stopped ticking but saved only on the 5-minute autosave or on quit, so a crash or a killed process while paused lost everything since the last autosave.

The server thread's loop (run_integrated in game/integrated.rs) now notices the tick the game becomes paused, logs Saving and pausing game... and saves the way the autosave does (save_game_with(false): chunks, entities, level.dat with the owner's player data, stats, advancements..., without waiting for the region writer). It saves once per pause. Closing the menu and pausing again saves again, as in vanilla.

Like vanilla's Minecraft.isPaused, this only happens when the game really pauses (Game::pauses_game: single player, not open to LAN). The dedicated server's own "pause when empty" save is unchanged.

Vanilla reference

From javap -c on the 26.3 client.jar:

  • IntegratedServer.tickServer: paused = Minecraft.isPaused() || players empty; on the false → true transition, LOGGER.info("Saving and pausing game...") and saveEverything(false, false, false); then tickPaused() while paused
  • MinecraftServer.saveEverything (PlayerList.saveAll, then saveAllChunks)

No parity harness covers saving. tools/agent_control_e2e.py gets a scenario, pause-save. It opens a world, checks that level.dat isn't rewritten over 40 ticks of play, opens the pause menu and expects level.dat to be written within 15 seconds.

Before the fix (origin/main):

$ python tools/agent_control_e2e.py --mode cli --scenario pause-save
[cli] FAIL: AssertionError('pausing single player did not save level.dat')
{"cli/pause-save": false}

After:

$ python tools/agent_control_e2e.py --mode cli --scenario pause-save
[cli] PASS in 18 s: {'saved_on_pause': True}
{"cli/pause-save": true}

(On Windows it was run through a small wrapper: junctions instead of symlinks, no vscreen, and horizon-ctl launch's output sent to a file, because a captured launch never reaches EOF there. The scenario itself is unchanged.)

Self-check

Run on Windows 11. tools/pr_ready.py was not run; these are the steps it runs:

cargo fmt --all -- --check                                                    ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings   ok
cargo test -p horizon-client --features mods --bins integrated::              2 passed
python tools/agent_control_e2e.py --mode cli --scenario pause-save            passed (fails before the fix)

In game

In game (server thread): a world is played for 200 ticks, then the pause menu is opened with horizon-ctl pause.

  • Before: level.dat keeps the time it had while playing (15:00:30) after pausing, and logs/latest.log has no Saving and pausing game....
  • After: level.dat is rewritten when the menu opens (15:05:54 → 15:06:10), and the log shows [15:06:10] [Server thread/INFO]: Saving and pausing game.... Closing the menu and pausing again logs a second save (15:06:29), and nothing is saved in between.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3585 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-3280` --- ### 📝 Commits (1) - [`ced6323`](https://github.com/horizon-rust/horizon/commit/ced6323bb2f0331f28e3859c6ceac42d89b6c797) Single player: save when the game pauses ### 📊 Changes **2 files changed** (+33 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/integrated.rs` (+9 -0) 📝 `tools/agent_control_e2e.py` (+24 -1) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3280 In vanilla, pausing single player saves the world: the log shows `Saving and pausing game...`, and the world is on disk while the pause menu is open. Horizon didn't save on pause. The server thread stopped ticking but saved only on the 5-minute autosave or on quit, so a crash or a killed process while paused lost everything since the last autosave. The server thread's loop (`run_integrated` in `game/integrated.rs`) now notices the tick the game becomes paused, logs `Saving and pausing game...` and saves the way the autosave does (`save_game_with(false)`: chunks, entities, level.dat with the owner's player data, stats, advancements..., without waiting for the region writer). It saves once per pause. Closing the menu and pausing again saves again, as in vanilla. Like vanilla's `Minecraft.isPaused`, this only happens when the game really pauses (`Game::pauses_game`: single player, not open to LAN). The dedicated server's own "pause when empty" save is unchanged. ## Vanilla reference From `javap -c` on the 26.3 `client.jar`: - `IntegratedServer.tickServer`: `paused = Minecraft.isPaused() || players empty`; on the false → true transition, `LOGGER.info("Saving and pausing game...")` and `saveEverything(false, false, false)`; then `tickPaused()` while paused - `MinecraftServer.saveEverything` (`PlayerList.saveAll`, then `saveAllChunks`) No parity harness covers saving. `tools/agent_control_e2e.py` gets a scenario, `pause-save`. It opens a world, checks that `level.dat` isn't rewritten over 40 ticks of play, opens the pause menu and expects `level.dat` to be written within 15 seconds. Before the fix (origin/main): ``` $ python tools/agent_control_e2e.py --mode cli --scenario pause-save [cli] FAIL: AssertionError('pausing single player did not save level.dat') {"cli/pause-save": false} ``` After: ``` $ python tools/agent_control_e2e.py --mode cli --scenario pause-save [cli] PASS in 18 s: {'saved_on_pause': True} {"cli/pause-save": true} ``` (On Windows it was run through a small wrapper: junctions instead of symlinks, no vscreen, and `horizon-ctl launch`'s output sent to a file, because a captured launch never reaches EOF there. The scenario itself is unchanged.) ## Self-check Run on Windows 11. `tools/pr_ready.py` was not run; these are the steps it runs: ``` cargo fmt --all -- --check ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings ok cargo test -p horizon-client --features mods --bins integrated:: 2 passed python tools/agent_control_e2e.py --mode cli --scenario pause-save passed (fails before the fix) ``` ## In game In game (server thread): a world is played for 200 ticks, then the pause menu is opened with `horizon-ctl pause`. - **Before:** `level.dat` keeps the time it had while playing (15:00:30) after pausing, and `logs/latest.log` has no `Saving and pausing game...`. - **After:** `level.dat` is rewritten when the menu opens (15:05:54 → 15:06:10), and the log shows `[15:06:10] [Server thread/INFO]: Saving and pausing game...`. Closing the menu and pausing again logs a second save (15:06:29), and nothing is saved in between. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:10:04 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5075
No description provided.