[PR #794] [MERGED] fix(game): persist creative flight status across world save and reload (#777) #2818

Closed
opened 2026-11-02 15:59:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/794
Author: @lazy-importer
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/18/2026
Merged by: @ludovic111

Base: main ← Head: fix/creative-flight-save-persistence


📝 Commits (1)

  • 3bb973e fix(game): persist creative flight status across world save and reload (#777)

📊 Changes

4 files changed (+52 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+6 -0)
📝 crates/horizon-client/src/lan/playerdata.rs (+2 -0)
📝 crates/horizon-client/src/motion.rs (+4 -0)
📝 crates/horizon-client/src/save.rs (+40 -1)

📄 Description

What and why

Fixes #777.

When flying in Creative or Spectator mode, leaving the world (Save and Quit to Title) and rejoining caused the player to fall to the ground because flight status was not saved or restored from the world save.

In vanilla 26.3, Player.addAdditionalSaveData writes abilities.flying (compound.putByte("flying", this.flying ? 1 : 0)), and Player.readAdditionalSaveData restores it when joining (this.flying = tag.getBoolean("flying") && this.mayfly).

In Horizon:

  1. Level did not model flying, so sync_level did not record player.flying.
  2. player_tag() in save.rs did not write flying for creative mode (only explicitly writing 1 for spectator and 0 for non-creative, leaving creative unhandled).
  3. read_player() did not read abilities.flying into Level.
  4. PlayerMotion::load_saved_state_once in motion.rs did not restore self.flying from level.flying.
  5. LAN guest player data storage (lan/playerdata.rs) did not serialize or deserialize guest.flying.

This change:

  • Adds flying: bool to Level.
  • Syncs player.flying to level.flying in sync_level and preserves it in lan/playerdata.rs.
  • Reads abilities.flying in Level::read_player and writes flying in Level::player_tag for creative players.
  • Restores self.flying = level.flying in PlayerMotion::load_saved_state_once, validating with player.may_fly and spectator mode on spawn.
  • Adds unit tests in save.rs and motion.rs.

Vanilla reference

Follows vanilla Player.addAdditionalSaveData(CompoundTag), Player.readAdditionalSaveData(CompoundTag), and Abilities.flying.

Self-check

Check Result
Scope ✅ 4 files, +52 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅
clippy ✅ (no warnings)
tests: horizon-client ✅ flight persistence tests pass

🔄 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/794 **Author:** [@lazy-importer](https://github.com/lazy-importer) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/creative-flight-save-persistence` --- ### 📝 Commits (1) - [`3bb973e`](https://github.com/horizon-rust/horizon/commit/3bb973efae05a899decbbb4644dcca83bd2ee5e3) fix(game): persist creative flight status across world save and reload (#777) ### 📊 Changes **4 files changed** (+52 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+6 -0) 📝 `crates/horizon-client/src/lan/playerdata.rs` (+2 -0) 📝 `crates/horizon-client/src/motion.rs` (+4 -0) 📝 `crates/horizon-client/src/save.rs` (+40 -1) </details> ### 📄 Description ## What and why Fixes #777. When flying in Creative or Spectator mode, leaving the world (`Save and Quit to Title`) and rejoining caused the player to fall to the ground because flight status was not saved or restored from the world save. In vanilla 26.3, `Player.addAdditionalSaveData` writes `abilities.flying` (`compound.putByte("flying", this.flying ? 1 : 0)`), and `Player.readAdditionalSaveData` restores it when joining (`this.flying = tag.getBoolean("flying") && this.mayfly`). In Horizon: 1. `Level` did not model `flying`, so `sync_level` did not record `player.flying`. 2. `player_tag()` in `save.rs` did not write `flying` for creative mode (only explicitly writing 1 for spectator and 0 for non-creative, leaving creative unhandled). 3. `read_player()` did not read `abilities.flying` into `Level`. 4. `PlayerMotion::load_saved_state_once` in `motion.rs` did not restore `self.flying` from `level.flying`. 5. LAN guest player data storage (`lan/playerdata.rs`) did not serialize or deserialize `guest.flying`. This change: - Adds `flying: bool` to `Level`. - Syncs `player.flying` to `level.flying` in `sync_level` and preserves it in `lan/playerdata.rs`. - Reads `abilities.flying` in `Level::read_player` and writes `flying` in `Level::player_tag` for creative players. - Restores `self.flying = level.flying` in `PlayerMotion::load_saved_state_once`, validating with `player.may_fly` and spectator mode on spawn. - Adds unit tests in `save.rs` and `motion.rs`. ## Vanilla reference Follows vanilla `Player.addAdditionalSaveData(CompoundTag)`, `Player.readAdditionalSaveData(CompoundTag)`, and `Abilities.flying`. ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 4 files, +52 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ | | clippy | ✅ (no warnings) | | tests: horizon-client | ✅ flight persistence tests pass | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:59:18 +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#2818
No description provided.