diff options
| author | mat <git@matdoes.dev> | 2025-03-07 19:11:24 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-03-07 19:11:24 +0000 |
| commit | 42c79043cf44bd462cbde79f9e87503520daebd7 (patch) | |
| tree | fa3282eca6108d775d6f87e3cb669c9a417ff08d /azalea-client/src/plugins/packet/game/events.rs | |
| parent | 28a17f3ed2143b40cdbab433f2ad757169813c67 (diff) | |
| download | azalea-drasl-42c79043cf44bd462cbde79f9e87503520daebd7.tar.xz | |
don't send game packets when outside of the game state
Diffstat (limited to 'azalea-client/src/plugins/packet/game/events.rs')
| -rw-r--r-- | azalea-client/src/plugins/packet/game/events.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/azalea-client/src/plugins/packet/game/events.rs b/azalea-client/src/plugins/packet/game/events.rs index e5c87971..5ba9972d 100644 --- a/azalea-client/src/plugins/packet/game/events.rs +++ b/azalea-client/src/plugins/packet/game/events.rs @@ -63,10 +63,18 @@ impl SendPacketEvent { pub fn handle_outgoing_packets( mut send_packet_events: EventReader<SendPacketEvent>, - mut query: Query<&mut RawConnection>, + mut query: Query<(&mut RawConnection, Option<&InGameState>)>, ) { for event in send_packet_events.read() { - if let Ok(raw_connection) = query.get_mut(event.sent_by) { + if let Ok((raw_connection, in_game_state)) = query.get_mut(event.sent_by) { + if in_game_state.is_none() { + error!( + "Tried to send a game packet {:?} while not in game state", + event.packet + ); + continue; + } + // debug!("Sending packet: {:?}", event.packet); if let Err(e) = raw_connection.write_packet(event.packet.clone()) { error!("Failed to send packet: {e}"); |
