From 26d619c9a329087a23d6577ee74bd764f50cd773 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Tue, 9 Dec 2025 13:29:59 -0600 Subject: 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 --- azalea-entity/src/lib.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'azalea-entity/src/lib.rs') diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs index 927b4637..84e1c9f7 100644 --- a/azalea-entity/src/lib.rs +++ b/azalea-entity/src/lib.rs @@ -4,7 +4,7 @@ pub mod attributes; mod data; pub mod dimensions; mod effects; -mod enchantments; +pub mod inventory; pub mod metadata; pub mod mining; pub mod particle; @@ -511,7 +511,7 @@ impl EntityBundle { dimensions, direction: LookDirection::default(), - attributes: default_attributes(EntityKind::Player), + attributes: Attributes::new(EntityKind::Player), jumping: Jumping(false), crouching: Crouching(false), @@ -522,17 +522,20 @@ impl EntityBundle { } } -pub fn default_attributes(_entity_kind: EntityKind) -> Attributes { - // TODO: do the correct defaults for everything, some - // entities have different defaults - Attributes { - movement_speed: AttributeInstance::new(0.1f32 as f64), - sneaking_speed: AttributeInstance::new(0.3), - attack_speed: AttributeInstance::new(4.0), - water_movement_efficiency: AttributeInstance::new(0.0), - block_interaction_range: AttributeInstance::new(4.5), - entity_interaction_range: AttributeInstance::new(3.0), - step_height: AttributeInstance::new(0.6), +impl Attributes { + pub fn new(_entity_kind: EntityKind) -> Self { + // TODO: do the correct defaults for everything, some + // entities have different defaults + Attributes { + movement_speed: AttributeInstance::new(0.1f32 as f64), + sneaking_speed: AttributeInstance::new(0.3), + attack_speed: AttributeInstance::new(4.0), + water_movement_efficiency: AttributeInstance::new(0.0), + mining_efficiency: AttributeInstance::new(0.0), + block_interaction_range: AttributeInstance::new(4.5), + entity_interaction_range: AttributeInstance::new(3.0), + step_height: AttributeInstance::new(0.6), + } } } -- cgit v1.2.3