aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/auto_tool.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-09 13:29:59 -0600
committerGitHub <noreply@github.com>2025-12-09 13:29:59 -0600
commit26d619c9a329087a23d6577ee74bd764f50cd773 (patch)
tree8020fe902257764a23a445c6ed9987ea4848189d /azalea/src/auto_tool.rs
parent84cd261118c9d1e3145d4d1751c0d22098cd8cd8 (diff)
downloadazalea-drasl-26d619c9a329087a23d6577ee74bd764f50cd773.tar.xz
Enchantments (#286)
* start implementing enchants * store parsed registries * more work on enchants * implement deserializer for some entity effects * mostly working definitions for enchants * fix tests * detect equipment changes * fix errors * update changelog * fix some imports * remove outdated todo * add basic test for enchants applying attributes * use git simdnbt
Diffstat (limited to 'azalea/src/auto_tool.rs')
-rw-r--r--azalea/src/auto_tool.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/azalea/src/auto_tool.rs b/azalea/src/auto_tool.rs
index af3d4352..b71fb0b0 100644
--- a/azalea/src/auto_tool.rs
+++ b/azalea/src/auto_tool.rs
@@ -1,8 +1,9 @@
use azalea_block::{BlockState, BlockTrait, fluid_state::FluidKind};
-use azalea_client::{Client, inventory::Inventory};
+use azalea_client::Client;
use azalea_core::position::BlockPos;
-use azalea_entity::{ActiveEffects, FluidOnEyes, Physics};
+use azalea_entity::{ActiveEffects, Attributes, FluidOnEyes, Physics, inventory::Inventory};
use azalea_inventory::{ItemStack, Menu, components};
+use azalea_registry::EntityKind;
use crate::bot::BotClientExt;
@@ -19,14 +20,21 @@ pub trait AutoToolClientExt {
impl AutoToolClientExt for Client {
fn best_tool_in_hotbar_for_block(&self, block: BlockState) -> BestToolResult {
- self.query_self::<(&Inventory, &Physics, &FluidOnEyes, &ActiveEffects), _>(
- |(inventory, physics, fluid_on_eyes, active_effects)| {
+ self.query_self::<(
+ &Inventory,
+ &Physics,
+ &FluidOnEyes,
+ &Attributes,
+ &ActiveEffects,
+ ), _>(
+ |(inventory, physics, fluid_on_eyes, attributes, active_effects)| {
let menu = &inventory.inventory_menu;
accurate_best_tool_in_hotbar_for_block(
block,
menu,
physics,
fluid_on_eyes,
+ attributes,
active_effects,
)
},
@@ -60,6 +68,7 @@ pub fn best_tool_in_hotbar_for_block(block: BlockState, menu: &Menu) -> BestTool
menu,
&physics,
&FluidOnEyes::new(FluidKind::Empty),
+ &Attributes::new(EntityKind::Player),
&inactive_effects,
)
}
@@ -69,6 +78,7 @@ pub fn accurate_best_tool_in_hotbar_for_block(
menu: &Menu,
physics: &Physics,
fluid_on_eyes: &FluidOnEyes,
+ attributes: &Attributes,
active_effects: &ActiveEffects,
) -> BestToolResult {
let hotbar_slots = &menu.slots()[menu.hotbar_slots_range()];
@@ -98,9 +108,9 @@ pub fn accurate_best_tool_in_hotbar_for_block(
this_item_speed = Some(azalea_entity::mining::get_mine_progress(
block.as_ref(),
azalea_registry::Item::Air,
- menu,
fluid_on_eyes,
physics,
+ attributes,
active_effects,
));
}
@@ -111,9 +121,9 @@ pub fn accurate_best_tool_in_hotbar_for_block(
this_item_speed = Some(azalea_entity::mining::get_mine_progress(
block.as_ref(),
item_stack.kind,
- menu,
fluid_on_eyes,
physics,
+ attributes,
active_effects,
));
} else {
@@ -135,9 +145,9 @@ pub fn accurate_best_tool_in_hotbar_for_block(
let this_item_speed = azalea_entity::mining::get_mine_progress(
block.as_ref(),
item_slot.kind,
- menu,
fluid_on_eyes,
physics,
+ attributes,
active_effects,
);
if this_item_speed > best_speed {