From 61e63c08968f7b0f451c4c3b07ea8d4927b14a2f Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 16 Sep 2023 22:30:28 -0500 Subject: don't apply metadata updates multiple times in swarms --- azalea-client/src/client.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'azalea-client/src/client.rs') diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 0cf01582..6b2dba57 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -87,6 +87,8 @@ pub struct Client { /// This is immutable; the server cannot change it. To get the username and /// skin the server chose for you, get your player from the [`TabList`] /// component. + /// + /// This as also available from the ECS as [`GameProfileComponent`]. pub profile: GameProfile, /// The entity for this client in the ECS. pub entity: Entity, @@ -580,6 +582,28 @@ impl Client { pub fn hunger(&self) -> Hunger { self.component::().to_owned() } + + /// Get the username of this client. + /// + /// This is a shortcut for + /// `bot.component::().name.clone()`. + pub fn username(&self) -> String { + self.component::().name.clone() + } + + /// Get the Minecraft UUID of this client. + /// + /// This is a shortcut for `bot.component::().uuid`. + pub fn uuid(&self) -> Uuid { + self.component::().uuid + } + + /// Get a map of player UUIDs to their information in the tab list. + /// + /// This is a shortcut for `bot.component::().0`. + pub fn tab_list(&self) -> HashMap { + self.component::().0 + } } /// A bundle for the components that are present on a local player that received -- cgit v1.2.3