diff options
| author | mat <git@matdoes.dev> | 2026-01-17 08:50:46 -1345 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-17 08:50:46 -1345 |
| commit | be4f2df7be4963a863d6fd96f64275dd7028e9d4 (patch) | |
| tree | ef3bcec160eb11207f08435b864fafde2f17030e /azalea/src/pathfinder/world.rs | |
| parent | 74ef7d19b2bc4453f5368cc39c838582f2f3bafd (diff) | |
| download | azalea-drasl-be4f2df7be4963a863d6fd96f64275dd7028e9d4.tar.xz | |
clippy
Diffstat (limited to 'azalea/src/pathfinder/world.rs')
| -rw-r--r-- | azalea/src/pathfinder/world.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/azalea/src/pathfinder/world.rs b/azalea/src/pathfinder/world.rs index ec8aa259..be264889 100644 --- a/azalea/src/pathfinder/world.rs +++ b/azalea/src/pathfinder/world.rs @@ -1,14 +1,13 @@ use core::f32; use std::{ cell::{RefCell, UnsafeCell}, - cmp, mem, sync::Arc, }; use azalea_block::{BlockState, properties}; use azalea_core::{ bitset::FastFixedBitSet, - position::{BlockPos, ChunkPos, ChunkSectionBlockPos, ChunkSectionPos}, + position::{BlockPos, ChunkPos, ChunkSectionBlockPos}, }; use azalea_physics::collision::BlockWithShape; use azalea_registry::{builtin::BlockKind, tags}; @@ -29,9 +28,7 @@ pub struct CachedWorld { min_y: i32, world_lock: Arc<RwLock<World>>, - // we store `PalettedContainer`s instead of `Chunk`s or `Section`s because it doesn't contain - // any unnecessary data like heightmaps or biomes. - cached_chunks: RefCell<Vec<(ChunkPos, Box<[PalettedContainer<BlockState>]>)>>, + cached_chunks: RefCell<Vec<(ChunkPos, CachedChunk)>>, last_chunk_cache_index: RefCell<Option<usize>>, cached_blocks: UnsafeCell<CachedSections>, @@ -39,6 +36,10 @@ pub struct CachedWorld { cached_mining_costs: UnsafeCell<Box<[(RelBlockPos, f32)]>>, } +// we store `PalettedContainer`s instead of `Chunk`s or `Section`s because it +// doesn't contain any unnecessary data like heightmaps or biomes. +type CachedChunk = Box<[PalettedContainer<BlockState>]>; + #[derive(Default)] pub struct CachedSections { pub last_index: usize, @@ -452,33 +453,33 @@ impl CachedWorld { } // check the adjacent blocks that weren't in the same section - if !up_is_in_same_section { - if check_should_avoid_this_block(&self, pos.up(1), |b| { + if !up_is_in_same_section + && check_should_avoid_this_block(self, pos.up(1), |b| { if mining_cache.is_falling_block(b) { is_falling_block_above = true; } mining_cache.is_liquid(b) - }) { - return f32::INFINITY; - } + }) + { + return f32::INFINITY; } if !north_is_in_same_section - && check_should_avoid_this_block(&self, pos.north(1), &|b| mining_cache.is_liquid(b)) + && check_should_avoid_this_block(self, pos.north(1), |b| mining_cache.is_liquid(b)) { return f32::INFINITY; } if !east_is_in_same_section - && check_should_avoid_this_block(&self, pos.east(1), |b| mining_cache.is_liquid(b)) + && check_should_avoid_this_block(self, pos.east(1), |b| mining_cache.is_liquid(b)) { return f32::INFINITY; } if !south_is_in_same_section - && check_should_avoid_this_block(&self, pos.south(1), |b| mining_cache.is_liquid(b)) + && check_should_avoid_this_block(self, pos.south(1), |b| mining_cache.is_liquid(b)) { return f32::INFINITY; } if !west_is_in_same_section - && check_should_avoid_this_block(&self, pos.west(1), |b| mining_cache.is_liquid(b)) + && check_should_avoid_this_block(self, pos.west(1), |b| mining_cache.is_liquid(b)) { return f32::INFINITY; } |
