aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/client.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-09 13:29:59 -0600
committerGitHub <noreply@github.com>2025-12-09 13:29:59 -0600
commit26d619c9a329087a23d6577ee74bd764f50cd773 (patch)
tree8020fe902257764a23a445c6ed9987ea4848189d /azalea-client/src/client.rs
parent84cd261118c9d1e3145d4d1751c0d22098cd8cd8 (diff)
downloadazalea-drasl-26d619c9a329087a23d6577ee74bd764f50cd773.tar.xz
Enchantments (#286)
* start implementing enchants * store parsed registries * more work on enchants * implement deserializer for some entity effects * mostly working definitions for enchants * fix tests * detect equipment changes * fix errors * update changelog * fix some imports * remove outdated todo * add basic test for enchants applying attributes * use git simdnbt
Diffstat (limited to 'azalea-client/src/client.rs')
-rw-r--r--azalea-client/src/client.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index 20e1cb3b..439f4d29 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -13,9 +13,10 @@ use azalea_core::{
data_registry::ResolvableDataRegistry, identifier::Identifier, position::Vec3, tick::GameTick,
};
use azalea_entity::{
- EntityUpdateSystems, PlayerAbilities, Position,
+ Attributes, EntityUpdateSystems, PlayerAbilities, Position,
dimensions::EntityDimensions,
indexing::{EntityIdIndex, EntityUuidIndex},
+ inventory::Inventory,
metadata::Health,
};
use azalea_physics::local_player::PhysicsState;
@@ -33,7 +34,6 @@ use bevy_ecs::{
schedule::{InternedScheduleLabel, LogLevel, ScheduleBuildSettings},
};
use parking_lot::{Mutex, RwLock};
-use simdnbt::owned::NbtCompound;
use thiserror::Error;
use tokio::{
sync::{
@@ -54,7 +54,6 @@ use crate::{
disconnect::DisconnectEvent,
events::Event,
interact::BlockStatePredictionHandler,
- inventory::Inventory,
join::{ConnectOpts, StartJoinServerEvent},
local_player::{Hunger, InstanceHolder, PermissionLevel, TabList},
mining::{self},
@@ -431,6 +430,12 @@ impl Client {
(*self.component::<GameProfileComponent>()).clone()
}
+ /// Returns the attribute values of our player, which can be used to
+ /// determine things like our movement speed.
+ pub fn attributes(&self) -> Attributes {
+ self.component::<Attributes>()
+ }
+
/// A convenience function to get the Minecraft Uuid of a player by their
/// username, if they're present in the tab list.
///
@@ -487,7 +492,7 @@ impl Client {
&self,
registry: &impl ResolvableDataRegistry,
) -> Option<Identifier> {
- self.with_registry_holder(|registries| registry.resolve_name(registries))
+ self.with_registry_holder(|registries| registry.resolve_name(registries).cloned())
}
/// Resolve the given registry to its name and data and call the given
/// function with it.
@@ -498,11 +503,11 @@ impl Client {
/// instead.
///
/// [`Enchantment`]: azalea_registry::Enchantment
- pub fn with_resolved_registry<R>(
+ pub fn with_resolved_registry<R: ResolvableDataRegistry, Ret>(
&self,
- registry: impl ResolvableDataRegistry,
- f: impl FnOnce(&Identifier, &NbtCompound) -> R,
- ) -> Option<R> {
+ registry: R,
+ f: impl FnOnce(&Identifier, &R::DeserializesTo) -> Ret,
+ ) -> Option<Ret> {
self.with_registry_holder(|registries| {
registry
.resolve(registries)