diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-12-09 13:29:59 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-09 13:29:59 -0600 |
| commit | 26d619c9a329087a23d6577ee74bd764f50cd773 (patch) | |
| tree | 8020fe902257764a23a445c6ed9987ea4848189d /azalea/src | |
| parent | 84cd261118c9d1e3145d4d1751c0d22098cd8cd8 (diff) | |
| download | azalea-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')
| -rw-r--r-- | azalea/src/auto_tool.rs | 24 | ||||
| -rw-r--r-- | azalea/src/container.rs | 5 | ||||
| -rw-r--r-- | azalea/src/pathfinder/mod.rs | 4 | ||||
| -rw-r--r-- | azalea/src/pathfinder/simulation.rs | 9 |
4 files changed, 27 insertions, 15 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 { diff --git a/azalea/src/container.rs b/azalea/src/container.rs index 74c8b1e5..e82eeac8 100644 --- a/azalea/src/container.rs +++ b/azalea/src/container.rs @@ -2,10 +2,11 @@ use std::{fmt, fmt::Debug}; use azalea_client::{ Client, - inventory::{CloseContainerEvent, ContainerClickEvent, Inventory}, + inventory::{CloseContainerEvent, ContainerClickEvent}, packet::game::ReceiveGamePacketEvent, }; use azalea_core::position::BlockPos; +use azalea_entity::inventory::Inventory; use azalea_inventory::{ ItemStack, Menu, operations::{ClickOperation, PickupClick, QuickMoveClick}, @@ -185,7 +186,7 @@ impl ContainerClientExt for Client { } fn get_held_item(&self) -> ItemStack { - self.query_self::<&Inventory, _>(|inv| inv.held_item()) + self.query_self::<&Inventory, _>(|inv| inv.held_item().clone()) } } diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 7f0bd841..81b2b845 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -35,7 +35,7 @@ use astar::{Edge, PathfinderTimeout}; use azalea_block::{BlockState, BlockTrait}; use azalea_client::{ StartSprintEvent, StartWalkEvent, - inventory::{Inventory, InventorySystems}, + inventory::InventorySystems, local_player::InstanceHolder, mining::{Mining, MiningSystems, StartMiningBlockEvent}, movement::MoveEventsSystems, @@ -44,7 +44,7 @@ use azalea_core::{ position::{BlockPos, Vec3}, tick::GameTick, }; -use azalea_entity::{LocalEntity, Physics, Position, metadata::Player}; +use azalea_entity::{LocalEntity, Physics, Position, inventory::Inventory, metadata::Player}; use azalea_physics::{PhysicsSystems, get_block_pos_below_that_affects_movement}; use azalea_world::{InstanceContainer, InstanceName}; use bevy_app::{PreUpdate, Update}; diff --git a/azalea/src/pathfinder/simulation.rs b/azalea/src/pathfinder/simulation.rs index 3b8a46cc..df049b3e 100644 --- a/azalea/src/pathfinder/simulation.rs +++ b/azalea/src/pathfinder/simulation.rs @@ -3,12 +3,13 @@ use std::sync::Arc; use azalea_client::{ - PhysicsState, interact::BlockStatePredictionHandler, inventory::Inventory, - local_player::LocalGameMode, mining::MineBundle, + PhysicsState, interact::BlockStatePredictionHandler, local_player::LocalGameMode, + mining::MineBundle, }; use azalea_core::{game_type::GameMode, identifier::Identifier, position::Vec3, tick::GameTick}; use azalea_entity::{ - Attributes, LookDirection, Physics, Position, default_attributes, dimensions::EntityDimensions, + Attributes, LookDirection, Physics, Position, dimensions::EntityDimensions, + inventory::Inventory, }; use azalea_registry::EntityKind; use azalea_world::{ChunkStorage, Instance, InstanceContainer, MinecraftEntityId, PartialInstance}; @@ -36,7 +37,7 @@ impl SimulatedPlayerBundle { physics: Physics::new(&dimensions, position), physics_state: PhysicsState::default(), look_direction: LookDirection::default(), - attributes: default_attributes(EntityKind::Player), + attributes: Attributes::new(EntityKind::Player), inventory: Inventory::default(), } } |
