[GH-ISSUE #5481] Native mods: a mod's own advancement criteria triggers #1690

Closed
opened 2026-11-02 15:48:58 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @navinor on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5481

🤖 Filed by navinor's AI agent (OpenCode, Claude Opus 5.5), not by navinor personally.

Part of #4953's "Registration and data" list: "Mod loot functions and conditions, advancement triggers, enchantment effect components and consume effects". Advancement triggers are the one item there without an issue (reservedbytes asked for them in #4953). This sits beside loot #5451, enchantment effects #5449 and consume effects #5448.

What happens today

A content mod or a world's data pack can ship data/mymod/advancement/connect_a_pipe.json with a criterion whose trigger is mymod:pipe_connected. Horizon loads it: advancements.rs's parse keeps any trigger name (vanilla's CriteriaTriggers codec would refuse the file). But only the game's own code calls Game::trigger, and only with vanilla's names, so nothing fires the mod's trigger. The advancement can only be had through /advancement grant.

On NeoForge a mod registers a CriterionTrigger under Registries.TRIGGER_TYPE, usually a SimpleCriterionTrigger, and calls trigger(serverPlayer, instance -> instance.matches(...)) where its event happens.

Plan

  • A server helper, native_trigger_criterion(uuid, trigger, test): vanilla's SimpleCriterionTrigger.trigger for the player with that UUID. Each open criterion with that trigger is tested: its player predicate first, as vanilla does, then the mod's test on the criterion's conditions. What passes is granted, with the toast, chat line and rewards the game's own triggers give.
  • It works for the acting player inside their hook, and for any player on the server from a hook where no player is swapped in (a tick, a menu click).
  • The test can check vanilla item predicates in the mod's conditions (ItemPredicate, as inventory_changed uses), so a mod doesn't parse them itself.
  • minecraft: triggers are refused: the game fires those from its own events.
  • An API fragment under tools/native-hook-fragments/ and a section in docs/native-mods.md.

Not in this: refusing unknown trigger names at load (Horizon keeps such advancements either way), and anything on the client (advancement packets carry no triggers).

Originally created by @navinor on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5481 > 🤖 Filed by navinor's AI agent (OpenCode, Claude Opus 5.5), not by navinor personally. Part of #4953's "Registration and data" list: "Mod loot functions and conditions, advancement triggers, enchantment effect components and consume effects". Advancement triggers are the one item there without an issue (reservedbytes asked for them in #4953). This sits beside loot #5451, enchantment effects #5449 and consume effects #5448. ## What happens today A content mod or a world's data pack can ship `data/mymod/advancement/connect_a_pipe.json` with a criterion whose trigger is `mymod:pipe_connected`. Horizon loads it: `advancements.rs`'s `parse` keeps any trigger name (vanilla's `CriteriaTriggers` codec would refuse the file). But only the game's own code calls `Game::trigger`, and only with vanilla's names, so nothing fires the mod's trigger. The advancement can only be had through `/advancement grant`. On NeoForge a mod registers a `CriterionTrigger` under `Registries.TRIGGER_TYPE`, usually a `SimpleCriterionTrigger`, and calls `trigger(serverPlayer, instance -> instance.matches(...))` where its event happens. ## Plan - A server helper, `native_trigger_criterion(uuid, trigger, test)`: vanilla's `SimpleCriterionTrigger.trigger` for the player with that UUID. Each open criterion with that trigger is tested: its `player` predicate first, as vanilla does, then the mod's `test` on the criterion's `conditions`. What passes is granted, with the toast, chat line and rewards the game's own triggers give. - It works for the acting player inside their hook, and for any player on the server from a hook where no player is swapped in (a tick, a menu click). - The test can check vanilla item predicates in the mod's conditions (`ItemPredicate`, as `inventory_changed` uses), so a mod doesn't parse them itself. - `minecraft:` triggers are refused: the game fires those from its own events. - An API fragment under `tools/native-hook-fragments/` and a section in `docs/native-mods.md`. Not in this: refusing unknown trigger names at load (Horizon keeps such advancements either way), and anything on the client (advancement packets carry no triggers).
Author
Owner

@kira-horizon[bot] commented on GitHub (Oct 31, 2026):

Claimed by Navinor on Discord (GitHub: navinor), to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #5481).

<!-- gh-comment-id:6548932145 --> @kira-horizon[bot] commented on GitHub (Oct 31, 2026): Claimed by `Navinor` on Discord (GitHub: `navinor`), to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #5481). <!-- kira:work -->
Author
Owner

@CocofireHD commented on GitHub (Oct 31, 2026):

🤖 Agent: /claim

Claiming to work on this. I will open a pull request with the fix and keep this issue updated.

<!-- gh-comment-id:6548932784 --> @CocofireHD commented on GitHub (Oct 31, 2026): 🤖 Agent: /claim Claiming to work on this. I will open a pull request with the fix and keep this issue updated.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 31, 2026):

🤖 Claims: refused, someone claimed this issue on Discord (Kira's in progress label): pick another, or ask in the thread. (asked by @CocofireHD)

<!-- gh-comment-id:6548935895 --> @github-actions[bot] commented on GitHub (Oct 31, 2026): 🤖 Claims: refused, someone claimed this issue on Discord (Kira's `in progress` label): pick another, or ask in the thread. (asked by @CocofireHD)
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#1690
No description provided.