diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-12-09 13:29:59 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-09 13:29:59 -0600 |
| commit | 26d619c9a329087a23d6577ee74bd764f50cd773 (patch) | |
| tree | 8020fe902257764a23a445c6ed9987ea4848189d /azalea-entity/src/mining.rs | |
| parent | 84cd261118c9d1e3145d4d1751c0d22098cd8cd8 (diff) | |
| download | azalea-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-entity/src/mining.rs')
| -rw-r--r-- | azalea-entity/src/mining.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/azalea-entity/src/mining.rs b/azalea-entity/src/mining.rs index 2008da34..b387367f 100644 --- a/azalea-entity/src/mining.rs +++ b/azalea-entity/src/mining.rs @@ -2,7 +2,7 @@ use azalea_block::{BlockBehavior, BlockTrait}; use azalea_core::tier::get_item_tier; use azalea_registry::{self as registry, MobEffect}; -use crate::{ActiveEffects, FluidOnEyes, Physics}; +use crate::{ActiveEffects, Attributes, FluidOnEyes, Physics}; /// How much progress is made towards mining the block per tick, as a /// percentage. @@ -17,9 +17,9 @@ use crate::{ActiveEffects, FluidOnEyes, Physics}; pub fn get_mine_progress( block: &dyn BlockTrait, held_item: registry::Item, - player_inventory: &azalea_inventory::Menu, fluid_on_eyes: &FluidOnEyes, physics: &Physics, + attributes: &Attributes, active_effects: &ActiveEffects, ) -> f32 { let block_behavior: BlockBehavior = block.behavior(); @@ -37,9 +37,9 @@ pub fn get_mine_progress( let base_destroy_speed = destroy_speed( block.as_registry_block(), held_item, - player_inventory, fluid_on_eyes, physics, + attributes, active_effects, ); (base_destroy_speed / destroy_time) / divisor as f32 @@ -81,22 +81,17 @@ fn has_correct_tool_for_drops(block: &dyn BlockTrait, tool: registry::Item) -> b fn destroy_speed( block: registry::Block, tool: registry::Item, - _player_inventory: &azalea_inventory::Menu, _fluid_on_eyes: &FluidOnEyes, physics: &Physics, + attributes: &Attributes, active_effects: &ActiveEffects, ) -> f32 { let mut base_destroy_speed = base_destroy_speed(block, tool); - // add efficiency enchantment - // TODO - // if base_destroy_speed > 1. { - // let efficiency_level = - // enchantments::get_enchant_level(registry::Enchantment::Efficiency, - // player_inventory); if efficiency_level > 0 && tool != - // registry::Item::Air { base_destroy_speed += (efficiency_level * - // efficiency_level + 1) as f32; } - // } + if base_destroy_speed > 1. { + // efficiency enchantment + base_destroy_speed += attributes.mining_efficiency.calculate() as f32; + } if let Some(dig_speed_amplifier) = active_effects.get_dig_speed_amplifier() { base_destroy_speed *= 1. + (dig_speed_amplifier + 1) as f32 * 0.2; |
