0
0
mirror of https://github.com/Pumpkin-MC/Pumpkin synced 2025-02-23 05:06:11 +00:00

30 lines
880 B
Rust
Raw Permalink Normal View History

2025-01-10 15:31:20 +01:00
use heck::ToPascalCase;
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
2025-01-10 15:31:20 +01:00
pub(crate) fn build() -> TokenStream {
println!("cargo:rerun-if-changed=../assets/chunk_status.json");
2025-01-10 15:31:20 +01:00
let chunk_status: Vec<String> =
serde_json::from_str(include_str!("../../assets/chunk_status.json"))
.expect("Failed to parse chunk_status.json");
let mut variants = TokenStream::new();
for status in chunk_status.iter() {
let full_name = format!("minecraft:{status}");
let name = format_ident!("{}", status.to_pascal_case());
2025-01-10 15:31:20 +01:00
variants.extend([quote! {
#[serde(rename = #full_name)]
#name,
}]);
}
quote! {
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
pub enum ChunkStatus {
#variants
}
}
}