From bc0cd9cc844853472e83c780e07ec3db2cbde7ad Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Fri, 16 Oct 2026 10:58:09 +0200 Subject: [PATCH] LAN guest: a use packet uses the item alone ServerGamePacketListenerImpl.handleUseItem takes the client's rotation and uses the held item, nothing else. The host ran the whole right click, with the block the guest had looked at before: a guest that turned from an ender chest to a double chest could get the ender chest opened again. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game.rs | 19 ++++++++++++------- crates/horizon-client/src/game/lan_actions.rs | 5 +++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index c9b97a198..d85489f3a 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -1017,6 +1017,9 @@ struct Game<'a> { saved_for_exit: bool, /// The block a guest is acting on (game/lan_actions.rs). forced_hit: Option, + /// A guest's `ServerboundUseItemPacket`: the held item alone, no block + /// or entity (`ServerGamePacketListenerImpl.handleUseItem`). + lan_item_only: bool, /// Level events of this tick for the guests, and the guest acting now. lan_events: Vec<(i32, [i32; 3], i32, Option)>, /// Block events (position, b0, b1, state) and entity events (id, event, @@ -2350,17 +2353,18 @@ impl Game<'_> { { return Ok(Some(Hand::Main)); } - if self.interact_frame() - || self.interact_armor_stand() - || self.interact_boat() - || self.interact_cart() - || self.interact_mob()? - || self.interact_knot() + if !self.lan_item_only + && (self.interact_frame() + || self.interact_armor_stand() + || self.interact_boat() + || self.interact_cart() + || self.interact_mob()? + || self.interact_knot()) { return Ok(Some(Hand::Main)); } // An EntityHitResult may fall through to Item.use, never to useItemOn. - let block_hit = if self.entity_targeted() { + let block_hit = if self.lan_item_only || self.entity_targeted() { None } else { self.pick() @@ -10169,6 +10173,7 @@ pub fn run() -> Result<()> { text_selection: Default::default(), saved_for_exit: false, forced_hit: None, + lan_item_only: false, lan_events: Vec::new(), lan_block_events: Vec::new(), lan_entity_events: Vec::new(), diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index e52cbeb71..52170de55 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -441,8 +441,13 @@ impl Game<'_> { if spectator { return; } + // handleUseItem: the client's rotation, then the item alone. What it + // looked at a moment ago (a block, a mob) is UseItemOn's or Interact's. self.as_guest(host, conn, |g| { + (g.yaw, g.pitch) = (p.yaw, p.pitch); + g.lan_item_only = true; let _ = g.use_item(); + g.lan_item_only = false; }); } S::Attack(p) => self.guest_attack(host, conn, p.id),