From d25f3674fbf865689e433ba84518cc45b8c5fa65 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 19 Sep 2022 19:19:20 -0700 Subject: [PATCH] Acknowledge only the latest dug block sequence --- src/client.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/client.rs b/src/client.rs index 0433565..6062905 100644 --- a/src/client.rs +++ b/src/client.rs @@ -222,7 +222,7 @@ pub struct Client { new_game_mode: GameMode, old_game_mode: GameMode, settings: Option, - dug_blocks: Vec, + dug_block_sequence: i32, /// Should be sent after login packet. msgs_to_send: Vec, bar_to_send: Option, @@ -293,7 +293,7 @@ impl Client { new_game_mode: GameMode::Survival, old_game_mode: GameMode::Survival, settings: None, - dug_blocks: Vec::new(), + dug_block_sequence: 0, msgs_to_send: Vec::new(), bar_to_send: None, resource_pack_to_send: None, @@ -911,22 +911,22 @@ impl Client { C2sPlayPacket::PlayerAbilitiesC2s(_) => {} C2sPlayPacket::PlayerAction(p) => { if p.sequence.0 != 0 { - self.dug_blocks.push(p.sequence.0); + self.dug_block_sequence = p.sequence.0; } self.events.push_back(match p.status { play::DiggingStatus::StartedDigging => ClientEvent::Digging { - status: event::DiggingStatus::Start, + status: DiggingStatus::Start, position: p.location, face: p.face, }, play::DiggingStatus::CancelledDigging => ClientEvent::Digging { - status: event::DiggingStatus::Cancel, + status: DiggingStatus::Cancel, position: p.location, face: p.face, }, play::DiggingStatus::FinishedDigging => ClientEvent::Digging { - status: event::DiggingStatus::Finish, + status: DiggingStatus::Finish, position: p.location, face: p.face, }, @@ -1279,13 +1279,14 @@ impl Client { } // Acknowledge broken blocks. - for seq in self.dug_blocks.drain(..) { + if self.dug_block_sequence != 0 { send_packet( &mut self.send, AcknowledgeBlockChange { - sequence: VarInt(seq), + sequence: VarInt(self.dug_block_sequence), }, - ) + ); + self.dug_block_sequence = 0; } // Teleport the player.