diff options
| author | mat <git@matdoes.dev> | 2023-10-10 23:21:23 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-10-10 23:21:23 -0500 |
| commit | 9a687f0ffebad80441e036aabe14e7cf80c774d3 (patch) | |
| tree | 2f6ad5a1a14cae23723550c934df395aab1733f6 /azalea-entity/src | |
| parent | 0297b8aacee27d9e86cea781b3751591e32df401 (diff) | |
| download | azalea-drasl-9a687f0ffebad80441e036aabe14e7cf80c774d3.tar.xz | |
start adding mining to pathfinder
Diffstat (limited to 'azalea-entity/src')
| -rw-r--r-- | azalea-entity/src/lib.rs | 6 | ||||
| -rw-r--r-- | azalea-entity/src/mining.rs | 18 |
2 files changed, 14 insertions, 10 deletions
diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs index 45213fc1..9b673945 100644 --- a/azalea-entity/src/lib.rs +++ b/azalea-entity/src/lib.rs @@ -366,6 +366,12 @@ pub struct LocalEntity; #[derive(Component, Clone, Debug, PartialEq, Deref, DerefMut)] pub struct FluidOnEyes(azalea_registry::Fluid); +impl FluidOnEyes { + pub fn new(fluid: azalea_registry::Fluid) -> Self { + Self(fluid) + } +} + // #[cfg(test)] // mod tests { // use super::*; diff --git a/azalea-entity/src/mining.rs b/azalea-entity/src/mining.rs index a2f869cf..ee5c961b 100644 --- a/azalea-entity/src/mining.rs +++ b/azalea-entity/src/mining.rs @@ -4,6 +4,14 @@ use azalea_registry as registry; use crate::{effects, enchantments, FluidOnEyes, Physics}; +/// How much progress is made towards mining the block per tick, as a +/// percentage. If this is 1 then the block gets broken instantly. +/// +/// You can divide 1 by this and then round up to get the number of ticks it +/// takes to mine the block. +/// +/// The player inventory is needed to check your armor and offhand for modifiers +/// to your mining speed. pub fn get_mine_progress( block: &dyn Block, held_item: registry::Item, @@ -11,16 +19,6 @@ pub fn get_mine_progress( fluid_on_eyes: &FluidOnEyes, physics: &Physics, ) -> f32 { - // public float getDestroyProgress(BlockState blockState, Player player, - // BlockGetter world, BlockPos blockPos) { float destroySpeed = - // blockState.getDestroySpeed(world, blockPos); if (destroySpeed == - // -1.0F) { return 0.0F; - // } else { - // int divider = player.hasCorrectToolForDrops(blockState) ? 30 : 100; - // return player.getDestroySpeed(blockState) / destroySpeed / - // (float)divider; } - // } - let block_behavior: BlockBehavior = block.behavior(); let destroy_time = block_behavior.destroy_time; |
