mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-31 08:22:33 +00:00
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:
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user