diff --git a/src/packets/serverbound/handshake.rs b/src/packets/serverbound/handshake.rs index 40f6a6a..97064f6 100644 --- a/src/packets/serverbound/handshake.rs +++ b/src/packets/serverbound/handshake.rs @@ -33,7 +33,7 @@ impl Handshake { let next_state = VarInt::parse(&mut reader).await?; // If you remove this, also fix get_next_state() to return an Option<> - if next_state.get_int() > 3 || next_state.get_int() < 0 { + if next_state.get_int() > 3 || next_state.get_int() < 1 { return None; } Some(Handshake { @@ -48,11 +48,18 @@ impl Handshake { self.server_address.get_value() } pub fn get_next_state(&self) -> ProtocolState { - match self.next_state.get_int() { + let state = self.next_state.get_int(); + match state { 1 => ProtocolState::Status, 2 => ProtocolState::Login, 3 => ProtocolState::Transfer, - _ => unreachable!(), + _ => { + tracing::error!( + next_state = state, + "invalid next_state for handshake packet!" + ); + unreachable!() + } } }