mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-04 06:39:07 +02:00
resource: rename BlockTypeMap to BlockTypes
The block_types() function it turned into a Default implementation.
This commit is contained in:
parent
95e4e45974
commit
4c2fd6c1a9
3 changed files with 18 additions and 15 deletions
|
@ -53,21 +53,24 @@ impl BlockType {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct BlockTypeMap(HashMap<String, BlockType>);
|
||||
#[derive(Debug)]
|
||||
pub struct BlockTypes(HashMap<String, BlockType>);
|
||||
|
||||
impl BlockTypeMap {
|
||||
impl Default for BlockTypes {
|
||||
fn default() -> Self {
|
||||
BlockTypes(
|
||||
block_types::BLOCK_TYPES
|
||||
.iter()
|
||||
.map(|(k, v)| (String::from(*k), *v))
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl BlockTypes {
|
||||
#[inline]
|
||||
pub fn get(&self, id: &str) -> Option<BlockType> {
|
||||
let suffix = id.strip_prefix("minecraft:")?;
|
||||
self.0.get(suffix).copied()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn block_types() -> BlockTypeMap {
|
||||
BlockTypeMap(
|
||||
block_types::BLOCK_TYPES
|
||||
.iter()
|
||||
.map(|(k, v)| (String::from(*k), *v))
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue