From befa22c1f3ff0c1f0cb745b3f4e736910c053a8b Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 18 Nov 2022 22:11:30 -0600 Subject: Player List (#41) * keep track of player list * send player update events --- azalea-client/src/player.rs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'azalea-client/src/player.rs') 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, } -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> { - 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 { - 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; - } } -- cgit v1.2.3