- Introduced Litematica exporter with necessary data structures for Minecraft text generation. - Added serde dependency for serialization support in multiple crates. - Updated Cargo.toml files to include new dependencies and features. - Created palette module for block palette management.
35 lines
919 B
Rust
35 lines
919 B
Rust
use crate::VoxelType;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct BlockPalette {
|
|
pub name: String,
|
|
pub author: Option<String>,
|
|
pub blocks: PaletteMappings,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct PaletteMappings {
|
|
pub body: String,
|
|
pub outline: Option<String>,
|
|
pub shadow: Option<String>,
|
|
}
|
|
|
|
impl BlockPalette {
|
|
pub fn resolve(&self, voxel: &VoxelType) -> String {
|
|
match voxel {
|
|
VoxelType::Body => self.blocks.body.clone(),
|
|
VoxelType::Outline => self
|
|
.blocks
|
|
.outline
|
|
.clone()
|
|
.unwrap_or_else(|| "minecraft:air".to_string()),
|
|
VoxelType::Shadow => self
|
|
.blocks
|
|
.shadow
|
|
.clone()
|
|
.unwrap_or_else(|| "minecraft:air".to_string()),
|
|
}
|
|
}
|
|
}
|