Merge remote-tracking branch 'origin/main' into perf/shared-block-json-20261017

This commit is contained in:
rdbtCVS
2026-10-17 02:27:02 +01:00
3 changed files with 27 additions and 8 deletions
+3
View File
@@ -3648,6 +3648,9 @@ impl Game<'_> {
) || self.book.is_some())
}
fn capture(&mut self, capture: bool) {
if !capture {
self.stop_mining();
}
// The real pointer takes over from an agent's.
self.agent_pointer = false;
let Some(window) = &self.window else { return };
+12
View File
@@ -30,6 +30,18 @@ fn attack_range_contains(range: &serde_json::Value, distance: f64, creative: boo
}
impl Game<'_> {
/// Opening a screen stops breaking before the next game tick (which may pause).
pub(super) fn stop_mining(&mut self) {
let mut destroying = std::mem::take(&mut self.clicks.destroying);
destroying.stop(&mut GameHands {
game: self,
error: None,
});
self.clicks.destroying = destroying;
self.attack_clicks = 0;
self.stop_remote_mining();
self.mining = None;
}
/// `LivingEntity.swing` with `getModifiedSwingDuration`.
pub(super) fn swing_hand(&mut self, hand: Hand, animation: SwingAnimation) {
let effects = &self.potions.effects;
+12 -8
View File
@@ -2071,6 +2071,17 @@ impl Game<'_> {
}
}
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 {
action: 2,
pos,
direction: 0,
sequence: 0,
}));
}
}
/// MultiPlayerGameMode.startDestroyBlock / continueDestroyBlock.
fn remote_mining(&mut self) {
let Some(r) = self.remote.as_mut() else {
@@ -2081,14 +2092,7 @@ impl Game<'_> {
}
let chatting = r.chat_input.is_some();
if !self.left || self.screen != Screen::Playing || chatting {
if let Some((pos, _, _)) = r.destroying.take() {
self.send(S::PlayerAction(play::PlayerAction {
action: 2,
pos,
direction: 0,
sequence: 0,
}));
}
self.stop_remote_mining();
self.mining = None;
return;
}