mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
don't send game packets when outside of the game state
This commit is contained in:
parent
28a17f3ed2
commit
42c79043cf
2 changed files with 13 additions and 3 deletions
|
@ -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}");
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue