[PR #4665] [MERGED] Native mods: a hook point for each player's server tick (API 22) #5767

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4665
Author: @ludovicthenot
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: native-player-tick-hook


📝 Commits (2)

  • fb4fcb0 Native mods: a hook point for each player's server tick (API 22)
  • 6718c7d Merge hr/main; renumber player-tick hook to API 31

📊 Changes

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

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+2 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+8 -1)
📝 docs/native-mods.md (+3 -0)
📝 native-hooks.json (+5 -0)

📄 Description

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

Stacked on #4656 (API 21), itself on #4648 (API 20): review only the last commit (fb4fcb04e, +18 −1).

What and why

Fixes #4663. Part of #3911 (Mods), gap E of #1854, player_tick in the priority list of #4402: a native mod can now act on every player each tick, which an aura, mana that refills, an ability on a timer or an effect while wearing a mod's armour need. The server tick hook (#3878) runs once per tick for the whole server; this one runs once per player.

  • native_player_tick(&mut self): no arguments; the helpers (native_player...) read the player whose tick it is.
  • Called in tick_guests (lan_actions.rs), inside the as_guest turn that already ends each player's tick, after tick_mining, tick_using, the cooldowns, count_tick_stats, tick_advancements and update_player_attributes: the end of ServerPlayer.tick. No new swap: it rides the one that was there.
  • Every living player in the level goes through it on the server (the single player server thread, LAN guests, dedicated servers). Dead players and players still loading don't, as tick_guests skips them.
  • Nothing changes without a native mod.
  • NATIVE_HOOKS_API 21 → 22, its native-hooks.json entry (player_tick, version 1), and an "API 22" paragraph in docs/native-mods.md. The number follows #4656 and moves with it.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only (a hook point; it does nothing in Horizon). It sits at the end of ServerPlayer.tick (its Player.tick part: statistics, advancements, attributes), once per player per server tick. Without a native mod the player's tick is unchanged; CI's parity job picks the harnesses that cover lan_actions.rs.

Tested in the game

A throwaway local change (not in this pull request) logged each call with native_player's position. A fresh survival world on the server thread, through horizon-ctl (--offscreen):

Player Calls counted Expected
alive, 3 s 62 about 60 (20 a second)
dead after /kill @s, 3 s 0 0
after respawn, 2 s 42 about 40

native_player gave the player's position in each call (Some((-25.0, 65.0, 8.0))).

Self-check

On this commit: cargo fmt --check ✅, cargo clippy -p horizon-client --bin horizon-client ✅ (no warnings), native_hooks::tests ✅ 6 passed (the catalog test checks the new entry). tools/pr_ready.py was not run.

Label: feature (players get something new).


🔄 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/4665 **Author:** [@ludovicthenot](https://github.com/ludovicthenot) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `native-player-tick-hook` --- ### 📝 Commits (2) - [`fb4fcb0`](https://github.com/horizon-rust/horizon/commit/fb4fcb04ec1565eb23326b8fea8defc67d347419) Native mods: a hook point for each player's server tick (API 22) - [`6718c7d`](https://github.com/horizon-rust/horizon/commit/6718c7dd9a7cf3bc247d39eaec94ae83cbc7280f) Merge hr/main; renumber player-tick hook to API 31 ### 📊 Changes **4 files changed** (+18 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+2 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+8 -1) 📝 `docs/native-mods.md` (+3 -0) 📝 `native-hooks.json` (+5 -0) </details> ### 📄 Description > 🤖 Opened by ludovicthenot's AI agent (Claude Code, Claude Opus 5.5), not by ludovicthenot personally. **Stacked on #4656 (API 21), itself on #4648 (API 20): review only the last commit** (`fb4fcb04e`, +18 −1). ## What and why Fixes #4663. Part of #3911 (Mods), gap **E** of #1854, `player_tick` in the priority list of #4402: a native mod can now act on every player each tick, which an aura, mana that refills, an ability on a timer or an effect while wearing a mod's armour need. The server tick hook (#3878) runs once per tick for the whole server; this one runs once per player. - **`native_player_tick(&mut self)`**: no arguments; the helpers (`native_player`...) read the player whose tick it is. - Called in `tick_guests` (lan_actions.rs), inside the `as_guest` turn that already ends each player's tick, after `tick_mining`, `tick_using`, the cooldowns, `count_tick_stats`, `tick_advancements` and `update_player_attributes`: the end of `ServerPlayer.tick`. No new swap: it rides the one that was there. - Every living player in the level goes through it on the server (the single player server thread, LAN guests, dedicated servers). Dead players and players still loading don't, as `tick_guests` skips them. - Nothing changes without a native mod. - `NATIVE_HOOKS_API` 21 → 22, its `native-hooks.json` entry (`player_tick`, version 1), and an "API 22" paragraph in `docs/native-mods.md`. The number follows #4656 and moves with it. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only (a hook point; it does nothing in Horizon). It sits at the end of `ServerPlayer.tick` (its `Player.tick` part: statistics, advancements, attributes), once per player per server tick. Without a native mod the player's tick is unchanged; CI's parity job picks the harnesses that cover `lan_actions.rs`. ## Tested in the game A throwaway local change (not in this pull request) logged each call with `native_player`'s position. A fresh survival world on the server thread, through `horizon-ctl` (`--offscreen`): | Player | Calls counted | Expected | | --- | --- | --- | | alive, 3 s | 62 | about 60 (20 a second) | | dead after `/kill @s`, 3 s | 0 | 0 | | after `respawn`, 2 s | 42 | about 40 | `native_player` gave the player's position in each call (`Some((-25.0, 65.0, 8.0))`). ## Self-check On this commit: `cargo fmt --check` ✅, `cargo clippy -p horizon-client --bin horizon-client` ✅ (no warnings), `native_hooks::tests` ✅ 6 passed (the catalog test checks the new entry). `tools/pr_ready.py` was not run. Label: `feature` (players get something new). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:14:51 +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#5767
No description provided.