Initial commit: Terrafier v0.1.0
- Core world model (World, Dimension, Tile, Terrain, Platform) - NBT reader/writer with full tag support - Anvil region (.mca) format reader with chunk parsing - Block palette compression and export - Biome database with Minecraft 1.21 biomes - CLI commands: new, import, export, info, render - GUI application with egui (viewport, tools, undo/redo) - Noise-based heightmap generation and editing operations License: GPL-3.0-or-later
This commit is contained in:
commit
91835402b3
94 changed files with 12372 additions and 0 deletions
64
cli/src/cmds/export.rs
Executable file
64
cli/src/cmds/export.rs
Executable file
|
|
@ -0,0 +1,64 @@
|
|||
use clap::Args;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::util::output::{self, OutputFormat};
|
||||
use crate::util::{load_world, progress};
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct ExportArgs {
|
||||
/// Path to Terrafier world directory
|
||||
pub world: String,
|
||||
/// Output directory for Minecraft save
|
||||
#[arg(short, long)]
|
||||
pub output: String,
|
||||
/// Minecraft data version (default: 3954 for 1.21)
|
||||
#[arg(long, default_value = "3954")]
|
||||
pub data_version: i32,
|
||||
}
|
||||
|
||||
pub fn cmd_export(
|
||||
args: ExportArgs,
|
||||
format: &OutputFormat,
|
||||
dry_run: bool,
|
||||
validate: bool,
|
||||
) -> anyhow::Result<()> {
|
||||
let world_path = Path::new(&args.world);
|
||||
log::info!("Exporting world from: {}", world_path.display());
|
||||
|
||||
let world = load_world(world_path)?;
|
||||
terrafier_core::io::export::validate_export(&world)?;
|
||||
|
||||
let tile_count: usize = world.dimensions.iter().map(|d| d.tiles.len()).sum();
|
||||
|
||||
if validate || dry_run {
|
||||
output::print_result(
|
||||
format,
|
||||
&serde_json::json!({
|
||||
"status": "validated",
|
||||
"input": args.world,
|
||||
"output": args.output,
|
||||
"tiles": tile_count,
|
||||
}),
|
||||
);
|
||||
if dry_run {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let bar = progress::new_bar(tile_count as u64, "Exporting...");
|
||||
terrafier_core::io::export::export_to_save(&world, Path::new(&args.output))?;
|
||||
progress::finish_with("Export complete", bar);
|
||||
|
||||
log::info!("World exported to: {}", args.output);
|
||||
output::print_result(
|
||||
format,
|
||||
&serde_json::json!({
|
||||
"status": "exported",
|
||||
"input": args.world,
|
||||
"output": args.output,
|
||||
"tiles": tile_count,
|
||||
}),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue