diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-11-18 22:11:30 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-18 22:11:30 -0600 |
| commit | befa22c1f3ff0c1f0cb745b3f4e736910c053a8b (patch) | |
| tree | 17037d0d62d1259366d9385c47236774886b4002 /azalea-client/src/player.rs | |
| parent | 6c6eb5572b869e3199adc560b101fa663c01b5d2 (diff) | |
| download | azalea-drasl-befa22c1f3ff0c1f0cb745b3f4e736910c053a8b.tar.xz | |
Player List (#41)
* keep track of player list
* send player update events
Diffstat (limited to 'azalea-client/src/player.rs')
| -rwxr-xr-x | azalea-client/src/player.rs | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/azalea-client/src/player.rs b/azalea-client/src/player.rs index a355831b..5db5c864 100755 --- a/azalea-client/src/player.rs +++ b/azalea-client/src/player.rs @@ -1,37 +1,39 @@ -use azalea_world::entity::Entity; +use azalea_auth::game_profile::GameProfile; +use azalea_chat::Component; +use azalea_core::GameType; +use azalea_world::entity::EntityData; use azalea_world::World; use uuid::Uuid; -/// Something that has a world associated to it. Usually, this is a `Client`. +/// Something that has a world associated to it. this is usually a `Client`. pub trait WorldHaver { fn world(&self) -> &World; } -/// A player in the world or tab list. -#[derive(Default, Debug)] -pub struct Player { - /// The player's uuid. +/// A player in the tab list. +#[derive(Debug, Clone)] +pub struct PlayerInfo { + pub profile: GameProfile, + /// The player's UUID. pub uuid: Uuid, - /// The player's entity id. - pub entity_id: u32, + pub gamemode: GameType, + pub latency: i32, + /// The player's display name in the tab list. + pub display_name: Option<Component>, } -impl Player { +impl PlayerInfo { /// Get a reference to the entity of the player in the world. - pub fn entity<'d>(&'d self, world: &'d World) -> Option<Entity<&World>> { - world.entity(self.entity_id) + pub fn entity<'d>(&'d self, world: &'d World) -> Option<&EntityData> { + world.entity_by_uuid(&self.uuid) } /// Get a mutable reference to the entity of the player in the world. - pub fn entity_mut<'d>(&'d self, world: &'d mut World) -> Option<Entity> { - world.entity_mut(self.entity_id) + pub fn entity_mut<'d>(&'d mut self, world: &'d mut World) -> Option<&'d mut EntityData> { + world.entity_mut_by_uuid(&self.uuid) } pub fn set_uuid(&mut self, uuid: Uuid) { self.uuid = uuid; } - - pub fn set_entity_id(&mut self, entity_id: u32) { - self.entity_id = entity_id; - } } |
