[PR #5731] [MERGED] feat(mods): native mods can raycast across the distant terrain and own an item's use #6462

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5731
Author: @Stink-O
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: native/claimed-items


📝 Commits (8)

  • b5c8018 feat(mods): native mods can raycast across the distant terrain and own an item's use
  • 764cbf8 Merge main into #5731
  • 24067ef fix(mods): end a claimed item's use wherever the game resets the use
  • 4359398 Merge remote-tracking branch 'hr/main' into pr-5731
  • 8bb24b5 Claimed items: an off-hand claimed item sends no use; docs: main hand only, the movement check, claims over use durations
  • f10724e Merge remote-tracking branch 'hr/main' into pr-5731
  • fab6784 Merge remote-tracking branch 'hr/main' into pr-5731
  • b618b02 Merge main into #5731

📊 Changes

6 files changed (+407 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+4 -0)
➕ crates/horizon-client/src/game/native_claimed_items.rs (+346 -0)
📝 crates/horizon-client/src/game/native_server.rs (+2 -1)
📝 crates/horizon-client/src/game/remote.rs (+23 -0)
📝 docs/native-mods.md (+24 -0)
➕ tools/native-hook-fragments/native_claimed_items.json (+8 -0)

📄 Description

🤖 Opened by Stink-O's AI agent (Claude Code, Claude Opus 5.5), not by Stink-O personally.

What and why

Fixes #5730. Part of #5727, the hooks Orbital Laser needs to run as a
native mod (its designator is aimed kilometres away and charged by holding right-click). It's useful beyond that:
today a client mod can't see past the loaded chunks, and can't own a right-click with its item.

  • native_view_hit() and native_raycast(distance): the first block along the view, up to 1024 blocks. Near the
    player it's clip_ray (as BlockGetter.clip). Past the loaded chunks it walks the distant terrain
    (Lod::ground), a block at a time, so a target far off can be aimed at before its chunks load.
  • native_claim_items(mod_id, ids) (at most 64 ids) and native_poll(mod_id): a right-click with a claimed item in
    the main hand is the mod's alone.
    • The client sends nothing to the server, starts a use locally, and queues UseStart.
    • It queues UseStop, with the ticks held, when the use ends: the button comes up, the hand's item changes or
      leaves the claim, the player respawns, the game joins a server, or the client's use is otherwise reset. So every
      UseStart has its UseStop, and a vanilla use after an interrupted claimed one isn't cancelled by it.
    • Each event carries the stack (id, count, slot, and its minecraft:custom_name and minecraft:custom_data as
      SNBT), so items told apart by custom data are told apart here.
    • A claimed item in the off hand does nothing on a right-click.
    • The use slows the player as an item in use does, which the server doesn't know of, so on a LAN or dedicated
      server the anticheat's movement check may log it.
    • A claim wins over #5649's native_use_duration for the same item; an unclaimed item takes exactly main's path.
  • The hand's stack at any other time is API 9's native_held(). Its doc now says that on a client it's the
    player's own.
  • docs/native-mods.md gets a section, "A client mod's view and items".

They're helpers only: fragment tools/native-hook-fragments/native_claimed_items.json. No API number is edited.

Kind

  • feature

Vanilla reference

Horizon-only.

  • BlockGetter.clip near the player.
  • Minecraft.startUseItem / MultiPlayerGameMode.useItem, which a claimed item stands in for.
  • LivingEntity.updatingUsingItem / stopUsingItem for when a use ends.

Other projects' code

None from other projects. Ported from the author's own fork of Horizon (Stink-O/horizon, MIT):
ae531730c,
896853699, reshaped to native helpers.

How it was tested

  • cargo test -p horizon-client --bin horizon-client native_claimed_items → test result: ok. 4 passed:
    • items are claimed by the first mod in id order;
    • events wait for their mod, up to a limit;
    • an_interrupted_claimed_use_leaves_the_next_use_alone;
    • a_claimed_use_is_the_mods_while_it_runs.
  • python3 tools/lan_e2e.py --check eat --check eating --check helduse --check consume-release (fast binaries of
    24067ef56, before #5649 merged; this is a needs-proof PR: remote.rs):
    • eat, helduse and consume-release passed.
    • eating failed once ("the player beside the eater heard 8 bites, wants 9") and passed alone. The same check
      failed the same way once on a later build after #5649.
    • With no mod claiming anything every new branch returns early, so vanilla eating takes the same path as on main.
  • Stamped locally in a scratch worktree, not committed: Stamped 5 fragment(s), through API 85.

For the merge

  • Depends on: nothing.
  • Conflicts: #5741's Game field now sits apart from this one's, so the two merge in either order.
  • Risk: it touches the client's use path (remote.rs), so it's a needs-proof PR. With no mod claiming
    anything every new branch returns early. Rollback: revert before the stamp PR merges; after that, fix
    forward.

Self-check

Approved by levzzz's agent with its fixes on top, and CI green there.

🤖 Generated with Claude Code


🔄 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/5731 **Author:** [@Stink-O](https://github.com/Stink-O) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/claimed-items` --- ### 📝 Commits (8) - [`b5c8018`](https://github.com/horizon-rust/horizon/commit/b5c8018c47fd863c53ad72e0836eeac62d95dc9b) feat(mods): native mods can raycast across the distant terrain and own an item's use - [`764cbf8`](https://github.com/horizon-rust/horizon/commit/764cbf821402cd36740149a147e4e1b01f244886) Merge main into #5731 - [`24067ef`](https://github.com/horizon-rust/horizon/commit/24067ef56f7ad8a24509bd5e155515bf55730123) fix(mods): end a claimed item's use wherever the game resets the use - [`4359398`](https://github.com/horizon-rust/horizon/commit/4359398e574468fbb0a025c1e00a0d30cb2b6a8e) Merge remote-tracking branch 'hr/main' into pr-5731 - [`8bb24b5`](https://github.com/horizon-rust/horizon/commit/8bb24b5292bcbe97c40515e5a1b0c2e0b80f9e0e) Claimed items: an off-hand claimed item sends no use; docs: main hand only, the movement check, claims over use durations - [`f10724e`](https://github.com/horizon-rust/horizon/commit/f10724e8b5848acb34f5515bf046250ef32da8f0) Merge remote-tracking branch 'hr/main' into pr-5731 - [`fab6784`](https://github.com/horizon-rust/horizon/commit/fab678483185d3fca505404535a5183013e6fe25) Merge remote-tracking branch 'hr/main' into pr-5731 - [`b618b02`](https://github.com/horizon-rust/horizon/commit/b618b02a6880842deae5691cce1568625fe11c3a) Merge main into #5731 ### 📊 Changes **6 files changed** (+407 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+4 -0) ➕ `crates/horizon-client/src/game/native_claimed_items.rs` (+346 -0) 📝 `crates/horizon-client/src/game/native_server.rs` (+2 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+23 -0) 📝 `docs/native-mods.md` (+24 -0) ➕ `tools/native-hook-fragments/native_claimed_items.json` (+8 -0) </details> ### 📄 Description > 🤖 Opened by Stink-O's AI agent (Claude Code, Claude Opus 5.5), not by Stink-O personally. ## What and why Fixes #5730. Part of #5727, the hooks [Orbital Laser](https://github.com/Stink-O/orbital-laser) needs to run as a native mod (its designator is aimed kilometres away and charged by holding right-click). It's useful beyond that: today a client mod can't see past the loaded chunks, and can't own a right-click with its item. - `native_view_hit()` and `native_raycast(distance)`: the first block along the view, up to 1024 blocks. Near the player it's `clip_ray` (as `BlockGetter.clip`). Past the loaded chunks it walks the distant terrain (`Lod::ground`), a block at a time, so a target far off can be aimed at before its chunks load. - `native_claim_items(mod_id, ids)` (at most 64 ids) and `native_poll(mod_id)`: a right-click with a claimed item in the main hand is the mod's alone. - The client sends nothing to the server, starts a use locally, and queues `UseStart`. - It queues `UseStop`, with the ticks held, when the use ends: the button comes up, the hand's item changes or leaves the claim, the player respawns, the game joins a server, or the client's use is otherwise reset. So every `UseStart` has its `UseStop`, and a vanilla use after an interrupted claimed one isn't cancelled by it. - Each event carries the stack (id, count, slot, and its `minecraft:custom_name` and `minecraft:custom_data` as SNBT), so items told apart by custom data are told apart here. - A claimed item in the off hand does nothing on a right-click. - The use slows the player as an item in use does, which the server doesn't know of, so on a LAN or dedicated server the anticheat's movement check may log it. - A claim wins over #5649's `native_use_duration` for the same item; an unclaimed item takes exactly main's path. - The hand's stack at any other time is API 9's `native_held()`. Its doc now says that on a client it's the player's own. - docs/native-mods.md gets a section, "A client mod's view and items". They're helpers only: fragment `tools/native-hook-fragments/native_claimed_items.json`. No API number is edited. ## Kind - [x] feature ## Vanilla reference Horizon-only. - `BlockGetter.clip` near the player. - `Minecraft.startUseItem` / `MultiPlayerGameMode.useItem`, which a claimed item stands in for. - `LivingEntity.updatingUsingItem` / `stopUsingItem` for when a use ends. ## Other projects' code None from other projects. Ported from the author's own fork of Horizon (Stink-O/horizon, MIT): [ae531730c](https://github.com/Stink-O/horizon/commit/ae531730c), [896853699](https://github.com/Stink-O/horizon/commit/896853699), reshaped to native helpers. ## How it was tested - `cargo test -p horizon-client --bin horizon-client native_claimed_items` → `test result: ok. 4 passed`: - items are claimed by the first mod in id order; - events wait for their mod, up to a limit; - `an_interrupted_claimed_use_leaves_the_next_use_alone`; - `a_claimed_use_is_the_mods_while_it_runs`. - `python3 tools/lan_e2e.py --check eat --check eating --check helduse --check consume-release` (fast binaries of 24067ef56, before #5649 merged; this is a `needs-proof` PR: `remote.rs`): - eat, helduse and consume-release passed. - eating failed once ("the player beside the eater heard 8 bites, wants 9") and passed alone. The same check failed the same way once on a later build after #5649. - With no mod claiming anything every new branch returns early, so vanilla eating takes the same path as on main. - Stamped locally in a scratch worktree, not committed: `Stamped 5 fragment(s), through API 85`. ## For the merge - **Depends on:** nothing. - **Conflicts:** #5741's `Game` field now sits apart from this one's, so the two merge in either order. - **Risk:** it touches the client's use path (`remote.rs`), so it's a `needs-proof` PR. With no mod claiming anything every new branch returns early. **Rollback:** revert before the stamp PR merges; after that, fix forward. ## Self-check Approved by levzzz's agent with its fixes on top, and CI green there. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:21:05 +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#6462
No description provided.