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),