[GH-ISSUE #4290] Native mods: a hook point for using an item (right click) #1260

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

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

Originally assigned to: @ludovicthenot on GitHub.

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

Part of #3911 (Mods). Gap I of #1854 (item behaviour hooks, 93 of the 307 code mods ranked there): today a native mod can't react when a player uses an item. Wands, staffs, tools with a right-click action and items that open a mod's screen all need it.

Proposal

A hook point in crates/horizon-client/src/game/native_hooks.rs:

/// A player uses `stack` (right click): on a block (`on` is its position and
/// face) once the block itself passed, or in the air. Set `claimed` to take
/// the use: the hand swings and the item's own use doesn't run.
pub(super) fn native_use_item(&mut self, stack: &ItemStack, on: Option<([i32; 3], [i32; 3])>, claimed: &mut bool)
  • Called from use_hand (game.rs), where ItemStack.useOn / Item.use start: after the block aimed at had its turn (so a chest still opens with a wand in hand, as vanilla orders it) and after the cooldown check. Every player goes through it on the server (the integrated server thread, LAN guests, dedicated servers), so it is authoritative; self.hand says which hand, and the helpers (native_player...) read the acting player.
  • Nothing changes without a native mod: not claimed, the use goes on as now.
  • NATIVE_HOOKS_API + 1, its native-hooks.json entry, docs/native-mods.md.

Stacked on #4284 (API 4), so this is API 5.

Originally created by @ludovicthenot on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4290 Originally assigned to: @ludovicthenot on GitHub. > 🤖 Filed by ludovicthenot's AI agent (Claude Code, Claude Opus 5.5), not by ludovicthenot personally. Part of #3911 (Mods). Gap **I** of #1854 (item behaviour hooks, 93 of the 307 code mods ranked there): today a native mod can't react when a player uses an item. Wands, staffs, tools with a right-click action and items that open a mod's screen all need it. ## Proposal A hook point in `crates/horizon-client/src/game/native_hooks.rs`: ```rust /// A player uses `stack` (right click): on a block (`on` is its position and /// face) once the block itself passed, or in the air. Set `claimed` to take /// the use: the hand swings and the item's own use doesn't run. pub(super) fn native_use_item(&mut self, stack: &ItemStack, on: Option<([i32; 3], [i32; 3])>, claimed: &mut bool) ``` - Called from `use_hand` (game.rs), where `ItemStack.useOn` / `Item.use` start: after the block aimed at had its turn (so a chest still opens with a wand in hand, as vanilla orders it) and after the cooldown check. Every player goes through it on the server (the integrated server thread, LAN guests, dedicated servers), so it is authoritative; `self.hand` says which hand, and the helpers (`native_player`...) read the acting player. - Nothing changes without a native mod: not claimed, the use goes on as now. - `NATIVE_HOOKS_API` + 1, its `native-hooks.json` entry, docs/native-mods.md. Stacked on #4284 (API 4), so this is API 5.
Author
Owner

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

🤖 Agent: /claim

<!-- gh-comment-id:6518662963 --> @ludovicthenot 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#1260
No description provided.