[GH-ISSUE #4673] Native mods: hook points for item behaviour (hitting a mob, inventory tick, equipping) #1415

Closed
opened 2026-11-02 15:46:46 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Qwerner88880 on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4673

Originally assigned to: @Qwerner88880 on GitHub.

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

Part of #3911 (Mods). Gap I of #1854 (item behaviour hooks), next to #4302 (using an item): today a native mod can't react when a held item hits a mob, can't run code for an item while it sits in a player's inventory, and can't tell when armour is put on or taken off. Weapons with an on-hit effect, items that recharge or tick down, and armour with an effect need these.

Proposal

Three hook points in crates/horizon-client/src/game/native_hooks.rs, named after the vanilla calls they sit in, as agreed on #4402:

  • native_hurt_enemy(stack, entity, kind): Item.hurtEnemy, once a player's hit landed on a mob. It only hears.
  • native_inventory_tick(slot, stack, selected): Item.inventoryTick from Inventory.tick, each server tick for every stack a player carries, armour and off hand included. The mod may change the stack.
  • native_on_equip(slot, new): LivingEntity.onEquipItem, when an equipment slot takes a different item. It only hears.

All are server-side, for every player of the world; the helpers read the acting player. Nothing changes without a native mod. NATIVE_HOOKS_API + 1, the native-hooks.json entries, and docs/native-mods.md.

Originally created by @Qwerner88880 on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4673 Originally assigned to: @Qwerner88880 on GitHub. > 🤖 Filed by Qwerner88880's AI agent (Claude Code, Claude Opus 5.5), not by Qwerner88880 personally. Part of #3911 (Mods). Gap **I** of #1854 (item behaviour hooks), next to #4302 (using an item): today a native mod can't react when a held item hits a mob, can't run code for an item while it sits in a player's inventory, and can't tell when armour is put on or taken off. Weapons with an on-hit effect, items that recharge or tick down, and armour with an effect need these. ## Proposal Three hook points in `crates/horizon-client/src/game/native_hooks.rs`, named after the vanilla calls they sit in, as agreed on #4402: - **`native_hurt_enemy(stack, entity, kind)`:** `Item.hurtEnemy`, once a player's hit landed on a mob. It only hears. - **`native_inventory_tick(slot, stack, selected)`:** `Item.inventoryTick` from `Inventory.tick`, each server tick for every stack a player carries, armour and off hand included. The mod may change the stack. - **`native_on_equip(slot, new)`:** `LivingEntity.onEquipItem`, when an equipment slot takes a different item. It only hears. All are server-side, for every player of the world; the helpers read the acting player. Nothing changes without a native mod. `NATIVE_HOOKS_API` + 1, the `native-hooks.json` entries, and `docs/native-mods.md`.
Author
Owner

@Qwerner88880 commented on GitHub (Oct 30, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6533285870 --> @Qwerner88880 commented on GitHub (Oct 30, 2026): 🤖 Agent: /claim
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#1415
No description provided.