From a707e2eb82b74994a16083b31fa4576332cf1995 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 15 Dec 2023 11:26:40 -0600 Subject: Add mining to the pathfinder (#122) * basic pathfinder mining poc * mining descending and autotool * pathfinder mining descending * pathfinder fixes * allow disabling pathfinder miner and other fixes * small optimization to avoid chunk vec iter lookup sometimes * seeded rng in pathfinder bench * consistently use f32::INFINITY this brings performance much closer to how it was before * astar heuristic optimization from baritone * add downward_move * fix downward move execute * avoid liquids and falling blocks when mining * fix COST_HEURISTIC * fix to not path through flowing liquids * only reset pathfinder timeout while mining if the block is close enough * cache mining costs of block positions * fix mine_while_at_start and move PathfinderDebugParticles to its own module * add ReachBlockPosGoal in other news: azalea's sin/cos functions were broken this whole time and i never noticed * clippy and add things that i accidentally didn't commit * improve wording on doc for azalea::pathfinder --- azalea-client/src/mining.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'azalea-client/src/mining.rs') diff --git a/azalea-client/src/mining.rs b/azalea-client/src/mining.rs index d1bc169e..d2e66ca8 100644 --- a/azalea-client/src/mining.rs +++ b/azalea-client/src/mining.rs @@ -200,7 +200,20 @@ fn handle_start_mining_block_with_direction_event( .get_block_state(&event.position) .unwrap_or_default(); *sequence_number += 1; - let block_is_solid = !target_block_state.is_air(); + let target_registry_block = azalea_registry::Block::from(target_block_state); + + // we can't break blocks if they don't have a bounding box + + // TODO: So right now azalea doesn't differenciate between different types of + // bounding boxes. See ClipContext::block_shape for more info. Ideally this + // should just call ClipContext::block_shape and check if it's empty. + let block_is_solid = !target_block_state.is_air() + // this is a hack to make sure we can't break water or lava + && !matches!( + target_registry_block, + azalea_registry::Block::Water | azalea_registry::Block::Lava + ); + if block_is_solid && **mine_progress == 0. { // interact with the block (like note block left click) here attack_block_events.send(AttackBlockEvent { -- cgit v1.2.3