diff options
| author | mat <git@matdoes.dev> | 2024-12-24 09:40:29 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-12-24 09:40:29 +0000 |
| commit | a599b5614e6acf65e552940fff99a9252a600472 (patch) | |
| tree | cf686191747a389f963b633a0898940cba594d13 /azalea/src | |
| parent | f03e0c22355778a9863cccb5a59d852278d60701 (diff) | |
| download | azalea-drasl-a599b5614e6acf65e552940fff99a9252a600472.tar.xz | |
make BlockState a u16 and add a BlockStateIntegerRepr type
Diffstat (limited to 'azalea/src')
| -rw-r--r-- | azalea/src/pathfinder/astar.rs | 7 | ||||
| -rw-r--r-- | azalea/src/pathfinder/mining.rs | 17 |
2 files changed, 15 insertions, 9 deletions
diff --git a/azalea/src/pathfinder/astar.rs b/azalea/src/pathfinder/astar.rs index 2442adb6..6573c883 100644 --- a/azalea/src/pathfinder/astar.rs +++ b/azalea/src/pathfinder/astar.rs @@ -5,6 +5,7 @@ use std::{ time::{Duration, Instant}, }; +use num_format::ToFormattedString; use priority_queue::PriorityQueue; use rustc_hash::FxHashMap; use tracing::{debug, trace, warn}; @@ -131,6 +132,12 @@ where let best_path = determine_best_path(&best_paths, &start); + debug!( + "A* ran at {} nodes per second", + ((num_nodes as f64 / start_time.elapsed().as_secs_f64()) as u64) + .to_formatted_string(&num_format::Locale::en) + ); + Path { movements: reconstruct_path(nodes, best_path), partial: true, diff --git a/azalea/src/pathfinder/mining.rs b/azalea/src/pathfinder/mining.rs index 049e974a..62963306 100644 --- a/azalea/src/pathfinder/mining.rs +++ b/azalea/src/pathfinder/mining.rs @@ -1,7 +1,6 @@ use std::{cell::UnsafeCell, ops::RangeInclusive}; -use azalea_block::{properties::Waterlogged, BlockState, BlockStates}; -use azalea_core::bitset::BitSet; +use azalea_block::{properties::Waterlogged, BlockState, BlockStateIntegerRepr, BlockStates}; use azalea_inventory::Menu; use nohash_hasher::IntMap; @@ -9,11 +8,11 @@ use super::costs::BLOCK_BREAK_ADDITIONAL_PENALTY; use crate::auto_tool::best_tool_in_hotbar_for_block; pub struct MiningCache { - block_state_id_costs: UnsafeCell<IntMap<u32, f32>>, + block_state_id_costs: UnsafeCell<IntMap<BlockStateIntegerRepr, f32>>, inventory_menu: Option<Menu>, - water_block_state_range: RangeInclusive<u32>, - lava_block_state_range: RangeInclusive<u32>, + water_block_state_range: RangeInclusive<BlockStateIntegerRepr>, + lava_block_state_range: RangeInclusive<BlockStateIntegerRepr>, falling_blocks: Vec<BlockState>, } @@ -23,16 +22,16 @@ impl MiningCache { let water_block_states = BlockStates::from(azalea_registry::Block::Water); let lava_block_states = BlockStates::from(azalea_registry::Block::Lava); - let mut water_block_state_range_min = u32::MAX; - let mut water_block_state_range_max = u32::MIN; + let mut water_block_state_range_min = BlockStateIntegerRepr::MAX; + let mut water_block_state_range_max = BlockStateIntegerRepr::MIN; for state in water_block_states { water_block_state_range_min = water_block_state_range_min.min(state.id); water_block_state_range_max = water_block_state_range_max.max(state.id); } let water_block_state_range = water_block_state_range_min..=water_block_state_range_max; - let mut lava_block_state_range_min = u32::MAX; - let mut lava_block_state_range_max = u32::MIN; + let mut lava_block_state_range_min = BlockStateIntegerRepr::MAX; + let mut lava_block_state_range_max = BlockStateIntegerRepr::MIN; for state in lava_block_states { lava_block_state_range_min = lava_block_state_range_min.min(state.id); lava_block_state_range_max = lava_block_state_range_max.max(state.id); |
