From e21e1b97bf9337e9f4747cd1b545b1b3a03e2ce7 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sat, 22 Feb 2025 21:45:26 -0600 Subject: Refactor azalea-client (#205) * start organizing packet_handling more by moving packet handlers into their own functions * finish writing all the handler functions for packets * use macro for generating match statement for packet handler functions * fix set_entity_data * update config state to also use handler functions * organize az-client file structure by moving things into plugins directory * fix merge issues --- azalea-client/src/configuration.rs | 62 -------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 azalea-client/src/configuration.rs (limited to 'azalea-client/src/configuration.rs') diff --git a/azalea-client/src/configuration.rs b/azalea-client/src/configuration.rs deleted file mode 100644 index d578be7a..00000000 --- a/azalea-client/src/configuration.rs +++ /dev/null @@ -1,62 +0,0 @@ -use azalea_buf::AzaleaWrite; -use azalea_core::resource_location::ResourceLocation; -use azalea_protocol::{ - common::client_information::ClientInformation, - packets::config::{ - s_client_information::ServerboundClientInformation, - s_custom_payload::ServerboundCustomPayload, - }, -}; -use bevy_app::prelude::*; -use bevy_ecs::prelude::*; -use tracing::{debug, warn}; - -use crate::packet_handling::{configuration::SendConfigurationEvent, login::InLoginState}; - -pub struct ConfigurationPlugin; -impl Plugin for ConfigurationPlugin { - fn build(&self, app: &mut App) { - app.add_systems( - Update, - handle_end_login_state - .before(crate::packet_handling::configuration::handle_send_packet_event), - ); - } -} - -fn handle_end_login_state( - mut removed: RemovedComponents, - query: Query<&ClientInformation>, - mut send_packet_events: EventWriter, -) { - for entity in removed.read() { - let mut brand_data = Vec::new(); - // they don't have to know :) - "vanilla".azalea_write(&mut brand_data).unwrap(); - send_packet_events.send(SendConfigurationEvent::new( - entity, - ServerboundCustomPayload { - identifier: ResourceLocation::new("brand"), - data: brand_data.into(), - }, - )); - - 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 { - information: client_information.clone(), - }, - )); - } -} -- cgit v1.2.3