diff options
| author | mat <git@matdoes.dev> | 2025-06-02 07:45:26 +1100 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-02 07:45:26 +1100 |
| commit | d028d7c3e9c84d177b7b10fa0d8f77d11bcea20f (patch) | |
| tree | a37fa4167a3171dd46c17d8ea5b8674cc72c3c78 /azalea-world/src/find_blocks.rs | |
| parent | b103e6fdc0daa131d1177c5d0705134640aa9d6e (diff) | |
| download | azalea-drasl-d028d7c3e9c84d177b7b10fa0d8f77d11bcea20f.tar.xz | |
add basic support for getting biome ids in chunks
Diffstat (limited to 'azalea-world/src/find_blocks.rs')
| -rw-r--r-- | azalea-world/src/find_blocks.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/azalea-world/src/find_blocks.rs b/azalea-world/src/find_blocks.rs index 1215549b..b266d799 100644 --- a/azalea-world/src/find_blocks.rs +++ b/azalea-world/src/find_blocks.rs @@ -1,9 +1,9 @@ -use azalea_block::BlockStates; +use azalea_block::{BlockState, BlockStates}; use azalea_core::position::{BlockPos, ChunkPos}; use crate::{ChunkStorage, Instance, iterators::ChunkIterator, palette::Palette}; -fn palette_maybe_has_block(palette: &Palette, block_states: &BlockStates) -> bool { +fn palette_maybe_has_block(palette: &Palette<BlockState>, block_states: &BlockStates) -> bool { match &palette { Palette::SingleValue(id) => block_states.contains(id), Palette::Linear(ids) => ids.iter().any(|id| block_states.contains(id)), @@ -63,11 +63,11 @@ impl Instance { let block_state = section.states.get_at_index(i); if block_states.contains(&block_state) { - let (section_x, section_y, section_z) = section.states.coords_from_index(i); + let section_pos = section.states.coords_from_index(i); let (x, y, z) = ( - chunk_pos.x * 16 + (section_x as i32), - self.chunks.min_y + (section_index * 16) as i32 + section_y as i32, - chunk_pos.z * 16 + (section_z as i32), + chunk_pos.x * 16 + (section_pos.x as i32), + self.chunks.min_y + (section_index * 16) as i32 + section_pos.y as i32, + chunk_pos.z * 16 + (section_pos.z as i32), ); let this_block_pos = BlockPos { x, y, z }; let this_block_distance = (nearest_to - this_block_pos).length_manhattan(); @@ -190,11 +190,11 @@ impl Iterator for FindBlocks<'_> { let block_state = section.states.get_at_index(i); if self.block_states.contains(&block_state) { - let (section_x, section_y, section_z) = section.states.coords_from_index(i); + let section_pos = section.states.coords_from_index(i); let (x, y, z) = ( - chunk_pos.x * 16 + (section_x as i32), - self.chunks.min_y + (section_index * 16) as i32 + section_y as i32, - chunk_pos.z * 16 + (section_z as i32), + chunk_pos.x * 16 + (section_pos.x as i32), + self.chunks.min_y + (section_index * 16) as i32 + section_pos.y as i32, + chunk_pos.z * 16 + (section_pos.z as i32), ); let this_block_pos = BlockPos { x, y, z }; let this_block_distance = |
