[PR #6520] [MERGED] Native mods: a player swapping their hands, cancellable (native_player_swap_hands, part of #5816) #6931

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

📋 Pull Request Information

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

Base: main ← Head: feat-player-swap-hands-hook


📝 Commits (10+)

  • 8a65c97 Merge the profiles prerequisite onto current main for Setup
  • d48b592 Splitscreen: arrange players with a Setup map and Apply/Revert
  • fb0496a Align Setup pause icons and seed the saved switch in live checks
  • 69ce6f6 Merge current main into the Setup rebuild
  • ab3ebbd Native mods: a player swapping their hands, cancellable (native_player_swap_hands)
  • 8ac0773 Keep native mouse ownership when a second local player joins
  • a5da7ab Keep the native mouse regression fixture portable across filesystem paths
  • adea816 Merge current main into the Setup draft before localization fixes
  • b3dcefa Localize the splitscreen Setup screen and its window feedback
  • 972519a Setup's switch says On/Off from its own keys, not vanilla's ON/OFF

📊 Changes

29 files changed (+2098 additions, -122 deletions)

View changed files

📝 crates/horizon-client-render/src/chunk.rs (+12 -6)
📝 crates/horizon-client-render/src/lib.rs (+2 -0)
📝 crates/horizon-client-render/src/mesher.rs (+15 -19)
📝 crates/horizon-client-render/src/mesher/reuse_tests.rs (+60 -1)
📝 crates/horizon-client-render/src/mesher/sides.rs (+5 -4)
📝 crates/horizon-client-render/src/options_ui.rs (+32 -12)
📝 crates/horizon-client-render/src/split_layout.rs (+487 -25)
➕ crates/horizon-client-render/src/split_map.rs (+166 -0)
➕ crates/horizon-client-render/src/split_ui.rs (+716 -0)
📝 crates/horizon-client/assets/horizon/lang/en_us.json (+31 -2)
📝 crates/horizon-client/assets/horizon/lang/fr_fr.json (+35 -6)
📝 crates/horizon-client/src/client_lib.rs (+3 -3)
📝 crates/horizon-client/src/game.rs (+11 -6)
📝 crates/horizon-client/src/game/agent.rs (+9 -2)
📝 crates/horizon-client/src/game/lan_actions.rs (+19 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+13 -0)
📝 crates/horizon-client/src/game/screens.rs (+21 -10)
📝 crates/horizon-client/src/game/split.rs (+11 -10)
📝 crates/horizon-client/src/game/split/hud.rs (+8 -2)
📝 crates/horizon-client/src/game/split/players.rs (+1 -0)

...and 9 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). A mod could not hear or refuse a player swapping their main and off hand.

  • New hook point native_player_swap_hands(player, name, cancel) (fragment native_player_swap_hands.json, docs paragraph). Called in lan_actions.rs for the player action SWAP_ITEM_WITH_OFFHAND, through as_guest, so the player's state is swapped in and native_tell / the item helpers work. cancel stops the swap and resends the inventory to the client.
  • Nothing changes when no mod hooks it.

Kind

  • feature (new native hook point)

Vanilla reference

ServerGamePacketListenerImpl.handlePlayerAction (SWAP_ITEM_WITH_OFFHAND); NeoForge/Bukkit equivalent: PlayerSwapHandItemsEvent.

Other projects' code

none. (Tested with a throwaway horizon-mixins bundle, not part of this PR.)

Proof on a real dedicated server

Engine from the batch branch this commit comes from, plus a throwaway bundle; a bare protocol client holds an iron hoe in the main hand and a totem in the off hand.

control (no action)                         -> no hook line
swap                                        -> hook: swap_hands player=..., acting=Some(player), native_tell=true
swap with the mod cancelling                -> "cancelling"; offhand stays iron_hoe, slot 0 stays totem; 1 ContainerSetContent resent

Not covered: swapping from an open inventory, the LAN host as a player.

Self-check

pr_ready --quick --base upstream/main ran once on the whole branch that carries this and four other hook commits (11 files, +267 −3): Python tests 586 passed, rustfmt, clippy, horizon-client tests 1809 passed, doc tests pass; parity not run (--quick). This PR is that commit cherry-picked onto current main (48 lines): cargo test -p horizon-client native_hooks passes (20 tests).


🔄 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/6520 **Author:** [@Detimes](https://github.com/Detimes) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat-player-swap-hands-hook` --- ### 📝 Commits (10+) - [`8a65c97`](https://github.com/horizon-rust/horizon/commit/8a65c97f3b2ee6a1f2536db6faa2bedbca5f62a8) Merge the profiles prerequisite onto current main for Setup - [`d48b592`](https://github.com/horizon-rust/horizon/commit/d48b592ddde908a6ccba643cc27d1411bbdebd95) Splitscreen: arrange players with a Setup map and Apply/Revert - [`fb0496a`](https://github.com/horizon-rust/horizon/commit/fb0496a105f785cfb7e9165d3c228935161e9a6f) Align Setup pause icons and seed the saved switch in live checks - [`69ce6f6`](https://github.com/horizon-rust/horizon/commit/69ce6f6c2635ceb282e0d8ea9dfc0bf2197286d0) Merge current main into the Setup rebuild - [`ab3ebbd`](https://github.com/horizon-rust/horizon/commit/ab3ebbdd653d3348ff6e56460eabff0493dcbfd9) Native mods: a player swapping their hands, cancellable (native_player_swap_hands) - [`8ac0773`](https://github.com/horizon-rust/horizon/commit/8ac07733050b65418c83772146e6e6bc3f7eda85) Keep native mouse ownership when a second local player joins - [`a5da7ab`](https://github.com/horizon-rust/horizon/commit/a5da7abce2db7a399dd3d8cfe004284f77f344ed) Keep the native mouse regression fixture portable across filesystem paths - [`adea816`](https://github.com/horizon-rust/horizon/commit/adea816573d33afa17d8843006bec63c23c8e828) Merge current main into the Setup draft before localization fixes - [`b3dcefa`](https://github.com/horizon-rust/horizon/commit/b3dcefa2ac3f6c02e06d45b165c0bc1252a9d01f) Localize the splitscreen Setup screen and its window feedback - [`972519a`](https://github.com/horizon-rust/horizon/commit/972519acdc626ead6b8945c256b443ac10df92a2) Setup's switch says On/Off from its own keys, not vanilla's ON/OFF ### 📊 Changes **29 files changed** (+2098 additions, -122 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/chunk.rs` (+12 -6) 📝 `crates/horizon-client-render/src/lib.rs` (+2 -0) 📝 `crates/horizon-client-render/src/mesher.rs` (+15 -19) 📝 `crates/horizon-client-render/src/mesher/reuse_tests.rs` (+60 -1) 📝 `crates/horizon-client-render/src/mesher/sides.rs` (+5 -4) 📝 `crates/horizon-client-render/src/options_ui.rs` (+32 -12) 📝 `crates/horizon-client-render/src/split_layout.rs` (+487 -25) ➕ `crates/horizon-client-render/src/split_map.rs` (+166 -0) ➕ `crates/horizon-client-render/src/split_ui.rs` (+716 -0) 📝 `crates/horizon-client/assets/horizon/lang/en_us.json` (+31 -2) 📝 `crates/horizon-client/assets/horizon/lang/fr_fr.json` (+35 -6) 📝 `crates/horizon-client/src/client_lib.rs` (+3 -3) 📝 `crates/horizon-client/src/game.rs` (+11 -6) 📝 `crates/horizon-client/src/game/agent.rs` (+9 -2) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+19 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+13 -0) 📝 `crates/horizon-client/src/game/screens.rs` (+21 -10) 📝 `crates/horizon-client/src/game/split.rs` (+11 -10) 📝 `crates/horizon-client/src/game/split/hud.rs` (+8 -2) 📝 `crates/horizon-client/src/game/split/players.rs` (+1 -0) _...and 9 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). A mod could not hear or refuse a player swapping their main and off hand. - New hook point `native_player_swap_hands(player, name, cancel)` (fragment `native_player_swap_hands.json`, docs paragraph). Called in `lan_actions.rs` for the player action SWAP_ITEM_WITH_OFFHAND, through `as_guest`, so the player's state is swapped in and `native_tell` / the item helpers work. `cancel` stops the swap and resends the inventory to the client. - Nothing changes when no mod hooks it. ## Kind - [x] feature (new native hook point) ## Vanilla reference `ServerGamePacketListenerImpl.handlePlayerAction` (SWAP_ITEM_WITH_OFFHAND); NeoForge/Bukkit equivalent: `PlayerSwapHandItemsEvent`. ## Other projects' code none. (Tested with a throwaway horizon-mixins bundle, not part of this PR.) ## Proof on a real dedicated server Engine from the batch branch this commit comes from, plus a throwaway bundle; a bare protocol client holds an iron hoe in the main hand and a totem in the off hand. ``` control (no action) -> no hook line swap -> hook: swap_hands player=..., acting=Some(player), native_tell=true swap with the mod cancelling -> "cancelling"; offhand stays iron_hoe, slot 0 stays totem; 1 ContainerSetContent resent ``` Not covered: swapping from an open inventory, the LAN host as a player. ## Self-check `pr_ready --quick --base upstream/main` ran once on the whole branch that carries this and four other hook commits (11 files, +267 −3): Python tests 586 passed, rustfmt, clippy, `horizon-client` tests 1809 passed, doc tests pass; parity not run (`--quick`). This PR is that commit cherry-picked onto current main (48 lines): `cargo test -p horizon-client native_hooks` passes (20 tests). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:29:25 +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#6931
No description provided.