[PR #6912] [MERGED] Native hooks: AdvancementProgressEvent and StatAwardEvent (native_player_advancement_progress, native_player_stat_award) #7187

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

📋 Pull Request Information

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

Base: main ← Head: v2/ses_01M6DKF0Z8BE7TF075HX2BZ8T2-7b6a6409e395


📝 Commits (6)

  • 34da960 Add native_player_advancement_progress hook
  • b0e4c06 Add native_player_stat_award hook
  • 19e698f Fix stat award and advancement progress hooks
  • c65ee1b Fix advancement progress and stat award hook review findings
  • 607bb4b Regenerate the mod API
  • efe72ef Merge main into #6912

📊 Changes

42 files changed (+460 additions, -135 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+29 -30)
📝 crates/horizon-client/src/game/advancements.rs (+41 -4)
📝 crates/horizon-client/src/game/beehives.rs (+1 -1)
📝 crates/horizon-client/src/game/books.rs (+1 -1)
📝 crates/horizon-client/src/game/campfire.rs (+1 -1)
📝 crates/horizon-client/src/game/chiseled_bookshelf.rs (+1 -1)
📝 crates/horizon-client/src/game/combat.rs (+4 -5)
📝 crates/horizon-client/src/game/composter.rs (+1 -1)
📝 crates/horizon-client/src/game/consume.rs (+1 -1)
📝 crates/horizon-client/src/game/creatures.rs (+7 -7)
📝 crates/horizon-client/src/game/decorated_pot.rs (+1 -1)
📝 crates/horizon-client/src/game/dragon.rs (+2 -2)
📝 crates/horizon-client/src/game/fishing.rs (+1 -1)
📝 crates/horizon-client/src/game/growth.rs (+2 -2)
📝 crates/horizon-client/src/game/integrated.rs (+1 -1)
📝 crates/horizon-client/src/game/jukebox.rs (+1 -1)
📝 crates/horizon-client/src/game/lan.rs (+49 -14)
📝 crates/horizon-client/src/game/lan_actions.rs (+2 -2)
📝 crates/horizon-client/src/game/lan_pvp.rs (+2 -2)
📝 crates/horizon-client/src/game/lan_stations.rs (+1 -1)

...and 22 more files

📄 Description

🤖 Opened by Aria's agent swarm, Dyna, not by Aria.

Adds two server-side native hooks.

  • native_player_advancement_progress (listen) matches NeoForge's AdvancementEvent.AdvancementProgressEvent. It fires after a criterion's progress changes, for grants and revokes. A no-op grant or revoke does not fire it. The minecraft:tick grants on a network player's first tick and on a reload reach the hook after that tick's recipe rewards, because the hub queues them for the game; every other path fires before the completion rewards, as vanilla does. The docs say so.
  • native_player_stat_award (cancel) matches NeoForge's StatAwardEvent. It fires before the stat count and the scoreboard criteria change; setting cancel awards nothing.

Every awardStat site now goes through Game::award_stat / award_custom_stat, which is why many files change by a line or two. With no native mod loaded it copies no name, so the per-tick and per-move counters don't allocate. The movement counters now skip a zero distance, as checkMovementStatistics does, so the hook never sees an award of 0. revoke_advancement shares a small revoke_criterion helper with the grant path rather than copying it.

Tested in game

Built through the launcher (native-build, dev profile) with a throwaway trait mod on a throwaway branch of https://github.com/arismoko/horizon-machine-sample (the recommended end-to-end route, used here). The build was one test merge of this PR with the batch's other hooks PRs (#6910, #6911) on main db813a1c3. Each hook logged a WAVE_PROOF line.

Hook Server thread (integrated, LAN) Dedicated server
player_advancement_progress ✅ mining stone logged minecraft:story/mine_stone get_stone true; /advancement revoke logged false, /advancement grant true; the first-tick grant logged recipes/decorations/crafting_table unlock_right_away true for the owner and a LAN guest ✅ earn, revoke and grant
player_stat_award ✅ mining stone logged minecraft:mined minecraft:stone 1; while cancelling, the minecraft.mined:minecraft.stone objective didn't move; with the cancel lifted it rose ✅ cancelled: no score set; allowed: Dedi has 1 [mined]

Not seen: a /reload granted no tick criterion in the test world, so the reload path of player_advancement_progress didn't fire.

pr_ready

pr_ready (tools/pr_ready.py --quick --base db813a1c3879cd7334b6d6e11b9ef2eeb175a49f at 607bb4bfe1, 2 min 43 s)

Check Result
Scope ⚠️ 42 files, +468 −139; 605 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 610 passed (44 s)
rustfmt ✅ (11 s)
clippy ✅ (36 s)
tests: horizon-client, horizon-client-lib ✅ 2001 passed (46 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
mod API up to date ✅ (23 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

On the scope warning: most of the 42 files are one-line changes from self.stats.add(…)/custom(…) to award_stat/award_custom_stat, so every award reaches the hook. The two hooks share that call path, so they ship together.

Part of #4953.

🤖 Generated with Dyna.


🔄 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/6912 **Author:** [@arismoko](https://github.com/arismoko) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `v2/ses_01M6DKF0Z8BE7TF075HX2BZ8T2-7b6a6409e395` --- ### 📝 Commits (6) - [`34da960`](https://github.com/horizon-rust/horizon/commit/34da960a6c939c474072b7e9ad1c167a16695253) Add native_player_advancement_progress hook - [`b0e4c06`](https://github.com/horizon-rust/horizon/commit/b0e4c06e916cddf38259b549a5f72c271edcfac7) Add native_player_stat_award hook - [`19e698f`](https://github.com/horizon-rust/horizon/commit/19e698fa1cb3b2801feaf164ace418041df007f4) Fix stat award and advancement progress hooks - [`c65ee1b`](https://github.com/horizon-rust/horizon/commit/c65ee1b3c60fcc904df758df0bee3fefa810ca44) Fix advancement progress and stat award hook review findings - [`607bb4b`](https://github.com/horizon-rust/horizon/commit/607bb4bfe1ad095cf95387253a2c49284c2ca52f) Regenerate the mod API - [`efe72ef`](https://github.com/horizon-rust/horizon/commit/efe72ef9852b16d606e0bbae42f20d68732092cf) Merge main into #6912 ### 📊 Changes **42 files changed** (+460 additions, -135 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+29 -30) 📝 `crates/horizon-client/src/game/advancements.rs` (+41 -4) 📝 `crates/horizon-client/src/game/beehives.rs` (+1 -1) 📝 `crates/horizon-client/src/game/books.rs` (+1 -1) 📝 `crates/horizon-client/src/game/campfire.rs` (+1 -1) 📝 `crates/horizon-client/src/game/chiseled_bookshelf.rs` (+1 -1) 📝 `crates/horizon-client/src/game/combat.rs` (+4 -5) 📝 `crates/horizon-client/src/game/composter.rs` (+1 -1) 📝 `crates/horizon-client/src/game/consume.rs` (+1 -1) 📝 `crates/horizon-client/src/game/creatures.rs` (+7 -7) 📝 `crates/horizon-client/src/game/decorated_pot.rs` (+1 -1) 📝 `crates/horizon-client/src/game/dragon.rs` (+2 -2) 📝 `crates/horizon-client/src/game/fishing.rs` (+1 -1) 📝 `crates/horizon-client/src/game/growth.rs` (+2 -2) 📝 `crates/horizon-client/src/game/integrated.rs` (+1 -1) 📝 `crates/horizon-client/src/game/jukebox.rs` (+1 -1) 📝 `crates/horizon-client/src/game/lan.rs` (+49 -14) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+2 -2) 📝 `crates/horizon-client/src/game/lan_pvp.rs` (+2 -2) 📝 `crates/horizon-client/src/game/lan_stations.rs` (+1 -1) _...and 22 more files_ </details> ### 📄 Description > 🤖 Opened by Aria's agent swarm, Dyna, not by Aria. Adds two server-side native hooks. - `native_player_advancement_progress` (listen) matches NeoForge's `AdvancementEvent.AdvancementProgressEvent`. It fires after a criterion's progress changes, for grants and revokes. A no-op grant or revoke does not fire it. The `minecraft:tick` grants on a network player's first tick and on a reload reach the hook after that tick's recipe rewards, because the hub queues them for the game; every other path fires before the completion rewards, as vanilla does. The docs say so. - `native_player_stat_award` (cancel) matches NeoForge's `StatAwardEvent`. It fires before the stat count and the scoreboard criteria change; setting `cancel` awards nothing. Every `awardStat` site now goes through `Game::award_stat` / `award_custom_stat`, which is why many files change by a line or two. With no native mod loaded it copies no name, so the per-tick and per-move counters don't allocate. The movement counters now skip a zero distance, as `checkMovementStatistics` does, so the hook never sees an award of 0. `revoke_advancement` shares a small `revoke_criterion` helper with the grant path rather than copying it. ## Tested in game Built through the launcher (native-build, dev profile) with a throwaway trait mod on a throwaway branch of https://github.com/arismoko/horizon-machine-sample (the recommended end-to-end route, used here). The build was one test merge of this PR with the batch's other hooks PRs (#6910, #6911) on main db813a1c3. Each hook logged a `WAVE_PROOF` line. | Hook | Server thread (integrated, LAN) | Dedicated server | | --- | --- | --- | | `player_advancement_progress` | ✅ mining stone logged `minecraft:story/mine_stone get_stone true`; `/advancement revoke` logged `false`, `/advancement grant` `true`; the first-tick grant logged `recipes/decorations/crafting_table unlock_right_away true` for the owner and a LAN guest | ✅ earn, revoke and grant | | `player_stat_award` | ✅ mining stone logged `minecraft:mined minecraft:stone 1`; while cancelling, the `minecraft.mined:minecraft.stone` objective didn't move; with the cancel lifted it rose | ✅ cancelled: no score set; allowed: `Dedi has 1 [mined]` | Not seen: a `/reload` granted no tick criterion in the test world, so the reload path of `player_advancement_progress` didn't fire. ## pr_ready **pr_ready** (`tools/pr_ready.py --quick --base db813a1c3879cd7334b6d6e11b9ef2eeb175a49f` at 607bb4bfe1, 2 min 43 s) | Check | Result | | --- | --- | | Scope | ⚠️ 42 files, +468 −139; 605 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 610 passed (44 s) | | rustfmt | ✅ (11 s) | | clippy | ✅ (36 s) | | tests: horizon-client, horizon-client-lib | ✅ 2001 passed (46 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (23 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | On the scope warning: most of the 42 files are one-line changes from `self.stats.add(…)`/`custom(…)` to `award_stat`/`award_custom_stat`, so every award reaches the hook. The two hooks share that call path, so they ship together. Part of #4953. 🤖 Generated with Dyna. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:35:26 +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#7187
No description provided.