aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/local_player.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-02-01 20:35:57 +0000
committermat <git@matdoes.dev>2025-02-01 20:35:57 +0000
commit87c34e1c3355e2b950f3c6f4ae44dcdfb775bbca (patch)
treef725697c27f1959a97d48d5ed6e4a25266dcdd6b /azalea-client/src/local_player.rs
parent4aa5010ea2dec8633be29b0a06c9b2233d7a6522 (diff)
downloadazalea-drasl-87c34e1c3355e2b950f3c6f4ae44dcdfb775bbca.tar.xz
add failing test_set_health_before_login test
Diffstat (limited to 'azalea-client/src/local_player.rs')
-rw-r--r--azalea-client/src/local_player.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs
index 7c9254a7..2d691826 100644
--- a/azalea-client/src/local_player.rs
+++ b/azalea-client/src/local_player.rs
@@ -20,14 +20,23 @@ use crate::{
/// A component that keeps strong references to our [`PartialInstance`] and
/// [`Instance`] for local players.
+///
+/// This can also act as a convenience for accessing the player's Instance since
+/// the alternative is to look up the player's [`InstanceName`] in the
+/// [`InstanceContainer`].
+///
+/// [`InstanceContainer`]: azalea_world::InstanceContainer
+/// [`InstanceName`]: azalea_world::InstanceName
#[derive(Component, Clone)]
pub struct InstanceHolder {
/// The partial instance is the world this client currently has loaded. It
/// has a limited render distance.
pub partial_instance: Arc<RwLock<PartialInstance>>,
/// The world is the combined [`PartialInstance`]s of all clients in the
- /// same world. (Only relevant if you're using a shared world, i.e. a
- /// swarm)
+ /// same world.
+ ///
+ /// This is only relevant if you're using a shared world (i.e. a
+ /// swarm).
pub instance: Arc<RwLock<Instance>>,
}
@@ -114,12 +123,16 @@ impl Default for Hunger {
}
impl InstanceHolder {
- /// Create a new `InstanceHolder`.
- pub fn new(entity: Entity, world: Arc<RwLock<Instance>>) -> Self {
+ /// Create a new `InstanceHolder` for the given entity.
+ ///
+ /// The partial instance will be created for you. The render distance will
+ /// be set to a default value, which you can change by creating a new
+ /// partial_instance.
+ pub fn new(entity: Entity, instance: Arc<RwLock<Instance>>) -> Self {
let client_information = ClientInformation::default();
InstanceHolder {
- instance: world,
+ instance,
partial_instance: Arc::new(RwLock::new(PartialInstance::new(
azalea_world::chunk_storage::calculate_chunk_storage_range(
client_information.view_distance.into(),