diff options
| author | mat <git@matdoes.dev> | 2025-02-22 22:34:06 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-02-22 22:34:06 +0000 |
| commit | 6fdf5fce497543d75b2c5a1f97bc35945bcfe74f (patch) | |
| tree | 73765f9457a8fcb9f208ee067ff2a911e3bea15a /azalea-client/src/configuration.rs | |
| parent | 444993b609d54124183fbcadee121c11897ee20e (diff) | |
| download | azalea-drasl-6fdf5fce497543d75b2c5a1f97bc35945bcfe74f.tar.xz | |
fix brand and client info so they're only sent when leaving login instead of entering config
closes #206
Diffstat (limited to 'azalea-client/src/configuration.rs')
| -rw-r--r-- | azalea-client/src/configuration.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/azalea-client/src/configuration.rs b/azalea-client/src/configuration.rs index bf07710b..0f198dbe 100644 --- a/azalea-client/src/configuration.rs +++ b/azalea-client/src/configuration.rs @@ -9,25 +9,30 @@ use azalea_protocol::{ }; use bevy_app::prelude::*; use bevy_ecs::prelude::*; +use tracing::{debug, warn}; -use crate::{client::InConfigState, packet_handling::configuration::SendConfigurationEvent}; +use crate::{ + client::InConfigState, + packet_handling::{configuration::SendConfigurationEvent, login::InLoginState}, +}; pub struct ConfigurationPlugin; impl Plugin for ConfigurationPlugin { fn build(&self, app: &mut App) { app.add_systems( Update, - handle_in_configuration_state + handle_end_login_state .before(crate::packet_handling::configuration::handle_send_packet_event), ); } } -fn handle_in_configuration_state( - query: Query<(Entity, &ClientInformation), Added<InConfigState>>, +fn handle_end_login_state( + mut removed: RemovedComponents<InLoginState>, + query: Query<&ClientInformation>, mut send_packet_events: EventWriter<SendConfigurationEvent>, ) { - for (entity, client_information) in query.iter() { + for entity in removed.read() { let mut brand_data = Vec::new(); // they don't have to know :) "vanilla".azalea_write(&mut brand_data).unwrap(); @@ -39,6 +44,15 @@ fn handle_in_configuration_state( }, )); + let client_information = match query.get(entity).ok() { + Some(i) => i, + None => { + warn!("ClientInformation component was not set before leaving login state, using a default"); + &ClientInformation::default() + } + }; + + debug!("Writing ClientInformation while in config state: {client_information:?}"); send_packet_events.send(SendConfigurationEvent::new( entity, ServerboundClientInformation { |
