diff options
| author | mat <git@matdoes.dev> | 2025-06-10 19:47:42 -0100 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-10 19:47:42 -0100 |
| commit | 2a6ac0764fe9975f9b16d495ce773e4ae1f097e0 (patch) | |
| tree | b96a18a089252575a3d1d6e28bc78b6f5880b73f /azalea | |
| parent | e4ead93f195d3d91fd809dfc8cfee9cc36aabcbc (diff) | |
| download | azalea-drasl-2a6ac0764fe9975f9b16d495ce773e4ae1f097e0.tar.xz | |
add mine_with_auto_tool
Diffstat (limited to 'azalea')
| -rw-r--r-- | azalea/src/auto_tool.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/azalea/src/auto_tool.rs b/azalea/src/auto_tool.rs index 0f33dd09..63561772 100644 --- a/azalea/src/auto_tool.rs +++ b/azalea/src/auto_tool.rs @@ -1,8 +1,11 @@ use azalea_block::{BlockState, BlockTrait, fluid_state::FluidKind}; use azalea_client::{Client, inventory::Inventory}; +use azalea_core::position::BlockPos; use azalea_entity::{FluidOnEyes, Physics}; use azalea_inventory::{ItemStack, Menu, components}; +use crate::BotClientExt; + #[derive(Debug)] pub struct BestToolResult { pub index: usize, @@ -11,6 +14,7 @@ pub struct BestToolResult { pub trait AutoToolClientExt { fn best_tool_in_hotbar_for_block(&self, block: BlockState) -> BestToolResult; + fn mine_with_auto_tool(&self, block_pos: BlockPos) -> impl Future<Output = ()> + Send; } impl AutoToolClientExt for Client { @@ -22,6 +26,17 @@ impl AutoToolClientExt for Client { accurate_best_tool_in_hotbar_for_block(block, menu, physics, fluid_on_eyes) } + + async fn mine_with_auto_tool(&self, block_pos: BlockPos) { + let block_state = self + .world() + .read() + .get_block_state(&block_pos) + .unwrap_or_default(); + let best_tool_result = self.best_tool_in_hotbar_for_block(block_state); + self.set_selected_hotbar_slot(best_tool_result.index as u8); + self.mine(block_pos).await; + } } /// Returns the best tool in the hotbar for the given block. |
