Add Litematica exporter and integrate serde for serialization
- 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.
This commit is contained in:
@@ -4,6 +4,7 @@ mod font;
|
||||
mod fonts;
|
||||
mod grid;
|
||||
mod models;
|
||||
mod palette;
|
||||
|
||||
pub use engine::{GenerationOptions, TextBuilder};
|
||||
pub use error::{FontError, VoxelError};
|
||||
|
||||
34
crates/lib/src/palette.rs
Normal file
34
crates/lib/src/palette.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
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()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user