[PR #6801] [MERGED] Native mods: 124 hook points for server mods (part of #5816) #7105

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

📋 Pull Request Information

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

Base: main ← Head: all-hooks


📝 Commits (10+)

  • ae5d8b2 Native mods: player hotbar selection (native_player_item_held)
  • bdce43d Native mods: player pick item (native_player_pick_item)
  • a7f0d88 Native mods: player enters bed (native_player_bed_enter)
  • 87f68a0 Native mods: player leaves bed (native_player_bed_leave)
  • 1d5a4e4 Native mods: player edits book (native_player_edit_book)
  • 1618c7d Native mods: player shears entity (native_player_shear_entity)
  • e50aad0 Native mods: player completes advancement (native_player_advancement_done)
  • bb4bad4 Native mods: player completes advancement (native_player_advancement_done)
  • 43e6a5d Native mods: fire ignition veto (native_block_ignite)
  • c0bded2 Native mods: fire burnout veto (native_block_burn)

📊 Changes

192 files changed (+12561 additions, -3404 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+234 -18)
📝 crates/horizon-client/src/game/advancements.rs (+34 -4)
📝 crates/horizon-client/src/game/beacon.rs (+5 -0)
📝 crates/horizon-client/src/game/beehives.rs (+12 -2)
📝 crates/horizon-client/src/game/block_entity_anims.rs (+10 -0)
📝 crates/horizon-client/src/game/block_entity_ticks.rs (+43 -8)
📝 crates/horizon-client/src/game/books.rs (+59 -2)
📝 crates/horizon-client/src/game/campfire.rs (+2 -0)
📝 crates/horizon-client/src/game/commands.rs (+87 -16)
📝 crates/horizon-client/src/game/commands/terrain_cmds.rs (+2 -0)
📝 crates/horizon-client/src/game/composter.rs (+1 -0)
📝 crates/horizon-client/src/game/creatures.rs (+110 -7)
📝 crates/horizon-client/src/game/crossbow.rs (+6 -0)
📝 crates/horizon-client/src/game/dedicated.rs (+11 -4)
📝 crates/horizon-client/src/game/dispenser.rs (+37 -0)
📝 crates/horizon-client/src/game/dragon.rs (+12 -1)
📝 crates/horizon-client/src/game/enchant_effects.rs (+12 -0)
📝 crates/horizon-client/src/game/end.rs (+1 -0)
📝 crates/horizon-client/src/game/fireworks.rs (+4 -0)
📝 crates/horizon-client/src/game/frames.rs (+29 -0)

...and 80 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): 124 new native hook points that mirror what a Paper plugin can listen to or veto, so the plugins of a Paper network can be rewritten as native mods. Sent as one PR, tested together, as agreed with the maintainers: a fully tested set may come in one piece instead of ~5 hooks per PR. One commit per hook (plus a few fixes) so it can still be read or cut apart.

Each hook is the usual shape: an empty native_* function with a doc comment ending @API:<name>@, a call at the place the server does the thing, a fragment under tools/native-hook-fragments/ (no API number, no mod_api entry), and a paragraph in docs/native-mods.md. 29 of them are cancellable (cancel: &mut bool, or a changeable value); the rest only tell. Nothing changes when no mod hooks them.

Group Hooks Names
Player input and items 11 player_item_held, player_pick_item, player_swap_with_equipment_slot, player_item_mend, player_item_cooldown, player_shield_disable, player_pickup_arrow, player_riptide, player_elytra_boost, player_egg_throw, player_attack_cooldown_reset
Player progress and state 15 player_exp_change, player_exp_cooldown_change, player_recipe_discovered, player_recipe_book_click, player_advancement_done, player_spawn_point_set, player_portal, player_teleport_end_gateway, player_velocity, player_stop_spectating_entity, player_locale_change, player_change_main_hand, player_deep_sleep, player_bed_enter, player_bed_leave
Player containers, books and entities 17 player_edit_book, player_lectern_page_change, player_insert_lectern_book, player_take_lectern_book, player_item_frame_change, player_flower_pot_manipulate, player_loom_pattern_select, player_stonecutter_recipe_select, player_map_filled, player_name_entity, player_open_sign, player_shear_entity, player_unleash_entity, player_toggle_entity_age_lock, player_bucket_entity, player_trade, player_change_beacon_effect
Fire, note blocks, bells, cauldrons 5 block_ignite, block_burn, note_play, bell_ring, cauldron_level_changed
Machines, crafting and containers 25 block_dispense_armor, block_shear_entity, block_exp, block_receive_game, brewing_start, campfire_start, block_cook, compost_item, crafter_craft, inventory_block_start, brewing_complete, brewing_fuel, furnace_burn, furnace_smelt, furnace_extract, furnace_start_smelt, hopper_pickup_item, anvil_damaged, prepare_anvil, prepare_grindstone, prepare_smithing, prepare_item_craft, prepare_item_enchant, enchant_item, trade_select
Blocks in the world 14 dragon_egg_form, fluid_level_change, leaves_decay, moisture_change, sculk_bloom, sponge_absorb, target_hit, vault_change_state, block_failed_dispense, beacon_state_change, block_break_progress_update, block_lock_check, block_fade, block_form
Entities and mobs 19 entity_teleport, entity_portal, entity_toggle_glide, entity_pose_change, entity_tame, entity_breed, entity_enter_love_mode, entity_transform, entity_break_door, entity_change_block, entity_enter_block, projectile_launch, entity_shoot_bow, item_spawn, potion_splash, firework_explode, exp_bottle, creeper_ignite, creeper_power
World, weather and server 17 weather_change, thunder_change, lightning_strike, time_skip, world_border_bounds_changed, world_game_rule_change, spawn_change, portal_create, raid_spawn_wave, raid_state_change, world_saved, entities_load, entities_unload, game_event, tab_complete, broadcast_message, whitelist_state_update
Other 1 world_border_center_changed

Kind

  • feature (new native hook points)

Vanilla reference

Every hook's doc comment says where it fires and what a cancel skips; the code sits in Horizon's port of the vanilla method. NeoForge has no event for most of these, so the fragments say none (NeoForge has no such event); the few that have one (AdvancementEvent.AdvancementEarnEvent, EntityTravelToDimensionEvent, PlayerWakeUpEvent) name it.

Other projects' code

none. Horizon's own source only. Bukkit/Paper/NeoForge source was not read; Paper's public Javadoc was used for the list of event names and their one-line meanings.

Disclosure: large parts were drafted by OpenAI Codex agents (one hook per commit, offline cargo check) and then read, compiled, formatted, tested, audited and fixed by Claude Code. Codex never had push access or network access.

Proof on a real dedicated server

Engine built from this branch (just before the last merge of main and two clippy fixes) with one throwaway horizon-mixins bundle that injects all 124 hook points (all injections resolved, status ok) and prints a line per call; a bare protocol client plus console commands on a fresh world, with controls.

Fired as expected: player_item_held (control: same slot again, silent), player_pick_item, player_recipe_discovered, player_advancement_done, player_spawn_point_set, player_exp_change and player_exp_cooldown_change (XP orb), note_play, bell_ring (both powered by redstone), sponge_absorb, block_ignite, block_burn, weather_change, thunder_change, lightning_strike, time_skip, world_border_bounds_changed, spawn_change, world_saved, whitelist_state_update, entity_teleport, firework_explode, tab_complete, furnace_burn, furnace_start_smelt, furnace_smelt, item_spawn, hopper_pickup_item (a first test found it silent on the real item-entity path; fixed in this PR and re-tested), plus fluid_level_change, leaves_decay, moisture_change, game_event, entity_change_block in ordinary world ticking.

Cancel verified on the server with a control: player_item_held (the client is sent its old held slot back; without a cancel nothing is sent) and time_skip (/time set 6000 is ignored; control without cancel works). A second agent read the call site of all 29 cancellable hooks for "the decision is already taken before the mod is asked" and half-done state: 28 fine, 1 defect (player_portal kept retrying a canceled trip every tick), fixed.

Not covered: about 85 of the hooks could not be triggered by a bare client or console (bed, books, lectern, loom, stonecutter, trades, anvil/smithing/enchanting/grindstone, raids, beacons, vaults, dispenser armor, bucket on mobs, elytra, riptide, ...); for those the proof is that the injection resolves and the call site was read. Known limits written in the doc comments: world_game_rule_change hears the game rules screen only (not /gamerule); entity_teleport reports command teleports only; broadcast_message and exp_bottle were not reached by /say or /summon. fluid_level_change, game_event, leaves_decay, moisture_change are called very often; they are one empty call when no mod hooks them.

Self-check

python3 tools/pr_ready.py --base upstream/main --quick: Python tests 602 passed, rustfmt, clippy (both CI variants), horizon-client, -lib and horizon-world tests 2366 passed, doc tests, mod API up to date; Scope warns (4395 lines of code, over 500) because this is the agreed single PR; parity not run (--quick).


🔄 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/6801 **Author:** [@Detimes](https://github.com/Detimes) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `all-hooks` --- ### 📝 Commits (10+) - [`ae5d8b2`](https://github.com/horizon-rust/horizon/commit/ae5d8b26dfa566a89460f3f046d41b4d31ed7b39) Native mods: player hotbar selection (native_player_item_held) - [`bdce43d`](https://github.com/horizon-rust/horizon/commit/bdce43d31ba3e81c3f603c4c79c3b90b37516b32) Native mods: player pick item (native_player_pick_item) - [`a7f0d88`](https://github.com/horizon-rust/horizon/commit/a7f0d885a150bf9d27aa35b29079ca9f03fe7c0e) Native mods: player enters bed (native_player_bed_enter) - [`87f68a0`](https://github.com/horizon-rust/horizon/commit/87f68a067dc64be5b4ac6274a7f5c2ff1490705e) Native mods: player leaves bed (native_player_bed_leave) - [`1d5a4e4`](https://github.com/horizon-rust/horizon/commit/1d5a4e42555ffef7475050b1b24ba76128439388) Native mods: player edits book (native_player_edit_book) - [`1618c7d`](https://github.com/horizon-rust/horizon/commit/1618c7d7091ee3e4d8e002d1b76132ed2983b83f) Native mods: player shears entity (native_player_shear_entity) - [`e50aad0`](https://github.com/horizon-rust/horizon/commit/e50aad00ba7226ceb240a60b1e35d47f7a5e505d) Native mods: player completes advancement (native_player_advancement_done) - [`bb4bad4`](https://github.com/horizon-rust/horizon/commit/bb4bad451e47e548c7aec3cf95f182f1e1ce88df) Native mods: player completes advancement (native_player_advancement_done) - [`43e6a5d`](https://github.com/horizon-rust/horizon/commit/43e6a5d7e93c1035616c2bd2a75e2c4edddc5f36) Native mods: fire ignition veto (native_block_ignite) - [`c0bded2`](https://github.com/horizon-rust/horizon/commit/c0bded22c69a5e5384d1312ca0a40a728a67dda1) Native mods: fire burnout veto (native_block_burn) ### 📊 Changes **192 files changed** (+12561 additions, -3404 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+234 -18) 📝 `crates/horizon-client/src/game/advancements.rs` (+34 -4) 📝 `crates/horizon-client/src/game/beacon.rs` (+5 -0) 📝 `crates/horizon-client/src/game/beehives.rs` (+12 -2) 📝 `crates/horizon-client/src/game/block_entity_anims.rs` (+10 -0) 📝 `crates/horizon-client/src/game/block_entity_ticks.rs` (+43 -8) 📝 `crates/horizon-client/src/game/books.rs` (+59 -2) 📝 `crates/horizon-client/src/game/campfire.rs` (+2 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+87 -16) 📝 `crates/horizon-client/src/game/commands/terrain_cmds.rs` (+2 -0) 📝 `crates/horizon-client/src/game/composter.rs` (+1 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+110 -7) 📝 `crates/horizon-client/src/game/crossbow.rs` (+6 -0) 📝 `crates/horizon-client/src/game/dedicated.rs` (+11 -4) 📝 `crates/horizon-client/src/game/dispenser.rs` (+37 -0) 📝 `crates/horizon-client/src/game/dragon.rs` (+12 -1) 📝 `crates/horizon-client/src/game/enchant_effects.rs` (+12 -0) 📝 `crates/horizon-client/src/game/end.rs` (+1 -0) 📝 `crates/horizon-client/src/game/fireworks.rs` (+4 -0) 📝 `crates/horizon-client/src/game/frames.rs` (+29 -0) _...and 80 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): **124 new native hook points** that mirror what a Paper plugin can listen to or veto, so the plugins of a Paper network can be rewritten as native mods. Sent as one PR, tested together, as agreed with the maintainers: a fully tested set may come in one piece instead of ~5 hooks per PR. One commit per hook (plus a few fixes) so it can still be read or cut apart. Each hook is the usual shape: an empty `native_*` function with a doc comment ending `@API:<name>@`, a call at the place the server does the thing, a fragment under `tools/native-hook-fragments/` (no API number, no `mod_api` entry), and a paragraph in `docs/native-mods.md`. 29 of them are cancellable (`cancel: &mut bool`, or a changeable value); the rest only tell. Nothing changes when no mod hooks them. | Group | Hooks | Names | |---|---:|---| | Player input and items | 11 | `player_item_held`, `player_pick_item`, `player_swap_with_equipment_slot`, `player_item_mend`, `player_item_cooldown`, `player_shield_disable`, `player_pickup_arrow`, `player_riptide`, `player_elytra_boost`, `player_egg_throw`, `player_attack_cooldown_reset` | | Player progress and state | 15 | `player_exp_change`, `player_exp_cooldown_change`, `player_recipe_discovered`, `player_recipe_book_click`, `player_advancement_done`, `player_spawn_point_set`, `player_portal`, `player_teleport_end_gateway`, `player_velocity`, `player_stop_spectating_entity`, `player_locale_change`, `player_change_main_hand`, `player_deep_sleep`, `player_bed_enter`, `player_bed_leave` | | Player containers, books and entities | 17 | `player_edit_book`, `player_lectern_page_change`, `player_insert_lectern_book`, `player_take_lectern_book`, `player_item_frame_change`, `player_flower_pot_manipulate`, `player_loom_pattern_select`, `player_stonecutter_recipe_select`, `player_map_filled`, `player_name_entity`, `player_open_sign`, `player_shear_entity`, `player_unleash_entity`, `player_toggle_entity_age_lock`, `player_bucket_entity`, `player_trade`, `player_change_beacon_effect` | | Fire, note blocks, bells, cauldrons | 5 | `block_ignite`, `block_burn`, `note_play`, `bell_ring`, `cauldron_level_changed` | | Machines, crafting and containers | 25 | `block_dispense_armor`, `block_shear_entity`, `block_exp`, `block_receive_game`, `brewing_start`, `campfire_start`, `block_cook`, `compost_item`, `crafter_craft`, `inventory_block_start`, `brewing_complete`, `brewing_fuel`, `furnace_burn`, `furnace_smelt`, `furnace_extract`, `furnace_start_smelt`, `hopper_pickup_item`, `anvil_damaged`, `prepare_anvil`, `prepare_grindstone`, `prepare_smithing`, `prepare_item_craft`, `prepare_item_enchant`, `enchant_item`, `trade_select` | | Blocks in the world | 14 | `dragon_egg_form`, `fluid_level_change`, `leaves_decay`, `moisture_change`, `sculk_bloom`, `sponge_absorb`, `target_hit`, `vault_change_state`, `block_failed_dispense`, `beacon_state_change`, `block_break_progress_update`, `block_lock_check`, `block_fade`, `block_form` | | Entities and mobs | 19 | `entity_teleport`, `entity_portal`, `entity_toggle_glide`, `entity_pose_change`, `entity_tame`, `entity_breed`, `entity_enter_love_mode`, `entity_transform`, `entity_break_door`, `entity_change_block`, `entity_enter_block`, `projectile_launch`, `entity_shoot_bow`, `item_spawn`, `potion_splash`, `firework_explode`, `exp_bottle`, `creeper_ignite`, `creeper_power` | | World, weather and server | 17 | `weather_change`, `thunder_change`, `lightning_strike`, `time_skip`, `world_border_bounds_changed`, `world_game_rule_change`, `spawn_change`, `portal_create`, `raid_spawn_wave`, `raid_state_change`, `world_saved`, `entities_load`, `entities_unload`, `game_event`, `tab_complete`, `broadcast_message`, `whitelist_state_update` | | Other | 1 | `world_border_center_changed` | ## Kind - [x] feature (new native hook points) ## Vanilla reference Every hook's doc comment says where it fires and what a cancel skips; the code sits in Horizon's port of the vanilla method. NeoForge has no event for most of these, so the fragments say `none (NeoForge has no such event)`; the few that have one (`AdvancementEvent.AdvancementEarnEvent`, `EntityTravelToDimensionEvent`, `PlayerWakeUpEvent`) name it. ## Other projects' code none. Horizon's own source only. Bukkit/Paper/NeoForge source was not read; Paper's public Javadoc was used for the list of event names and their one-line meanings. Disclosure: large parts were drafted by OpenAI Codex agents (one hook per commit, offline `cargo check`) and then read, compiled, formatted, tested, audited and fixed by Claude Code. Codex never had push access or network access. ## Proof on a real dedicated server Engine built from this branch (just before the last merge of `main` and two clippy fixes) with one throwaway horizon-mixins bundle that injects **all 124 hook points** (all injections resolved, status ok) and prints a line per call; a bare protocol client plus console commands on a fresh world, with controls. Fired as expected: `player_item_held` (control: same slot again, silent), `player_pick_item`, `player_recipe_discovered`, `player_advancement_done`, `player_spawn_point_set`, `player_exp_change` and `player_exp_cooldown_change` (XP orb), `note_play`, `bell_ring` (both powered by redstone), `sponge_absorb`, `block_ignite`, `block_burn`, `weather_change`, `thunder_change`, `lightning_strike`, `time_skip`, `world_border_bounds_changed`, `spawn_change`, `world_saved`, `whitelist_state_update`, `entity_teleport`, `firework_explode`, `tab_complete`, `furnace_burn`, `furnace_start_smelt`, `furnace_smelt`, `item_spawn`, `hopper_pickup_item` (a first test found it silent on the real item-entity path; fixed in this PR and re-tested), plus `fluid_level_change`, `leaves_decay`, `moisture_change`, `game_event`, `entity_change_block` in ordinary world ticking. Cancel verified on the server with a control: `player_item_held` (the client is sent its old held slot back; without a cancel nothing is sent) and `time_skip` (`/time set 6000` is ignored; control without cancel works). A second agent read the call site of **all 29 cancellable hooks** for "the decision is already taken before the mod is asked" and half-done state: 28 fine, 1 defect (`player_portal` kept retrying a canceled trip every tick), fixed. Not covered: about 85 of the hooks could not be triggered by a bare client or console (bed, books, lectern, loom, stonecutter, trades, anvil/smithing/enchanting/grindstone, raids, beacons, vaults, dispenser armor, bucket on mobs, elytra, riptide, ...); for those the proof is that the injection resolves and the call site was read. Known limits written in the doc comments: `world_game_rule_change` hears the game rules screen only (not `/gamerule`); `entity_teleport` reports command teleports only; `broadcast_message` and `exp_bottle` were not reached by `/say` or `/summon`. `fluid_level_change`, `game_event`, `leaves_decay`, `moisture_change` are called very often; they are one empty call when no mod hooks them. ## Self-check `python3 tools/pr_ready.py --base upstream/main --quick`: Python tests 602 passed, rustfmt, clippy (both CI variants), `horizon-client`, `-lib` and `horizon-world` tests 2366 passed, doc tests, mod API up to date; Scope warns (4395 lines of code, over 500) because this is the agreed single PR; parity not run (`--quick`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:33:55 +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#7105
No description provided.