[PR #6521] [MERGED] Native mods: a player's food level changing, changeable (native_food_level_changed, part of #5816) #6933

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

📋 Pull Request Information

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

Base: main ← Head: feat-food-level-hook


📝 Commits (10+)

  • 8a65c97 Merge the profiles prerequisite onto current main for Setup
  • d48b592 Splitscreen: arrange players with a Setup map and Apply/Revert
  • fb0496a Align Setup pause icons and seed the saved switch in live checks
  • 69ce6f6 Merge current main into the Setup rebuild
  • ab3ebbd Native mods: a player swapping their hands, cancellable (native_player_swap_hands)
  • 4e70c05 Native mods: a player's food level changing, changeable (native_food_level_changed)
  • 8ac0773 Keep native mouse ownership when a second local player joins
  • a5da7ab Keep the native mouse regression fixture portable across filesystem paths
  • adea816 Merge current main into the Setup draft before localization fixes
  • b3dcefa Localize the splitscreen Setup screen and its window feedback

📊 Changes

25 files changed (+2120 additions, -89 deletions)

View changed files

📝 crates/horizon-client-render/src/lib.rs (+2 -0)
📝 crates/horizon-client-render/src/options_ui.rs (+32 -12)
📝 crates/horizon-client-render/src/split_layout.rs (+487 -25)
➕ crates/horizon-client-render/src/split_map.rs (+166 -0)
➕ crates/horizon-client-render/src/split_ui.rs (+716 -0)
📝 crates/horizon-client/assets/horizon/lang/en_us.json (+31 -2)
📝 crates/horizon-client/assets/horizon/lang/fr_fr.json (+35 -6)
📝 crates/horizon-client/src/client_lib.rs (+3 -3)
📝 crates/horizon-client/src/game.rs (+11 -6)
📝 crates/horizon-client/src/game/agent.rs (+9 -2)
📝 crates/horizon-client/src/game/lan_actions.rs (+41 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+34 -0)
📝 crates/horizon-client/src/game/screens.rs (+21 -10)
📝 crates/horizon-client/src/game/split.rs (+11 -10)
📝 crates/horizon-client/src/game/split/hud.rs (+8 -2)
📝 crates/horizon-client/src/game/split/players.rs (+1 -0)
➕ crates/horizon-client/src/game/split/setup.rs (+155 -0)
📝 crates/horizon-client/src/game/split/windows.rs (+12 -5)
📝 crates/horizon-client/src/mod_api/generated.rs (+97 -0)
📝 docs/extras.md (+6 -1)

...and 5 more files

📄 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 follow, change or refuse a player's food level changing (hunger rules, regeneration tweaks, food items).

  • New hook point native_food_level_changed(player, name, from, to, cancel) (fragment native_food_level_changed.json, docs paragraph). Called from leave_guest (lan_actions.rs), before the guest's state is swapped out, once per turn for the net change. A mod can change to or set cancel (the food level stays at from). The player's state is swapped in, so the helpers work.
  • Nothing changes when no mod hooks it.

Kind

  • feature (new native hook point)

Vanilla reference

FoodData changes (eating, exhaustion, saturation); NeoForge/Bukkit equivalent: FoodLevelChangeEvent.

Other projects' code

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

Proof on a real dedicated server

Engine from the batch branch this commit comes from, plus a throwaway bundle; a bare protocol client in survival.

control (idle)                              -> no hook line
exhaustion: food 20 -> 19                   -> hook: food_level from=20 to=19, acting=Some(player), native_tell=true
with the mod cancelling                     -> food stays 20 after 120 further hook lines
with the mod setting to = 15                -> food ends at 15

Not covered: the LAN host as a player, mob and dispenser paths.

Self-check

pr_ready --quick --base upstream/main ran once on the whole branch that carries this and four other hook commits (11 files, +267 −3): Python tests 586 passed, rustfmt, clippy, horizon-client tests 1809 passed, doc tests pass; parity not run (--quick). This PR is that commit cherry-picked onto current main (60 lines): cargo test -p horizon-client native_hooks 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/6521 **Author:** [@Detimes](https://github.com/Detimes) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat-food-level-hook` --- ### 📝 Commits (10+) - [`8a65c97`](https://github.com/horizon-rust/horizon/commit/8a65c97f3b2ee6a1f2536db6faa2bedbca5f62a8) Merge the profiles prerequisite onto current main for Setup - [`d48b592`](https://github.com/horizon-rust/horizon/commit/d48b592ddde908a6ccba643cc27d1411bbdebd95) Splitscreen: arrange players with a Setup map and Apply/Revert - [`fb0496a`](https://github.com/horizon-rust/horizon/commit/fb0496a105f785cfb7e9165d3c228935161e9a6f) Align Setup pause icons and seed the saved switch in live checks - [`69ce6f6`](https://github.com/horizon-rust/horizon/commit/69ce6f6c2635ceb282e0d8ea9dfc0bf2197286d0) Merge current main into the Setup rebuild - [`ab3ebbd`](https://github.com/horizon-rust/horizon/commit/ab3ebbdd653d3348ff6e56460eabff0493dcbfd9) Native mods: a player swapping their hands, cancellable (native_player_swap_hands) - [`4e70c05`](https://github.com/horizon-rust/horizon/commit/4e70c0549732dedd1ab50f4004b18b10984714a4) Native mods: a player's food level changing, changeable (native_food_level_changed) - [`8ac0773`](https://github.com/horizon-rust/horizon/commit/8ac07733050b65418c83772146e6e6bc3f7eda85) Keep native mouse ownership when a second local player joins - [`a5da7ab`](https://github.com/horizon-rust/horizon/commit/a5da7abce2db7a399dd3d8cfe004284f77f344ed) Keep the native mouse regression fixture portable across filesystem paths - [`adea816`](https://github.com/horizon-rust/horizon/commit/adea816573d33afa17d8843006bec63c23c8e828) Merge current main into the Setup draft before localization fixes - [`b3dcefa`](https://github.com/horizon-rust/horizon/commit/b3dcefa2ac3f6c02e06d45b165c0bc1252a9d01f) Localize the splitscreen Setup screen and its window feedback ### 📊 Changes **25 files changed** (+2120 additions, -89 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/lib.rs` (+2 -0) 📝 `crates/horizon-client-render/src/options_ui.rs` (+32 -12) 📝 `crates/horizon-client-render/src/split_layout.rs` (+487 -25) ➕ `crates/horizon-client-render/src/split_map.rs` (+166 -0) ➕ `crates/horizon-client-render/src/split_ui.rs` (+716 -0) 📝 `crates/horizon-client/assets/horizon/lang/en_us.json` (+31 -2) 📝 `crates/horizon-client/assets/horizon/lang/fr_fr.json` (+35 -6) 📝 `crates/horizon-client/src/client_lib.rs` (+3 -3) 📝 `crates/horizon-client/src/game.rs` (+11 -6) 📝 `crates/horizon-client/src/game/agent.rs` (+9 -2) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+41 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+34 -0) 📝 `crates/horizon-client/src/game/screens.rs` (+21 -10) 📝 `crates/horizon-client/src/game/split.rs` (+11 -10) 📝 `crates/horizon-client/src/game/split/hud.rs` (+8 -2) 📝 `crates/horizon-client/src/game/split/players.rs` (+1 -0) ➕ `crates/horizon-client/src/game/split/setup.rs` (+155 -0) 📝 `crates/horizon-client/src/game/split/windows.rs` (+12 -5) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+97 -0) 📝 `docs/extras.md` (+6 -1) _...and 5 more files_ </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 follow, change or refuse a player's food level changing (hunger rules, regeneration tweaks, food items). - New hook point `native_food_level_changed(player, name, from, to, cancel)` (fragment `native_food_level_changed.json`, docs paragraph). Called from `leave_guest` (`lan_actions.rs`), before the guest's state is swapped out, once per turn for the net change. A mod can change `to` or set `cancel` (the food level stays at `from`). The player's state is swapped in, so the helpers work. - Nothing changes when no mod hooks it. ## Kind - [x] feature (new native hook point) ## Vanilla reference `FoodData` changes (eating, exhaustion, saturation); NeoForge/Bukkit equivalent: `FoodLevelChangeEvent`. ## Other projects' code none. (Tested with a throwaway horizon-mixins bundle, not part of this PR.) ## Proof on a real dedicated server Engine from the batch branch this commit comes from, plus a throwaway bundle; a bare protocol client in survival. ``` control (idle) -> no hook line exhaustion: food 20 -> 19 -> hook: food_level from=20 to=19, acting=Some(player), native_tell=true with the mod cancelling -> food stays 20 after 120 further hook lines with the mod setting to = 15 -> food ends at 15 ``` Not covered: the LAN host as a player, mob and dispenser paths. ## Self-check `pr_ready --quick --base upstream/main` ran once on the whole branch that carries this and four other hook commits (11 files, +267 −3): Python tests 586 passed, rustfmt, clippy, `horizon-client` tests 1809 passed, doc tests pass; parity not run (`--quick`). This PR is that commit cherry-picked onto current main (60 lines): `cargo test -p horizon-client native_hooks` 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:29: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#6933
No description provided.