diff options
Diffstat (limited to 'azalea-block')
| -rwxr-xr-x | azalea-block/azalea-block-macros/src/lib.rs | 21 | ||||
| -rwxr-xr-x | azalea-block/src/lib.rs | 6 |
2 files changed, 11 insertions, 16 deletions
diff --git a/azalea-block/azalea-block-macros/src/lib.rs b/azalea-block/azalea-block-macros/src/lib.rs index 270b49c7..3b983fb4 100755 --- a/azalea-block/azalea-block-macros/src/lib.rs +++ b/azalea-block/azalea-block-macros/src/lib.rs @@ -327,17 +327,11 @@ pub fn make_block_states(input: TokenStream) -> TokenStream { } property_enums.extend(quote! { - #[derive(Debug, Clone, Copy)] + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum #property_struct_name { #property_enum_variants } - // impl Property for #property_struct_name { - // type Value = Self; - - // fn try_from_block_state - // } - impl From<u32> for #property_struct_name { fn from(value: u32) -> Self { match value { @@ -354,13 +348,9 @@ pub fn make_block_states(input: TokenStream) -> TokenStream { property_variant_types = vec!["true".to_string(), "false".to_string()]; property_enums.extend(quote! { - #[derive(Debug, Clone, Copy)] + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct #property_struct_name(pub bool); - // impl Property for #property_struct_name { - // type Value = bool; - // } - impl From<u32> for #property_struct_name { fn from(value: u32) -> Self { match value { @@ -542,10 +532,9 @@ pub fn make_block_states(input: TokenStream) -> TokenStream { // add to properties_to_state_ids let property_variants = properties_to_state_ids .entry(property_value_name_ident.to_string()) - .or_insert_with(Vec::new); - let property_variant_data = property_variants - .iter_mut() - .find(|v| v.ident.to_string() == variant.to_string()); + .or_default(); + let property_variant_data = + property_variants.iter_mut().find(|v| v.ident == variant); if let Some(property_variant_data) = property_variant_data { property_variant_data.block_state_ids.push(state_id); } else { diff --git a/azalea-block/src/lib.rs b/azalea-block/src/lib.rs index d590bcea..983de579 100755 --- a/azalea-block/src/lib.rs +++ b/azalea-block/src/lib.rs @@ -167,6 +167,12 @@ impl From<FluidState> for BlockState { } } +impl From<BlockState> for azalea_registry::Block { + fn from(value: BlockState) -> Self { + Box::<dyn Block>::from(value).as_registry_block() + } +} + #[cfg(test)] mod tests { use super::*; |
