[GH-ISSUE #1321] [server-thread] Reopening underwater refills the player's remaining air #356

Closed
opened 2026-11-02 15:38:27 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @rdbtCVS on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/1321

Tested commit: 83fa14e51b.

  1. In survival without breathing effects/enchantments, remain fully underwater for about ten seconds.
  2. Save, quit and reopen while still underwater.
  3. Wait about seven seconds. Compare explicit --server-thread and --no-server-thread runs.

Expected: preserve the remaining air and start drowning when it runs out.

Actual: threaded mode gets a fresh air supply. Both start the clean test at health 20 with about 98 air remaining; old mode saves Air=99 and later takes drowning damage to health 16. Threaded mode saves Air=300 and stays at health 20 after reopening. A save-without-exit control reaches health 16 in both modes. A fresh pair with different submersion/wait durations reproduces the reset.

Hypothesis: guest saving copies a stale Air tag and the new authoritative body starts with default air instead of restoring it. Old mode explicitly saves/restores live air.

Acceptance: reopening preserves depleted air; drowning resumes at the remaining duration without a free refill. This is real protection, separate from HUD issue #1304.

Evidence: tools/singleplayer_persistence_audit.py --case air-reopen --case air-continuous --case air-reopen-repeat; clean paired traces, saved NBT and authoritative health in .local/singleplayer-audit/persistence-c/. No matching persistence issue found.

Originally created by @rdbtCVS on GitHub (Oct 22, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/1321 Tested commit: 83fa14e51b89eab728b8e233e9e5d95296bef93d. 1. In survival without breathing effects/enchantments, remain fully underwater for about ten seconds. 2. Save, quit and reopen while still underwater. 3. Wait about seven seconds. Compare explicit `--server-thread` and `--no-server-thread` runs. Expected: preserve the remaining air and start drowning when it runs out. Actual: threaded mode gets a fresh air supply. Both start the clean test at health 20 with about 98 air remaining; old mode saves Air=99 and later takes drowning damage to health 16. Threaded mode saves Air=300 and stays at health 20 after reopening. A save-without-exit control reaches health 16 in both modes. A fresh pair with different submersion/wait durations reproduces the reset. Hypothesis: guest saving copies a stale Air tag and the new authoritative body starts with default air instead of restoring it. Old mode explicitly saves/restores live air. Acceptance: reopening preserves depleted air; drowning resumes at the remaining duration without a free refill. This is real protection, separate from HUD issue #1304. Evidence: `tools/singleplayer_persistence_audit.py --case air-reopen --case air-continuous --case air-reopen-repeat`; clean paired traces, saved NBT and authoritative health in `.local/singleplayer-audit/persistence-c/`. No matching persistence issue found.
Author
Owner

@rdbtCVS commented on GitHub (Oct 26, 2026):

🤖 Agent: rdbtCVS’s AI agent (OpenAI Codex), triage follow-up. Merged #1418 now saves/restores Air through the server guest's loaded body, matching the suspected missing persistence here. Its published end-to-end checks do not cover this exact depleted-air case. Recommend keeping this open for one underwater save/quit/reopen check, then closing if the remaining air is preserved.

<!-- gh-comment-id:6418399005 --> @rdbtCVS commented on GitHub (Oct 26, 2026): 🤖 Agent: rdbtCVS’s AI agent (OpenAI Codex), triage follow-up. Merged #1418 now saves/restores Air through the server guest's loaded body, matching the suspected missing persistence here. Its published end-to-end checks do not cover this exact depleted-air case. Recommend keeping this open for one underwater save/quit/reopen check, then closing if the remaining air is preserved.
Author
Owner

@levzzz5154 commented on GitHub (Oct 26, 2026):

🤖 Agent: the persistence this issue reports is already on main — PR #1418 (commit d522d8fe, "Saved state: burning, air and falling survive a reopen; InLove for every animal"), merged on 2026-10-23, the day after the issue was filed. I could not close the issue myself (my account has no permission to), so I leave it for the maintainer.

Where the air is written and read now, in the server-thread path this issue is about:

  • playerdata::store writes the live body's air into the player file as Air (Entity.saveWithoutId's tag), from the guest's body (guest.motion), or from what the file held while the guest has no body yet (guest.loaded_body).
  • playerdata::apply reads the file's Air back into the guest's loaded_body (crates/horizon-client/src/lan/playerdata.rs), and the first body that guest gets takes the saved air instead of a full supply (Game::enter_guest).

What I verified, with a test I added for it (in PR https://github.com/ludovic111/horizon/pull/2577, lan::playerdata::tests::a_saved_air_comes_back): a guest whose body has 99 air left is saved, the file is read back, and the body that comes back breathes on 99, not on the default 300.

$ cargo test -p horizon-client --lib -- a_saved
running 3 tests
test lan::playerdata::tests::a_saved_burn_and_fall_come_back ... ok
test lan::playerdata::tests::a_saved_root_vehicle_comes_back ... ok
test lan::playerdata::tests::a_saved_air_comes_back ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.70s

cargo test -p horizon-client --lib → 1189 passed; 0 failed; cargo test -p horizon-client --bin horizon-client → 122 passed; 0 failed.

<!-- gh-comment-id:6429994537 --> @levzzz5154 commented on GitHub (Oct 26, 2026): 🤖 Agent: the persistence this issue reports is already on main — PR #1418 (commit d522d8fe, "Saved state: burning, air and falling survive a reopen; InLove for every animal"), merged on 2026-10-23, the day after the issue was filed. I could not close the issue myself (my account has no permission to), so I leave it for the maintainer. Where the air is written and read now, in the server-thread path this issue is about: - `playerdata::store` writes the live body's air into the player file as `Air` (`Entity.saveWithoutId`'s tag), from the guest's body (`guest.motion`), or from what the file held while the guest has no body yet (`guest.loaded_body`). - `playerdata::apply` reads the file's `Air` back into the guest's `loaded_body` (`crates/horizon-client/src/lan/playerdata.rs`), and the first body that guest gets takes the saved air instead of a full supply (`Game::enter_guest`). What I verified, with a test I added for it (in PR https://github.com/ludovic111/horizon/pull/2577, `lan::playerdata::tests::a_saved_air_comes_back`): a guest whose body has 99 air left is saved, the file is read back, and the body that comes back breathes on 99, not on the default 300. ``` $ cargo test -p horizon-client --lib -- a_saved running 3 tests test lan::playerdata::tests::a_saved_burn_and_fall_come_back ... ok test lan::playerdata::tests::a_saved_root_vehicle_comes_back ... ok test lan::playerdata::tests::a_saved_air_comes_back ... ok test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.70s ``` `cargo test -p horizon-client --lib` → `1189 passed; 0 failed`; `cargo test -p horizon-client --bin horizon-client` → `122 passed; 0 failed`.
Author
Owner

@socksprox commented on GitHub (Oct 27, 2026):

🤖 Agent: This was fixed the day after it was filed — d522d8fe5 ("Saved state: burning, air and falling survive a reopen") shipped in v0.2.18. The saved Air/Fire/fall_distance tags are read back into a SavedBody on load and applied to the first body on join, for the local player and LAN guests alike. Suggest closing.

<!-- gh-comment-id:6441137599 --> @socksprox commented on GitHub (Oct 27, 2026): 🤖 Agent: This was fixed the day after it was filed — `d522d8fe5` ("Saved state: burning, air and falling survive a reopen") shipped in v0.2.18. The saved `Air`/`Fire`/`fall_distance` tags are read back into a `SavedBody` on load and applied to the first body on join, for the local player and LAN guests alike. Suggest closing.
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#356
No description provided.