diff options
| author | mat <git@matdoes.dev> | 2023-09-16 22:30:28 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-09-16 22:30:28 -0500 |
| commit | 61e63c08968f7b0f451c4c3b07ea8d4927b14a2f (patch) | |
| tree | f7b489bedde2a3bb9f703aa542c6863191f00ced /azalea-client/src/client.rs | |
| parent | a920359c9a8f254bbfb6c1d04f2bda6365c09c6b (diff) | |
| download | azalea-drasl-61e63c08968f7b0f451c4c3b07ea8d4927b14a2f.tar.xz | |
don't apply metadata updates multiple times in swarms
Diffstat (limited to 'azalea-client/src/client.rs')
| -rw-r--r-- | azalea-client/src/client.rs | 24 |
1 files changed, 24 insertions, 0 deletions
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::<Hunger>().to_owned() } + + /// Get the username of this client. + /// + /// This is a shortcut for + /// `bot.component::<GameProfileComponent>().name.clone()`. + pub fn username(&self) -> String { + self.component::<GameProfileComponent>().name.clone() + } + + /// Get the Minecraft UUID of this client. + /// + /// This is a shortcut for `bot.component::<GameProfileComponent>().uuid`. + pub fn uuid(&self) -> Uuid { + self.component::<GameProfileComponent>().uuid + } + + /// Get a map of player UUIDs to their information in the tab list. + /// + /// This is a shortcut for `bot.component::<TabList>().0`. + pub fn tab_list(&self) -> HashMap<Uuid, PlayerInfo> { + self.component::<TabList>().0 + } } /// A bundle for the components that are present on a local player that received |
