diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs index f69c30f0..89e3d0e2 100644 --- a/azalea-client/src/plugins/mining.rs +++ b/azalea-client/src/plugins/mining.rs @@ -313,7 +313,7 @@ fn handle_mining_queued( physics, ) >= 1. { - // block was broken instantly + // block was broken instantly (instamined) commands.trigger_targets( FinishMiningBlockEvent { position: mining_queued.position, @@ -497,10 +497,10 @@ pub fn handle_stop_mining_block_event( mut events: EventReader, mut commands: Commands, mut mine_block_progress_events: EventWriter, - mut query: Query<(&mut Mining, &MineBlockPos, &mut MineProgress)>, + mut query: Query<(&MineBlockPos, &mut MineProgress)>, ) { for event in events.read() { - let (mut _mining, mine_block_pos, mut mine_progress) = query.get_mut(event.entity).unwrap(); + let (mine_block_pos, mut mine_progress) = query.get_mut(event.entity).unwrap(); let mine_block_pos = mine_block_pos.expect("IsMining is true so MineBlockPos must be present"); @@ -639,7 +639,7 @@ pub fn continue_mining_block( )); **mine_progress = 0.; **mine_ticks = 0.; - **mine_delay = 0; + **mine_delay = 5; } mine_block_progress_events.write(MineBlockProgressEvent { diff --git a/azalea/src/pathfinder/goals.rs b/azalea/src/pathfinder/goals.rs index 4c0dbafa..c19bf504 100644 --- a/azalea/src/pathfinder/goals.rs +++ b/azalea/src/pathfinder/goals.rs @@ -1,6 +1,9 @@ //! The goals that a pathfinder can try to reach. -use std::{f32::consts::SQRT_2, fmt::Debug}; +use std::{ + f32::consts::SQRT_2, + fmt::{self, Debug}, +}; use azalea_core::position::{BlockPos, Vec3}; use azalea_world::ChunkStorage; @@ -193,7 +196,7 @@ impl Goal for AndGoals { } /// Move to a position where we can reach the given block. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct ReachBlockPosGoal { pub pos: BlockPos, pub distance: f64, @@ -244,3 +247,12 @@ impl Goal for ReachBlockPosGoal { block_hit_result.block_pos == self.pos } } +impl Debug for ReachBlockPosGoal { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ReachBlockPosGoal") + .field("pos", &self.pos) + .field("distance", &self.distance) + .field("max_check_distance", &self.max_check_distance) + .finish() + } +} diff --git a/azalea/src/pathfinder/moves/basic.rs b/azalea/src/pathfinder/moves/basic.rs index fe0d81f5..e352f385 100644 --- a/azalea/src/pathfinder/moves/basic.rs +++ b/azalea/src/pathfinder/moves/basic.rs @@ -55,6 +55,7 @@ fn execute_forward_move(mut ctx: ExecuteCtx) { } ctx.look_at(center); + ctx.jump_if_in_water(); ctx.sprint(SprintDirection::Forward); } @@ -141,6 +142,7 @@ fn execute_ascend_move(mut ctx: ExecuteCtx) { ctx.look_at(target_center); ctx.walk(WalkDirection::Forward); + ctx.jump_if_in_water(); // these checks are to make sure we don't fall if our velocity is too high in // the wrong direction @@ -439,6 +441,7 @@ fn execute_diagonal_move(mut ctx: ExecuteCtx) { ctx.look_at(target_center); ctx.sprint(SprintDirection::Forward); + ctx.jump_if_in_water(); } /// Go directly down, usually by mining. diff --git a/azalea/src/pathfinder/moves/mod.rs b/azalea/src/pathfinder/moves/mod.rs index 6c26a507..44d31bfb 100644 --- a/azalea/src/pathfinder/moves/mod.rs +++ b/azalea/src/pathfinder/moves/mod.rs @@ -111,6 +111,12 @@ impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_> { }); } + pub fn jump_if_in_water(&mut self) { + if self.physics.is_in_water() { + self.jump(); + } + } + /// Returns whether this block could be mined. pub fn should_mine(&mut self, block: BlockPos) -> bool { let block_state = self