1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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<dyn std::error::Error>> {
/// 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,
});
}
}
}