From d028d7c3e9c84d177b7b10fa0d8f77d11bcea20f Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 2 Jun 2025 07:45:26 +1100 Subject: add basic support for getting biome ids in chunks --- azalea/src/pathfinder/world.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'azalea/src') 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)>>, + cached_chunks: RefCell< + Vec<( + ChunkPos, + Vec>, + )>, + >, last_chunk_cache_index: RefCell>, cached_blocks: UnsafeCell, @@ -119,7 +124,7 @@ impl CachedWorld { fn with_section( &self, section_pos: ChunkSectionPos, - f: impl FnOnce(&azalea_world::palette::PalettedContainer) -> T, + f: impl FnOnce(&azalea_world::palette::PalettedContainer) -> T, ) -> Option { 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 = §ions[section_index]; + let section = §ions[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 = §ions[section_index]; + let section = §ions[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 = chunk + let sections = chunk .sections .iter() .map(|section| section.states.clone()) - .collect(); + .collect::>>(); if section_index >= sections.len() { // y position is out of bounds -- cgit v1.2.3