Enhance CLI functionality with palette support and update exporters to use BlockPalette
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
mod litematica;
|
||||
mod mcfunction;
|
||||
|
||||
pub use litematica::LitematicaExporter;
|
||||
pub use mcfunction::McFunctionExporter;
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user