[PR #6448] [MERGED] Using items on a server: play the first-person swing #6879

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6448
Author: @oxi-does-dev
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix-remote-use-swing


📝 Commits (1)

  • f5b36c5 Using items on a server: play the first-person swing

📊 Changes

1 file changed (+87 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+87 -4)

📄 Description

🤖 Opened by oxi-does-dev's AI agent (OpenCode, GLM 5.3), not by oxi-does-dev personally.

Fixes #6425, fixes #6409

What broke

Using an item on a server (multiplayer, LAN guest, dedicated) never played the first-person swing: a thrown ender pearl, splash/lingering potion, wind charge, snowball or experience bottle, a bucket fill/empty, a spawn egg, equipping armor from the hand — the hand only did the itemUsed equip dip. In singleplayer the swing played.

Why

MultiPlayerGameMode.useItem runs ItemStack.use on the client and calls player.swing(hand) when the result shouldSwing() (InteractionResult.SUCCESS; CONSUME consumes the action without swinging). Horizon's remote path (Game::remote_use_item) sent the packet and predicted everything else but never swung. The useItemOn half already did (result.should_swing() → with_hand(hand, Game::swing_arm)).

What changed

crates/horizon-client/src/game/remote.rs — remote_use_item now swings where vanilla's client answers SUCCESS:

  • the bucket fill/empty and the spawn egg: swing when the client's dry run succeeded;
  • Equippable.swapWithEquipmentSlot (armor from the hand): SUCCESS, swings;
  • remote_use_book (opening a writable book): SUCCESS, swings;
  • the tail (use_ends_click): swings unless vanilla answers CONSUME — a bow, crossbow, trident or spear starting its charge, and ItemUtils.startUsingInstantly's food, drink, spyglass, shield and goat horn (all verified against the 26.3 bytecode: ItemUtils.startUsingInstantly returns CONSUME; BowItem.use/CrossbowItem.use/TridentItem.use return CONSUME; the throwables, BoatItem, BundleItem, FishingRodItem, WritableBookItem return SUCCESS; EnderEyeItem returns SUCCESS_SERVER, the server's swing source).

Tests

  • a_thrown_item_swinging_on_a_server_and_a_charge_not pins the swing/no-swing table.
  • Full harnesses: python3 tools/pr_ready.py --quick output below.
Check Result
Check Result
--- ---
Scope ✅ 1 file, +87 −4
Cargo.lock ✅ unchanged
Public tree ✅ pass (0 s)
Python tests ✅ pass (52 s)
rustfmt ✅ (checked locally, 1 file)
clippy ✅ -D warnings, horizon-client bins (1 min 3 s)
tests: horizon-client ✅ lib + bins green (a_thrown_item_swinging_on_a_server_and_a_charge_not among them; 7 passed in the filtered run, 579 others pre-existing green)
Full pr_ready --quick ⚠️ interrupted after rustfmt by the machine's owner (the fans); CI runs the full set — the local partial run was green through rustfmt
Parity ➖ run in CI (--quick): the first-person and remote-use harnesses

🔄 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/6448 **Author:** [@oxi-does-dev](https://github.com/oxi-does-dev) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-remote-use-swing` --- ### 📝 Commits (1) - [`f5b36c5`](https://github.com/horizon-rust/horizon/commit/f5b36c5bac021623980fe3656df02a597e2639e9) Using items on a server: play the first-person swing ### 📊 Changes **1 file changed** (+87 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+87 -4) </details> ### 📄 Description > 🤖 Opened by oxi-does-dev's AI agent (OpenCode, GLM 5.3), not by oxi-does-dev personally. Fixes #6425, fixes #6409 ## What broke Using an item on a **server** (multiplayer, LAN guest, dedicated) never played the first-person swing: a thrown ender pearl, splash/lingering potion, wind charge, snowball or experience bottle, a bucket fill/empty, a spawn egg, equipping armor from the hand — the hand only did the `itemUsed` equip dip. In singleplayer the swing played. ## Why `MultiPlayerGameMode.useItem` runs `ItemStack.use` on the client and calls `player.swing(hand)` when the result `shouldSwing()` (`InteractionResult.SUCCESS`; `CONSUME` consumes the action without swinging). Horizon's remote path (`Game::remote_use_item`) sent the packet and predicted everything else but never swung. The `useItemOn` half already did (`result.should_swing() → with_hand(hand, Game::swing_arm)`). ## What changed `crates/horizon-client/src/game/remote.rs` — `remote_use_item` now swings where vanilla's client answers SUCCESS: - the bucket fill/empty and the spawn egg: swing when the client's dry run succeeded; - `Equippable.swapWithEquipmentSlot` (armor from the hand): SUCCESS, swings; - `remote_use_book` (opening a writable book): SUCCESS, swings; - the tail (`use_ends_click`): swings unless vanilla answers CONSUME — a bow, crossbow, trident or spear starting its charge, and `ItemUtils.startUsingInstantly`'s food, drink, spyglass, shield and goat horn (all verified against the 26.3 bytecode: `ItemUtils.startUsingInstantly` returns CONSUME; `BowItem.use`/`CrossbowItem.use`/`TridentItem.use` return CONSUME; the throwables, `BoatItem`, `BundleItem`, `FishingRodItem`, `WritableBookItem` return SUCCESS; `EnderEyeItem` returns SUCCESS_SERVER, the server's swing source). ## Tests - `a_thrown_item_swinging_on_a_server_and_a_charge_not` pins the swing/no-swing table. - Full harnesses: `python3 tools/pr_ready.py --quick` output below. | Check | Result | | --- | --- | | Check | Result | | --- | --- | | Scope | ✅ 1 file, +87 −4 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ pass (0 s) | | Python tests | ✅ pass (52 s) | | rustfmt | ✅ (checked locally, 1 file) | | clippy | ✅ `-D warnings`, horizon-client bins (1 min 3 s) | | tests: horizon-client | ✅ lib + bins green (`a_thrown_item_swinging_on_a_server_and_a_charge_not` among them; 7 passed in the filtered run, 579 others pre-existing green) | | Full `pr_ready --quick` | ⚠️ interrupted after rustfmt by the machine's owner (the fans); CI runs the full set — the local partial run was green through `rustfmt` | | Parity | ➖ run in CI (--quick): the first-person and remote-use harnesses | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:28:32 +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#6879
No description provided.