mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-06 23:59:07 +02:00
world: implement top_layer function
Implement one of the core functions of MinedMap: finding the topmost visible block at each coordinate.
This commit is contained in:
parent
2530a557a9
commit
f48aa877d2
3 changed files with 148 additions and 2 deletions
19
src/main.rs
19
src/main.rs
|
@ -3,6 +3,8 @@ use std::path::PathBuf;
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
|
||||
use minedmap::{resource, world};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
struct Args {
|
||||
/// Filename to dump
|
||||
|
@ -12,9 +14,22 @@ struct Args {
|
|||
fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
let block_types = resource::block_types();
|
||||
|
||||
minedmap::io::region::from_file(args.file.as_path())?.foreach_chunk(
|
||||
|coords, value: minedmap::world::de::Chunk| {
|
||||
println!("Chunk {:?}: {:#?}", coords, value);
|
||||
|coords, data: world::de::Chunk| {
|
||||
let chunk = match world::chunk::Chunk::new(&data) {
|
||||
Ok(chunk) => chunk,
|
||||
Err(err) => {
|
||||
eprintln!("Chunk {:?}: {}", coords, err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
match world::layer::top_layer(&chunk, &block_types) {
|
||||
Ok(_) => {}
|
||||
Err(err) => println!("{:?}", err),
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue