aboutsummaryrefslogtreecommitdiff
path: root/azalea/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-06-02 07:45:26 +1100
committermat <git@matdoes.dev>2025-06-02 07:45:26 +1100
commitd028d7c3e9c84d177b7b10fa0d8f77d11bcea20f (patch)
treea37fa4167a3171dd46c17d8ea5b8674cc72c3c78 /azalea/src
parentb103e6fdc0daa131d1177c5d0705134640aa9d6e (diff)
downloadazalea-drasl-d028d7c3e9c84d177b7b10fa0d8f77d11bcea20f.tar.xz
add basic support for getting biome ids in chunks
Diffstat (limited to 'azalea/src')
-rw-r--r--azalea/src/pathfinder/world.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/azalea/src/pathfinder/world.rs b/azalea/src/pathfinder/world.rs
index 013f7c2d..b77183e8 100644
--- a/azalea/src/pathfinder/world.rs
+++ b/azalea/src/pathfinder/world.rs
@@ -9,7 +9,7 @@ use azalea_core::{
position::{BlockPos, ChunkPos, ChunkSectionBlockPos, ChunkSectionPos},
};
use azalea_physics::collision::BlockWithShape;
-use azalea_world::Instance;
+use azalea_world::{Instance, palette::PalettedContainer};
use parking_lot::RwLock;
use super::{mining::MiningCache, rel_block_pos::RelBlockPos};
@@ -26,7 +26,12 @@ pub struct CachedWorld {
// 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, Vec<azalea_world::palette::PalettedContainer>)>>,
+ cached_chunks: RefCell<
+ Vec<(
+ ChunkPos,
+ Vec<azalea_world::palette::PalettedContainer<BlockState>>,
+ )>,
+ >,
last_chunk_cache_index: RefCell<Option<usize>>,
cached_blocks: UnsafeCell<CachedSections>,
@@ -119,7 +124,7 @@ impl CachedWorld {
fn with_section<T>(
&self,
section_pos: ChunkSectionPos,
- f: impl FnOnce(&azalea_world::palette::PalettedContainer) -> T,
+ f: impl FnOnce(&azalea_world::palette::PalettedContainer<BlockState>) -> T,
) -> Option<T> {
if section_pos.y * 16 < self.min_y {
// y position is out of bounds
@@ -143,7 +148,7 @@ impl CachedWorld {
// y position is out of bounds
return None;
};
- let section: &azalea_world::palette::PalettedContainer = &sections[section_index];
+ let section = &sections[section_index];
return Some(f(section));
}
@@ -165,7 +170,7 @@ impl CachedWorld {
return None;
};
*self.last_chunk_cache_index.borrow_mut() = Some(chunk_index);
- let section: &azalea_world::palette::PalettedContainer = &sections[section_index];
+ let section = &sections[section_index];
return Some(f(section));
}
@@ -173,11 +178,11 @@ impl CachedWorld {
let chunk = world.chunks.get(&chunk_pos)?;
let chunk = chunk.read();
- let sections: Vec<azalea_world::palette::PalettedContainer> = chunk
+ let sections = chunk
.sections
.iter()
.map(|section| section.states.clone())
- .collect();
+ .collect::<Vec<PalettedContainer<BlockState>>>();
if section_index >= sections.len() {
// y position is out of bounds