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 | |
| parent | 28a17f3ed2143b40cdbab433f2ad757169813c67 (diff) | |
| download | azalea-drasl-42c79043cf44bd462cbde79f9e87503520daebd7.tar.xz | |
don't send game packets when outside of the game state
| -rw-r--r-- | azalea-client/src/plugins/packet/game/events.rs | 12 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/mod.rs | 4 |
2 files changed, 13 insertions, 3 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}"); diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index a13f1490..a715a77e 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -1503,10 +1503,12 @@ impl GamePacketHandler<'_> { } pub fn start_configuration(&mut self, _p: &ClientboundStartConfiguration) { + debug!("Got start configuration packet"); + as_system::<(Commands, EventWriter<_>)>(self.ecs, |(mut commands, mut events)| { events.send(SendPacketEvent::new( self.player, - ServerboundConfigurationAcknowledged {}, + ServerboundConfigurationAcknowledged, )); commands |
