Files
Pumpkin/pumpkin-data/build/flower_pot_transformations.rs
ht06 0804a07626 Implement Flower pot and change the state of eye blossom flower (#930)
* feat: place flowers, saplings, ... inside the pot

* feat: remove flowers, saplings, ... inside the pot and check when placing block next to the pot

* feat: add changement for eye blossom flower state (open and closed)

* fix: adapt to the BlockState commit (8ebc9ee)

* fix: delete unused import

* fix: refactor

* cargo clippy + fmt

* feat: use extractor to place the flower inside the pot

* All done

* fix: replace blocking_lock() by lock().await

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-07-01 08:50:52 +02:00

28 lines
860 B
Rust

use proc_macro2::TokenStream;
use quote::quote;
use std::{collections::HashMap, fs};
pub(crate) fn build() -> TokenStream {
println!("cargo:rerun-if-changed=../assets/flower_pot_transformations.json");
let flower_pot_transformation: HashMap<u16, u16> = serde_json::from_str(
&fs::read_to_string("../assets/flower_pot_transformations.json").unwrap(),
)
.expect("Failed to parse flower_pot_transformations.json");
let mut variants = TokenStream::new();
for (item_id, potted_block_id) in flower_pot_transformation {
variants.extend(quote! {
#item_id => Some(#potted_block_id),
});
}
quote! {
#[must_use]
pub const fn get_potted_item(item_id: u16) -> Option<u16> {
match item_id {
#variants
_ => None,
}
}
}
}