Enhance CLI functionality with palette support and update exporters to use BlockPalette

This commit is contained in:
2026-03-23 01:21:21 +01:00
parent 1893b3427f
commit 484415870a
12 changed files with 149 additions and 29 deletions

View File

@@ -1,4 +1,5 @@
mod litematica;
mod mcfunction;
pub use litematica::LitematicaExporter;
pub use mcfunction::McFunctionExporter;

View File

@@ -7,7 +7,7 @@ use std::{
use anyhow::Context;
use flate2::Compression;
use flate2::write::GzEncoder;
use lib::{StructureExporter, VoxelType};
use lib::{BlockPalette, StructureExporter, VoxelType};
use serde::Serialize;
#[derive(Serialize)]
@@ -61,10 +61,11 @@ pub struct LitematicaExporter {
}
impl LitematicaExporter {
pub fn new(body_block: &str, outline_block: &str) -> Self {
pub fn new(palette: &BlockPalette) -> Self {
let mut palette_map = HashMap::new();
palette_map.insert(VoxelType::Body, body_block.to_string());
palette_map.insert(VoxelType::Outline, outline_block.to_string());
palette_map.insert(VoxelType::Body, palette.resolve(&VoxelType::Body));
palette_map.insert(VoxelType::Outline, palette.resolve(&VoxelType::Outline));
palette_map.insert(VoxelType::Shadow, palette.resolve(&VoxelType::Shadow));
Self { palette_map }
}

View File

@@ -1,19 +1,18 @@
use std::collections::HashMap;
use lib::{StructureExporter, VoxelType};
use lib::{BlockPalette, StructureExporter, VoxelType};
pub struct McFunctionExporter {
palette: HashMap<VoxelType, String>,
}
impl McFunctionExporter {
pub fn new(body_block: &str, outline_block: &str) -> Self {
let mut palette = HashMap::new();
palette.insert(VoxelType::Body, body_block.to_string());
palette.insert(VoxelType::Outline, outline_block.to_string());
Self { palette }
pub fn new(palette: &BlockPalette) -> Self {
let mut map = HashMap::new();
map.insert(VoxelType::Body, palette.resolve(&VoxelType::Body));
map.insert(VoxelType::Outline, palette.resolve(&VoxelType::Outline));
map.insert(VoxelType::Shadow, palette.resolve(&VoxelType::Shadow));
Self { palette: map }
}
}