mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-01 05:29:05 +02:00
Add new nbtdump util
This commit is contained in:
parent
40105aaccd
commit
ddd78079dc
4 changed files with 460 additions and 0 deletions
30
src/bin/nbtdump.rs
Normal file
30
src/bin/nbtdump.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
use std::{fs::File, io::prelude::*, path::PathBuf};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use clap::Parser;
|
||||
use flate2::read::GzDecoder;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
struct Args {
|
||||
/// Filename to dump
|
||||
file: PathBuf,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
let file = File::open(&args.file).context("Failed to open file")?;
|
||||
|
||||
let mut decoder = GzDecoder::new(file);
|
||||
let mut buf = vec![];
|
||||
decoder
|
||||
.read_to_end(&mut buf)
|
||||
.context("Failed to read file")?;
|
||||
|
||||
let nbt: fastnbt::Value =
|
||||
fastnbt::from_bytes(buf.as_slice()).context("Failed to decode NBT data")?;
|
||||
|
||||
println!("{:#x?}", nbt);
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue