mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-06 23:59:07 +02:00
world/section: replace block_id_at() method with block_at()
Directly return a BlockType, preparing for early lookup of palettes.
This commit is contained in:
parent
f2ab424590
commit
5c82b80924
3 changed files with 19 additions and 16 deletions
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use super::chunk::Chunk;
|
||||
use crate::{
|
||||
resource::{BlockFlag, BlockType, BlockTypes},
|
||||
resource::{BlockFlag, BlockType},
|
||||
types::*,
|
||||
};
|
||||
|
||||
|
@ -92,7 +92,7 @@ pub type BlockInfoArray = LayerBlockArray<Option<BlockInfo>>;
|
|||
/// determined as the block that should be visible on the rendered
|
||||
/// map. For water blocks, the height of the first non-water block
|
||||
/// is additionally filled in as the water depth.
|
||||
pub fn top_layer(chunk: &Chunk, block_types: &BlockTypes) -> Result<Box<BlockInfoArray>> {
|
||||
pub fn top_layer(chunk: &Chunk) -> Result<Box<BlockInfoArray>> {
|
||||
use BLOCKS_PER_CHUNK as N;
|
||||
|
||||
let mut done = 0;
|
||||
|
@ -109,9 +109,7 @@ pub fn top_layer(chunk: &Chunk, block_types: &BlockTypes) -> Result<Box<BlockInf
|
|||
}
|
||||
|
||||
let coords = SectionBlockCoords { xz, y };
|
||||
let block_id = section.block_id_at(coords)?;
|
||||
let Some(block_type) = block_types.get(block_id) else {
|
||||
eprintln!("Unknown block type: {}", block_id);
|
||||
let Some(block_type) = section.block_at(coords)? else {
|
||||
continue;
|
||||
};
|
||||
let height = BlockHeight::new(section_y, y)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue