feat: vegetation patch features (#1708)

* feat: vegetation features

* refactor: surface_direction helpers

* fix: several issues

* refactor: add with_waterlogged helper to Block/BlockState

* refactor: small changes and added helpful comments
This commit is contained in:
RB007
2026-03-20 04:43:28 -04:00
committed by GitHub
parent f2d7a1a332
commit 655e69fc66
8 changed files with 696 additions and 27 deletions

View File

@@ -253,6 +253,20 @@ fn value_to_placement_modifier(v: &Value) -> TokenStream {
/// # Returns
/// A `BlockPredicate` variant token stream, or `compile_error!` for unknown types.
pub fn value_to_block_predicate(v: &Value) -> TokenStream {
// Handle bare string values: "#minecraft:some_tag" is a block-tag predicate,
// "true" (or any non-# string) is AlwaysTrue.
if let Some(s) = v.as_str() {
if let Some(tag) = s.strip_prefix('#') {
return quote! {
BlockPredicate::MatchingBlockTag(MatchingBlockTagPredicate {
offset: OffsetBlocksBlockPredicate { offset: None },
tag: #tag.to_string(),
})
};
}
return quote! { BlockPredicate::AlwaysTrue };
}
let type_str = v["type"].as_str().unwrap_or("");
match type_str {
"minecraft:true" | "" => quote! { BlockPredicate::AlwaysTrue },