[PR #6305] [MERGED] Native mods: a player starting or stopping flight, cancellable (native_player_toggle_flight, part of #5816) #6783

Closed
opened 2026-11-03 06:26:35 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6305
Author: @Detimes
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat-player-flight-hook


📝 Commits (4)

  • 0c25ed9 Native mods: a player starting or stopping flight, cancellable (native_player_toggle_flight)
  • 4eeb923 Merge remote-tracking branch 'upstream/main' into feat-player-flight-hook
  • e560fdd Merge upstream/main: keep both hooks in native_hooks.rs
  • 7673b45 Merge remote-tracking branch 'origin/main' into prO/6305

📊 Changes

6 files changed (+79 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/lan.rs (+3 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+26 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+20 -0)
📝 crates/horizon-client/src/lan/hub.rs (+12 -1)
📝 docs/native-mods.md (+5 -0)
➕ tools/native-hook-fragments/native_player_toggle_flight.json (+13 -0)

📄 Description

🤖 Opened by Detimes' AI agent (Claude Code, Claude Sonnet 5.5), not by Detimes personally.

What and why

Part of #5816 (hook points a survival server's native mods need). A mod could not hear or refuse a player starting or stopping flight.

  • New hook point native_player_toggle_flight(player, name, flying, cancel) (fragment native_player_toggle_flight.json, docs paragraph). The hub's PlayerAbilities handler applies the request as before and, when flying changed, queues a HostEvent::Flight; lan_flight_toggled calls the hook inside as_guest, so the player's state is swapped in and native_tell / native_acting_player work. It fires after the hub applied the new state.
  • cancel refuses the toggle in both directions: the guest goes back to the state they had and gets a fresh abilities packet, as vanilla sends for what it refuses (this also stops a "stop flying").
  • Nothing changes when no mod hooks it.

Kind

  • feature (new native hook point)

Vanilla reference

ServerGamePacketListenerImpl.handlePlayerAbilities (honoured only for a player who may fly). NeoForge has no flight toggle event; Bukkit's PlayerToggleFlightEvent is the equivalent (the fragment says so).

Other projects' code

none. (Tested with a throwaway horizon-mixins bundle, not part of this PR.)

Proof on a real dedicated server

Engine from this branch plus a throwaway bundle; a bare protocol client in creative sends the abilities packet.

control (idle, no packet)                 -> no hook line
client sends flags=2 (start flying)       -> hook: flying=true, acting=Some(player), native_tell=true; client got the mod's chat line
client repeats flags=2 (no change)        -> nothing
client sends flags=0 (stop flying)        -> hook: flying=false, native_tell=true
with the mod cancelling: start flying     -> server answers abilities flags 0x0d (no flying bit); data get entity: flying: 0b

Not covered: the flight a game-mode change starts or ends (/gamemode), a LAN host's own player, a spectator toggling, a landing client's report (named in the doc comment).

Self-check

pr_ready --quick --base upstream/main before merging main into the branch: Python tests 515 passed, rustfmt, clippy, horizon-client tests 1668 passed, doc tests pass; parity not run (--quick). After the merge: cargo test -p horizon-client --bin horizon-client native_hooks::tests passes (20 tests).


🔄 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/6305 **Author:** [@Detimes](https://github.com/Detimes) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat-player-flight-hook` --- ### 📝 Commits (4) - [`0c25ed9`](https://github.com/horizon-rust/horizon/commit/0c25ed9f23815dc3f00a2ffe874886e2c01271dc) Native mods: a player starting or stopping flight, cancellable (native_player_toggle_flight) - [`4eeb923`](https://github.com/horizon-rust/horizon/commit/4eeb923824729f32460fef97481310a2c3efa560) Merge remote-tracking branch 'upstream/main' into feat-player-flight-hook - [`e560fdd`](https://github.com/horizon-rust/horizon/commit/e560fdd4bcaebed0f0bca530fbab400b8560f32e) Merge upstream/main: keep both hooks in native_hooks.rs - [`7673b45`](https://github.com/horizon-rust/horizon/commit/7673b451137d4b3af77abbc2f2f256b6662a23bd) Merge remote-tracking branch 'origin/main' into prO/6305 ### 📊 Changes **6 files changed** (+79 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan.rs` (+3 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+26 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+20 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+12 -1) 📝 `docs/native-mods.md` (+5 -0) ➕ `tools/native-hook-fragments/native_player_toggle_flight.json` (+13 -0) </details> ### 📄 Description > 🤖 Opened by Detimes' AI agent (Claude Code, Claude Sonnet 5.5), not by Detimes personally. ## What and why Part of #5816 (hook points a survival server's native mods need). A mod could not hear or refuse a player starting or stopping flight. - New hook point `native_player_toggle_flight(player, name, flying, cancel)` (fragment `native_player_toggle_flight.json`, docs paragraph). The hub's `PlayerAbilities` handler applies the request as before and, when `flying` changed, queues a `HostEvent::Flight`; `lan_flight_toggled` calls the hook inside `as_guest`, so the player's state is swapped in and `native_tell` / `native_acting_player` work. It fires after the hub applied the new state. - `cancel` refuses the toggle in both directions: the guest goes back to the state they had and gets a fresh abilities packet, as vanilla sends for what it refuses (this also stops a "stop flying"). - Nothing changes when no mod hooks it. ## Kind - [x] feature (new native hook point) ## Vanilla reference `ServerGamePacketListenerImpl.handlePlayerAbilities` (honoured only for a player who may fly). NeoForge has no flight toggle event; Bukkit's `PlayerToggleFlightEvent` is the equivalent (the fragment says so). ## Other projects' code none. (Tested with a throwaway horizon-mixins bundle, not part of this PR.) ## Proof on a real dedicated server Engine from this branch plus a throwaway bundle; a bare protocol client in creative sends the abilities packet. ``` control (idle, no packet) -> no hook line client sends flags=2 (start flying) -> hook: flying=true, acting=Some(player), native_tell=true; client got the mod's chat line client repeats flags=2 (no change) -> nothing client sends flags=0 (stop flying) -> hook: flying=false, native_tell=true with the mod cancelling: start flying -> server answers abilities flags 0x0d (no flying bit); data get entity: flying: 0b ``` Not covered: the flight a game-mode change starts or ends (`/gamemode`), a LAN host's own player, a spectator toggling, a landing client's report (named in the doc comment). ## Self-check `pr_ready --quick --base upstream/main` before merging main into the branch: Python tests 515 passed, rustfmt, clippy, `horizon-client` tests 1668 passed, doc tests pass; parity not run (`--quick`). After the merge: `cargo test -p horizon-client --bin horizon-client native_hooks::tests` passes (20 tests). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:26:35 +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#6783
No description provided.