mirror of
https://github.com/Pumpkin-MC/Pumpkin
synced 2025-01-30 21:51:36 +00:00
32 lines
869 B
Rust
32 lines
869 B
Rust
use heck::ToPascalCase;
|
|
use proc_macro2::TokenStream;
|
|
use quote::quote;
|
|
|
|
use crate::ident;
|
|
|
|
pub(crate) fn build() -> TokenStream {
|
|
println!("cargo:rerun-if-changed=../assets/chunk_status.json");
|
|
|
|
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 = ident(status.to_pascal_case());
|
|
variants.extend([quote! {
|
|
#[serde(rename = #full_name)]
|
|
#name,
|
|
}]);
|
|
}
|
|
quote! {
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
|
|
pub enum ChunkStatus {
|
|
#variants
|
|
}
|
|
}
|
|
}
|