From 9513f42e87f64c409cdb2a100500a50e5a713bac Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sat, 27 Dec 2025 22:02:00 -0600 Subject: Move Client struct to azalea crate (#297) * move the Client struct out of azalea-client into azalea * actually add client impls in azalea --- azalea/src/client_impl/client_information.rs | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 azalea/src/client_impl/client_information.rs (limited to 'azalea/src/client_impl/client_information.rs') diff --git a/azalea/src/client_impl/client_information.rs b/azalea/src/client_impl/client_information.rs new file mode 100644 index 00000000..b3cf7927 --- /dev/null +++ b/azalea/src/client_impl/client_information.rs @@ -0,0 +1,38 @@ +use azalea_client::ClientInformation; +use azalea_protocol::packets::game; +use tracing::debug; + +use crate::Client; + +impl Client { + /// Tell the server we changed our game options (i.e. render distance, main + /// hand). + /// + /// If this is not set before the login packet, the default will be sent. + /// + /// ```rust,no_run + /// # use azalea::{Client, ClientInformation}; + /// # async fn example(bot: Client) -> Result<(), Box> { + /// bot.set_client_information(ClientInformation { + /// view_distance: 2, + /// ..Default::default() + /// }); + /// # Ok(()) + /// # } + /// ``` + pub fn set_client_information(&self, client_information: ClientInformation) { + self.query_self::<&mut ClientInformation, _>(|mut ci| { + *ci = client_information.clone(); + }); + + if self.logged_in() { + debug!( + "Sending client information (already logged in): {:?}", + client_information + ); + self.write_packet(game::s_client_information::ServerboundClientInformation { + client_information, + }); + } + } +} -- cgit v1.2.3