improve docs and rename model_customisation

This commit is contained in:
mat 2023-02-21 19:13:51 +00:00
parent d88ca2d865
commit 40073f5baa
3 changed files with 13 additions and 4 deletions

View file

@ -64,6 +64,9 @@ pub type ClientInformation = ServerboundClientInformationPacket;
/// To make a new client, use either [`azalea::ClientBuilder`] or
/// [`Client::join`].
///
/// Note that `Client` is inaccessible from systems (i.e. plugins), but you can
/// achieve everything that client can do with events.
///
/// [`azalea::ClientBuilder`]: https://docs.rs/azalea/latest/azalea/struct.ClientBuilder.html
#[derive(Clone)]
pub struct Client {
@ -467,6 +470,8 @@ impl Client {
}
/// Get a HashMap of all the players in the tab list.
///
/// Internally, this fetches the `players` field in [`LocalPlayer`].
pub fn players(&mut self) -> HashMap<Uuid, PlayerInfo> {
self.local_player(&mut self.ecs.lock()).players.clone()
}

View file

@ -13,12 +13,16 @@ use crate::{packet_handling::AddPlayerEvent, GameProfileComponent};
/// A player in the tab list.
#[derive(Debug, Clone)]
pub struct PlayerInfo {
/// Information about the player's Minecraft account, including their
/// username.
pub profile: GameProfile,
/// The player's UUID.
pub uuid: Uuid,
pub gamemode: GameType,
pub latency: i32,
/// The player's display name in the tab list.
/// The player's display name in the tab list, but only if it's different
/// from the player's normal username. Use `player_info.profile.name` to get
/// the player's actual username.
pub display_name: Option<FormattedText>,
}

View file

@ -15,7 +15,7 @@ pub struct ServerboundClientInformationPacket {
/// Whether the messages sent from the server should have colors. Note that
/// many servers ignore this and always send colored messages.
pub chat_colors: bool,
pub model_customisation: ModelCustomization,
pub model_customization: ModelCustomization,
pub main_hand: HumanoidArm,
pub text_filtering_enabled: bool,
/// Whether the client should show up as "Anonymous Player" in the server
@ -30,7 +30,7 @@ impl Default for ServerboundClientInformationPacket {
view_distance: 8,
chat_visibility: ChatVisibility::default(),
chat_colors: true,
model_customisation: ModelCustomization::default(),
model_customization: ModelCustomization::default(),
main_hand: HumanoidArm::Right,
text_filtering_enabled: false,
allows_listing: false,
@ -149,7 +149,7 @@ mod tests {
view_distance: 24,
chat_visibility: ChatVisibility::Hidden,
chat_colors: false,
model_customisation: ModelCustomization {
model_customization: ModelCustomization {
cape: false,
jacket: false,
left_sleeve: true,