From 9a687f0ffebad80441e036aabe14e7cf80c774d3 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 10 Oct 2023 23:21:23 -0500 Subject: start adding mining to pathfinder --- azalea-entity/src/lib.rs | 6 ++++++ azalea-entity/src/mining.rs | 18 ++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'azalea-entity/src') 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; -- cgit v1.2.3