aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-09-15 17:09:04 -0500
committermat <git@matdoes.dev>2023-09-15 17:09:04 -0500
commitb6586d500cc01b790aa11b019cca9a829e3efc27 (patch)
treec40e57151fa2b5dcad45175772f6373bc63a4277 /azalea-client/src
parent659b6a1175298f4e2204c151e1fab0e18548f2ce (diff)
downloadazalea-drasl-b6586d500cc01b790aa11b019cca9a829e3efc27.tar.xz
make Account a component
Diffstat (limited to 'azalea-client/src')
-rwxr-xr-xazalea-client/src/account.rs3
-rw-r--r--azalea-client/src/client.rs50
2 files changed, 28 insertions, 25 deletions
diff --git a/azalea-client/src/account.rs b/azalea-client/src/account.rs
index 0e67a79a..46d0a728 100755
--- a/azalea-client/src/account.rs
+++ b/azalea-client/src/account.rs
@@ -5,6 +5,7 @@ use std::sync::Arc;
use crate::get_mc_dir;
use azalea_auth::certs::{Certificates, FetchCertificatesError};
use azalea_auth::AccessTokenResponse;
+use bevy_ecs::component::Component;
use parking_lot::Mutex;
use thiserror::Error;
use uuid::Uuid;
@@ -28,7 +29,7 @@ use uuid::Uuid;
///
/// [`Client::join`]: crate::Client::join
/// [`azalea::ClientBuilder`]: https://docs.rs/azalea/latest/azalea/struct.ClientBuilder.html
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Component)]
pub struct Account {
/// The Minecraft username of the account.
pub username: String,
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index f26fe6d8..561c5a24 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -260,8 +260,7 @@ impl Client {
let mut ecs = ecs_lock.lock();
// Make the ecs entity for this client
- let entity_mut = ecs.spawn_empty();
- let entity = entity_mut.id();
+ let entity = ecs.spawn_empty().id();
// we got the GameConnection, so the server is now connected :)
let client = Client::new(
@@ -296,28 +295,31 @@ impl Client {
write_packets_task,
);
- ecs.entity_mut(entity).insert(JoinedClientBundle {
- local_player,
- packet_receiver,
- game_profile: GameProfileComponent(game_profile),
- physics_state: PhysicsState::default(),
- local_player_events: LocalPlayerEvents(tx),
- inventory: InventoryComponent::default(),
- client_information: ClientInformation::default(),
- tab_list: TabList::default(),
- current_sequence_number: CurrentSequenceNumber::default(),
- last_sent_direction: LastSentLookDirection::default(),
- abilities: PlayerAbilities::default(),
- permission_level: PermissionLevel::default(),
- hunger: Hunger::default(),
-
- entity_id_index: EntityIdIndex::default(),
-
- mining: mining::MineBundle::default(),
- attack: attack::AttackBundle::default(),
-
- _local: LocalEntity,
- });
+ ecs.entity_mut(entity).insert((
+ account.to_owned(),
+ JoinedClientBundle {
+ local_player,
+ packet_receiver,
+ game_profile: GameProfileComponent(game_profile),
+ physics_state: PhysicsState::default(),
+ local_player_events: LocalPlayerEvents(tx),
+ inventory: InventoryComponent::default(),
+ client_information: ClientInformation::default(),
+ tab_list: TabList::default(),
+ current_sequence_number: CurrentSequenceNumber::default(),
+ last_sent_direction: LastSentLookDirection::default(),
+ abilities: PlayerAbilities::default(),
+ permission_level: PermissionLevel::default(),
+ hunger: Hunger::default(),
+
+ entity_id_index: EntityIdIndex::default(),
+
+ mining: mining::MineBundle::default(),
+ attack: attack::AttackBundle::default(),
+
+ _local: LocalEntity,
+ },
+ ));
Ok((client, rx))
}