diff --git a/src/client.rs b/src/client.rs index 1ec2494..5e7e732 100644 --- a/src/client.rs +++ b/src/client.rs @@ -2,8 +2,8 @@ use std::collections::{HashSet, VecDeque}; use std::iter::FusedIterator; -use std::mem; use std::time::Duration; +use std::{cmp, mem}; pub use bitfield_struct::bitfield; pub use event::*; @@ -1034,7 +1034,7 @@ impl Client { C2sPlayPacket::PlayerAbilitiesC2s(_) => {} C2sPlayPacket::PlayerAction(p) => { if p.sequence.0 != 0 { - self.block_change_sequence = p.sequence.0; + self.block_change_sequence = cmp::max(p.sequence.0, self.block_change_sequence); } self.events.push_back(match p.status { @@ -1112,15 +1112,25 @@ impl Client { C2sPlayPacket::UpdateSign(_) => {} C2sPlayPacket::SwingArm(p) => self.events.push_back(ClientEvent::ArmSwing(p.hand)), C2sPlayPacket::TeleportToEntity(_) => {} - C2sPlayPacket::UseItemOn(p) => self.events.push_back(ClientEvent::InteractWithBlock { - hand: p.hand, - location: p.location, - face: p.face, - cursor_pos: p.cursor_pos, - head_inside_block: p.head_inside_block, - sequence: p.sequence, - }), - C2sPlayPacket::UseItem(_) => {} + C2sPlayPacket::UseItemOn(p) => { + if p.sequence.0 != 0 { + self.block_change_sequence = cmp::max(p.sequence.0, self.block_change_sequence); + } + + self.events.push_back(ClientEvent::InteractWithBlock { + hand: p.hand, + location: p.location, + face: p.face, + cursor_pos: p.cursor_pos, + head_inside_block: p.head_inside_block, + sequence: p.sequence, + }) + } + C2sPlayPacket::UseItem(p) => { + if p.sequence.0 != 0 { + self.block_change_sequence = cmp::max(p.sequence.0, self.block_change_sequence); + } + } } }