mirror of
https://github.com/Pumpkin-MC/Pumpkin
synced 2025-07-03 10:07:33 +00:00
* fix * another fix * Update build.rs * Delete pumpkin-data/src/generated directory * clippy fix --------- Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
32 lines
907 B
Rust
32 lines
907 B
Rust
use std::fs;
|
|
|
|
use heck::ToPascalCase;
|
|
use proc_macro2::TokenStream;
|
|
use quote::{format_ident, quote};
|
|
|
|
pub(crate) fn build() -> TokenStream {
|
|
println!("cargo:rerun-if-changed=../assets/chunk_status.json");
|
|
|
|
let chunk_status: Vec<String> =
|
|
serde_json::from_str(&fs::read_to_string("../assets/chunk_status.json").unwrap())
|
|
.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());
|
|
variants.extend([quote! {
|
|
#[serde(rename = #full_name)]
|
|
#name,
|
|
}]);
|
|
}
|
|
quote! {
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
|
|
pub enum ChunkStatus {
|
|
#variants
|
|
}
|
|
}
|
|
}
|