[PR #313] [MERGED] Use the off hand when the main hand passes: place blocks, eat, charge anchors #2483

Closed
opened 2026-11-02 15:56:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/313
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: fix/offhand-use


📝 Commits (2)

  • ffd0297 Crossbows load firework rockets from either hand; bows and crossbows take held arrows first
  • 5e29357 Use the off hand when the main hand passes: place blocks, eat, charge anchors

📊 Changes

20 files changed (+365 additions, -237 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+151 -111)
📝 crates/horizon-client/src/game/armor_stands.rs (+2 -2)
📝 crates/horizon-client/src/game/books.rs (+2 -2)
📝 crates/horizon-client/src/game/creatures.rs (+4 -4)
📝 crates/horizon-client/src/game/crossbow.rs (+120 -32)
📝 crates/horizon-client/src/game/dispense_fixture.rs (+16 -8)
📝 crates/horizon-client/src/game/dispenser.rs (+1 -1)
📝 crates/horizon-client/src/game/fireworks.rs (+3 -2)
📝 crates/horizon-client/src/game/fov.rs (+1 -1)
📝 crates/horizon-client/src/game/hand.rs (+12 -7)
📝 crates/horizon-client/src/game/maps.rs (+1 -1)
📝 crates/horizon-client/src/game/potions.rs (+7 -7)
📝 crates/horizon-client/src/game/powder_snow.rs (+1 -1)
📝 crates/horizon-client/src/game/raids.rs (+2 -2)
📝 crates/horizon-client/src/game/respawn_anchor.rs (+3 -28)
📝 crates/horizon-client/src/game/shield.rs (+1 -5)
📝 crates/horizon-client/src/game/trident.rs (+5 -5)
📝 crates/horizon-client/src/game/wind.rs (+2 -2)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java (+20 -15)
📝 tools/test_use_item_on_parity.py (+11 -1)

📄 Description

Part of #276. Thanks to Cosmic (Online5277) for the report. Stacked on #312: review only the top commit.

What

Right-click now falls through to the off hand when the main hand does nothing, as in vanilla. Blocks can be placed from the off hand, and food, potions, buckets, bone meal, seeds, spawn eggs, shields and the rest work there too. Glowstone in the off hand charges a respawn anchor.

Why

Minecraft.startUseItem loops over InteractionHand.values(). For each hand it tries useItemOn and then useItem, and stops at the first that succeeds or fails. The empty-hand block use (useWithoutItem) runs only for the main hand. Horizon used only the main hand, plus a few off-hand special cases.

How

  • Game::hand is the hand an item use acts with. held, held_mut, held_slot, consume_held, damage_held and swing_arm follow it, and with_hand runs a use with a given hand.
  • use_item_as_player loops over both hands through use_hand. Sneaking with something in either hand suppresses block uses, as in vanilla.
  • The item in use keeps its hand: tick_using runs with the hand of the slot in use (40 for the off hand). The equip/re-equip animation (itemUsed) and the swing go to the hand that acted.
  • The anchor's PASS, when the main hand isn't glowstone and the off hand is, replaces the old charge_anchor_from_offhand special case. The same goes for use_offhand.
  • Uses converted to the acting hand: potions, ominous bottles, books, maps, powder snow, wind charges, tridents, spyglass, spawn eggs, throwables, cauldrons and armor stands (equip).

Entity interactions (interactOn: leads, trading, saddles and so on) still use only the main hand.

How tested

  • The use_item_on harness now puts items in the off hand too. Anchors get glowstone or an apple there 40% of the time. Other cases move the item to the off hand 30% of the time, leaving the main hand empty or holding a stick, apple, stone, bone meal or shield. The oracle loops over both hands like startUseItem. Result: 4000/4000 cases match, including off-hand placements, berries, seeds, bone meal and glowstone anchor charges.
  • In game: a gold block placed from the off hand while the main hand held a stick (fp-offhand-block-placed.png), and a shield raised from the off hand with a sword in the main hand (fp-shield-raised.png).
Self-check (Mac mini), all five branches of this batch rebased on origin/main 050b2038:
- cargo fmt --all --check: OK
- cargo clippy --workspace --all-targets -- -D warnings: OK on this branch alone, and on the integration of all five
- cargo test -p horizon-client (integration): 649 + 41 + 15 + 2 + 2 + 1 passed, 0 failed
- tools/parity.py --changed origin/main on the integration commit: 79 passed, 0 failed
  (including arrow, use_item_on, first_person, dispenser and mob_ai)
- tools/parity.py, run explicitly: player_hurt, blocking_rules, blocking_item_damage, item_use, item_use_start,
  item_use_lifecycle, living_hurt, damage_reduction, player_equipment, registered_player_combat,
  server_player_combat, server_player_damage: 12 passed, 0 failed

Screenshots: ~/code/horizon-parity/shots/offhand-276/ on the Mac mini.

Needs Ludovic

Nothing.

🤖 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/313 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/offhand-use` --- ### 📝 Commits (2) - [`ffd0297`](https://github.com/horizon-rust/horizon/commit/ffd0297dc421e499c7567e4602d91e5fe652a1b9) Crossbows load firework rockets from either hand; bows and crossbows take held arrows first - [`5e29357`](https://github.com/horizon-rust/horizon/commit/5e2935747bca16333b9d048fd67f0ca6c90a92c8) Use the off hand when the main hand passes: place blocks, eat, charge anchors ### 📊 Changes **20 files changed** (+365 additions, -237 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+151 -111) 📝 `crates/horizon-client/src/game/armor_stands.rs` (+2 -2) 📝 `crates/horizon-client/src/game/books.rs` (+2 -2) 📝 `crates/horizon-client/src/game/creatures.rs` (+4 -4) 📝 `crates/horizon-client/src/game/crossbow.rs` (+120 -32) 📝 `crates/horizon-client/src/game/dispense_fixture.rs` (+16 -8) 📝 `crates/horizon-client/src/game/dispenser.rs` (+1 -1) 📝 `crates/horizon-client/src/game/fireworks.rs` (+3 -2) 📝 `crates/horizon-client/src/game/fov.rs` (+1 -1) 📝 `crates/horizon-client/src/game/hand.rs` (+12 -7) 📝 `crates/horizon-client/src/game/maps.rs` (+1 -1) 📝 `crates/horizon-client/src/game/potions.rs` (+7 -7) 📝 `crates/horizon-client/src/game/powder_snow.rs` (+1 -1) 📝 `crates/horizon-client/src/game/raids.rs` (+2 -2) 📝 `crates/horizon-client/src/game/respawn_anchor.rs` (+3 -28) 📝 `crates/horizon-client/src/game/shield.rs` (+1 -5) 📝 `crates/horizon-client/src/game/trident.rs` (+5 -5) 📝 `crates/horizon-client/src/game/wind.rs` (+2 -2) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java` (+20 -15) 📝 `tools/test_use_item_on_parity.py` (+11 -1) </details> ### 📄 Description Part of #276. Thanks to Cosmic (Online5277) for the report. Stacked on #312: review only the top commit. ## What Right-click now falls through to the off hand when the main hand does nothing, as in vanilla. Blocks can be placed from the off hand, and food, potions, buckets, bone meal, seeds, spawn eggs, shields and the rest work there too. Glowstone in the off hand charges a respawn anchor. ## Why `Minecraft.startUseItem` loops over `InteractionHand.values()`. For each hand it tries `useItemOn` and then `useItem`, and stops at the first that succeeds or fails. The empty-hand block use (`useWithoutItem`) runs only for the main hand. Horizon used only the main hand, plus a few off-hand special cases. ## How - `Game::hand` is the hand an item use acts with. `held`, `held_mut`, `held_slot`, `consume_held`, `damage_held` and `swing_arm` follow it, and `with_hand` runs a use with a given hand. - `use_item_as_player` loops over both hands through `use_hand`. Sneaking with something in either hand suppresses block uses, as in vanilla. - The item in use keeps its hand: `tick_using` runs with the hand of the slot in use (40 for the off hand). The equip/re-equip animation (`itemUsed`) and the swing go to the hand that acted. - The anchor's `PASS`, when the main hand isn't glowstone and the off hand is, replaces the old `charge_anchor_from_offhand` special case. The same goes for `use_offhand`. - Uses converted to the acting hand: potions, ominous bottles, books, maps, powder snow, wind charges, tridents, spyglass, spawn eggs, throwables, cauldrons and armor stands (equip). Entity interactions (`interactOn`: leads, trading, saddles and so on) still use only the main hand. ## How tested - The `use_item_on` harness now puts items in the off hand too. Anchors get glowstone or an apple there 40% of the time. Other cases move the item to the off hand 30% of the time, leaving the main hand empty or holding a stick, apple, stone, bone meal or shield. The oracle loops over both hands like `startUseItem`. Result: 4000/4000 cases match, including off-hand placements, berries, seeds, bone meal and glowstone anchor charges. - In game: a gold block placed from the off hand while the main hand held a stick (`fp-offhand-block-placed.png`), and a shield raised from the off hand with a sword in the main hand (`fp-shield-raised.png`). ``` Self-check (Mac mini), all five branches of this batch rebased on origin/main 050b2038: - cargo fmt --all --check: OK - cargo clippy --workspace --all-targets -- -D warnings: OK on this branch alone, and on the integration of all five - cargo test -p horizon-client (integration): 649 + 41 + 15 + 2 + 2 + 1 passed, 0 failed - tools/parity.py --changed origin/main on the integration commit: 79 passed, 0 failed (including arrow, use_item_on, first_person, dispenser and mob_ai) - tools/parity.py, run explicitly: player_hurt, blocking_rules, blocking_item_damage, item_use, item_use_start, item_use_lifecycle, living_hurt, damage_reduction, player_equipment, registered_player_combat, server_player_combat, server_player_damage: 12 passed, 0 failed ``` Screenshots: ~/code/horizon-parity/shots/offhand-276/ on the Mac mini. ## Needs Ludovic Nothing. 🤖 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-02 15:56:34 +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#2483
No description provided.