diff --git a/crates/horizon-client/src/game/hand.rs b/crates/horizon-client/src/game/hand.rs index d91d3b979..7c12223c9 100644 --- a/crates/horizon-client/src/game/hand.rs +++ b/crates/horizon-client/src/game/hand.rs @@ -144,6 +144,11 @@ impl Game<'_> { let harvest = !facts.requires_tool || self.res.items().correct_for_drops(held, &facts.name); speed / facts.hardness / if harvest { 30.0 } else { 100.0 } } + /// A key for the main-hand stack (`destroyingItem`): its item and components. + pub(super) fn main_hand_key(&self) -> String { + self.held() + .map_or(String::new(), |s| format!("{} {:?}", s.item, s.extra)) + } /// Whether an attack would hit an entity rather than the block behind /// it: the crosshair's `EntityHitResult`. pub(super) fn entity_targeted(&self) -> bool { @@ -445,9 +450,7 @@ impl HandWorld for GameHands<'_, '_> { true } fn main_hand_key(&mut self) -> String { - self.game - .held() - .map_or(String::new(), |s| format!("{} {:?}", s.item, s.extra)) + self.game.main_hand_key() } fn destroy_stage(&mut self, _: [i32; 3], _: Option) {} fn swing(&mut self, hand: Hand, animation: SwingAnimation) { diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index 77e143f9a..d128602c1 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -187,6 +187,8 @@ pub(super) struct Remote { /// The local player's profile name: its score holder and team member. pub(super) profile_name: String, destroying: Option<([i32; 3], u8, f32)>, + /// `MultiPlayerGameMode.destroyingItem`: the held item key the break began with. + destroying_item: String, destroy_delay: u32, input: horizon_client::interaction_input::InteractionInput, stop_mining: bool, @@ -471,6 +473,7 @@ impl Game<'_> { profile: 0, profile_name: String::new(), destroying: None, + destroying_item: String::new(), destroy_delay: 0, input: Default::default(), stop_mining: false, @@ -3837,6 +3840,8 @@ impl Game<'_> { } } + /// `MultiPlayerGameMode.stopDestroyBlock`: aborts the break and starts + /// the attack strength again. pub(super) fn stop_remote_mining(&mut self) { if let Some((pos, _, _)) = self.remote.as_mut().and_then(|r| r.destroying.take()) { self.send(S::PlayerAction(play::PlayerAction { @@ -3845,6 +3850,7 @@ impl Game<'_> { direction: 0, sequence: 0, })); + self.reset_attack_strength(); } } @@ -3898,11 +3904,11 @@ impl Game<'_> { } else { self.destroy_progress(hit.pos) }; - let same = self - .remote - .as_ref() - .and_then(|r| r.destroying) - .is_some_and(|(p, _, _)| p == hit.pos); + // sameDestroyTarget: the same block and still the item the break began with. + let held = self.main_hand_key(); + let same = self.remote.as_ref().is_some_and(|r| { + r.destroying.is_some_and(|(p, _, _)| p == hit.pos) && r.destroying_item == held + }); if start && same { return; } @@ -3929,6 +3935,7 @@ impl Game<'_> { } if let Some(r) = self.remote.as_mut() { r.destroying = Some((hit.pos, face, 0.0)); + r.destroying_item = held; } self.mining = Some(Mining { pos: hit.pos,