|
|
@ -23,10 +23,16 @@ impl Blocks {
|
|
|
|
Ok(blocks)
|
|
|
|
Ok(blocks)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns the blocks indexed by ID
|
|
|
|
// Returns the references of blocks indexed by state ID
|
|
|
|
pub fn blocks(&self) -> DataResult<HashMap<u32, Block>> {
|
|
|
|
pub fn blocks_by_state_id<'a>(&self, blocks: &'a Vec<Block>) -> DataResult<HashMap<u32, &'a Block>> {
|
|
|
|
let blocks = self.blocks_array()?;
|
|
|
|
let mut blocks_map = HashMap::new();
|
|
|
|
let blocks_map = blocks.into_iter().map(|b| (b.id, b)).collect();
|
|
|
|
blocks.iter().for_each(|b| {
|
|
|
|
|
|
|
|
let min_state_id = b.min_state_id.unwrap_or(b.id << 4);
|
|
|
|
|
|
|
|
let max_state_id = b.max_state_id.unwrap_or(min_state_id + 15);
|
|
|
|
|
|
|
|
(min_state_id..max_state_id).for_each(|s| {
|
|
|
|
|
|
|
|
blocks_map.insert(s, b);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Ok(blocks_map)
|
|
|
|
Ok(blocks_map)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -39,6 +45,14 @@ impl Blocks {
|
|
|
|
Ok(blocks_map)
|
|
|
|
Ok(blocks_map)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns the blocks indexed by ID
|
|
|
|
|
|
|
|
pub fn blocks(&self) -> DataResult<HashMap<u32, Block>> {
|
|
|
|
|
|
|
|
let blocks = self.blocks_array()?;
|
|
|
|
|
|
|
|
let blocks_map = blocks.into_iter().map(|b| (b.id, b)).collect();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(blocks_map)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns the block collision shapes object
|
|
|
|
/// Returns the block collision shapes object
|
|
|
|
pub fn block_collision_shapes(&self) -> DataResult<BlockCollisionShapes> {
|
|
|
|
pub fn block_collision_shapes(&self) -> DataResult<BlockCollisionShapes> {
|
|
|
|
let content = get_version_specific_file(&self.version, BLOCK_COLLISION_SHAPES_FILE)?;
|
|
|
|
let content = get_version_specific_file(&self.version, BLOCK_COLLISION_SHAPES_FILE)?;
|
|
|
|