From 4a3ee778588a1d0e8bb1371668c208c451204b47 Mon Sep 17 00:00:00 2001 From: EmperialDev <98261860+EmperialDev@users.noreply.github.com> Date: Thu, 20 Oct 2022 21:21:05 +0200 Subject: [PATCH] Added sequence where it was missing (#127) --- src/client.rs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) 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); + } + } } }