[GH-ISSUE #4654] Native mods: a hook point for left-clicking a block #1408

Closed
opened 2026-11-02 15:46:43 +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/4654

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 B of #1854 (block behaviour hooks), left_click_block in the priority list of #4402: today a native mod can't react when a player starts digging a block (a left click). Blocks that react to a punch, tools with a left-click action, and protected areas that stop a dig before it starts (native_destroy_block only sees the break at its end) all need it.

Proposal

A hook point in crates/horizon-client/src/game/native_hooks.rs, native_left_click_block, next to #4610's native_right_click_block:

/// A player left-clicks the block `state` at `pos` (`face` hit): where
/// `ServerPlayerGameMode.handleBlockBreakAction` takes a dig's start. Set
/// `canceled` to ignore the click: nothing is attacked, dug or broken.
pub(super) fn native_left_click_block(&mut self, pos: [i32; 3], face: [i32; 3], state: BlockStateId, canceled: &mut bool)
  • Called in lan_actions.rs on a START_DESTROY_BLOCK, after its reach, spawn protection and world border checks, before Block.attack or a creative break. Every player goes through it on the server (the integrated server thread is one of them), so it is authoritative; the ack already sent puts a canceled block back on the client.
  • Nothing changes without a native mod.
  • NATIVE_HOOKS_API + 1, its native-hooks.json entry, docs/native-mods.md.
Originally created by @ludovicthenot on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4654 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 **B** of #1854 (block behaviour hooks), `left_click_block` in the priority list of #4402: today a native mod can't react when a player starts digging a block (a left click). Blocks that react to a punch, tools with a left-click action, and protected areas that stop a dig before it starts (`native_destroy_block` only sees the break at its end) all need it. ## Proposal A hook point in `crates/horizon-client/src/game/native_hooks.rs`, `native_left_click_block`, next to #4610's `native_right_click_block`: ```rust /// A player left-clicks the block `state` at `pos` (`face` hit): where /// `ServerPlayerGameMode.handleBlockBreakAction` takes a dig's start. Set /// `canceled` to ignore the click: nothing is attacked, dug or broken. pub(super) fn native_left_click_block(&mut self, pos: [i32; 3], face: [i32; 3], state: BlockStateId, canceled: &mut bool) ``` - Called in `lan_actions.rs` on a `START_DESTROY_BLOCK`, after its reach, spawn protection and world border checks, before `Block.attack` or a creative break. Every player goes through it on the server (the integrated server thread is one of them), so it is authoritative; the ack already sent puts a canceled block back on the client. - Nothing changes without a native mod. - `NATIVE_HOOKS_API` + 1, its `native-hooks.json` entry, docs/native-mods.md.
Author
Owner

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

🤖 Agent: /claim

<!-- gh-comment-id:6532805276 --> @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#1408
No description provided.