diff options
| author | mat <git@matdoes.dev> | 2026-05-06 03:36:16 -0100 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-05-07 08:05:58 -1200 |
| commit | 9ffd0e80bbb3feace231553d6539124585b03e3c (patch) | |
| tree | ad8df7d07df9f8f542e288c263d76b8ffd637416 /azalea/src/auto_tool.rs | |
| parent | 4d1f430408dc6854c1af5fb14b2641e293a9cf43 (diff) | |
| download | azalea-drasl-9ffd0e80bbb3feace231553d6539124585b03e3c.tar.xz | |
change panicking functions in Client and EntityRef to return an AzaleaResult instead
Diffstat (limited to 'azalea/src/auto_tool.rs')
| -rw-r--r-- | azalea/src/auto_tool.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/azalea/src/auto_tool.rs b/azalea/src/auto_tool.rs index 4f59d4a9..8ab64d6b 100644 --- a/azalea/src/auto_tool.rs +++ b/azalea/src/auto_tool.rs @@ -4,7 +4,7 @@ use azalea_entity::{ActiveEffects, Attributes, FluidOnEyes, Physics, inventory:: use azalea_inventory::{ItemStack, Menu, components}; use azalea_registry::builtin::{BlockKind, EntityKind}; -use crate::Client; +use crate::{Client, client_impl::error::AzaleaResult}; #[derive(Debug)] pub struct BestToolResult { @@ -13,7 +13,7 @@ pub struct BestToolResult { } impl Client { - pub fn best_tool_in_hotbar_for_block(&self, block: BlockState) -> BestToolResult { + pub fn best_tool_in_hotbar_for_block(&self, block: BlockState) -> AzaleaResult<BestToolResult> { self.query_self::<( &Inventory, &Physics, @@ -35,15 +35,16 @@ impl Client { ) } - pub async fn mine_with_auto_tool(&self, block_pos: BlockPos) { + pub async fn mine_with_auto_tool(&self, block_pos: BlockPos) -> AzaleaResult<()> { let block_state = self - .world() + .world()? .read() .get_block_state(block_pos) .unwrap_or_default(); - let best_tool_result = self.best_tool_in_hotbar_for_block(block_state); + 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; + Ok(()) } } |
