azalea/client_impl/client_information.rs
1use azalea_client::ClientInformation;
2use azalea_protocol::packets::game;
3use tracing::debug;
4
5use crate::Client;
6
7impl Client {
8 /// Tell the server we changed our game options (i.e. render distance, main
9 /// hand).
10 ///
11 /// If this is not set before the login packet, the default will be sent.
12 ///
13 /// ```rust,no_run
14 /// # use azalea::{Client, ClientInformation};
15 /// # async fn example(bot: Client) -> Result<(), Box<dyn std::error::Error>> {
16 /// bot.set_client_information(ClientInformation {
17 /// view_distance: 2,
18 /// ..Default::default()
19 /// });
20 /// # Ok(())
21 /// # }
22 /// ```
23 pub fn set_client_information(&self, client_information: ClientInformation) {
24 self.query_self::<&mut ClientInformation, _>(|mut ci| {
25 *ci = client_information.clone();
26 });
27
28 if self.logged_in() {
29 debug!(
30 "Sending client information (already logged in): {:?}",
31 client_information
32 );
33 self.write_packet(game::s_client_information::ServerboundClientInformation {
34 client_information,
35 });
36 }
37 }
38}