mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 17:44:52 +01:00
resource: make BlockTypeMap return BlockType without reference
This commit is contained in:
parent
0673c89bd8
commit
cbbc6d8f35
2 changed files with 15 additions and 6 deletions
|
@ -53,11 +53,20 @@ impl BlockType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type BlockTypeMap = HashMap<String, BlockType>;
|
pub struct BlockTypeMap(HashMap<String, BlockType>);
|
||||||
|
|
||||||
|
impl BlockTypeMap {
|
||||||
|
#[inline]
|
||||||
|
pub fn get(&self, id: &str) -> Option<BlockType> {
|
||||||
|
self.0.get(id).copied()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn block_types() -> BlockTypeMap {
|
pub fn block_types() -> BlockTypeMap {
|
||||||
|
BlockTypeMap(
|
||||||
block_types::BLOCK_TYPES
|
block_types::BLOCK_TYPES
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(k, v)| (String::from(*k), *v))
|
.map(|(k, v)| (String::from(*k), *v))
|
||||||
.collect()
|
.collect(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ pub fn top_layer(chunk: &Chunk, block_types: &BlockTypeMap) -> Result<Box<BlockI
|
||||||
|
|
||||||
let coords = SectionBlockCoords { xz, y };
|
let coords = SectionBlockCoords { xz, y };
|
||||||
let block_id = section.block_id_at(coords)?;
|
let block_id = section.block_id_at(coords)?;
|
||||||
let Some(&block_type) = block_types.get(block_id) else {
|
let Some(block_type) = block_types.get(block_id) else {
|
||||||
eprintln!("Unknown block type: {}", block_id);
|
eprintln!("Unknown block type: {}", block_id);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue