diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2023-12-10 00:08:08 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-10 00:08:08 -0600 |
| commit | 348c71b97b2dfc45d7412ec33f6131e20592bb14 (patch) | |
| tree | 2490f6fe8e4d8181a526b66e0397ceea96ec8961 /azalea-block | |
| parent | f15f0325c0a9d62f10ea22b891ab7134391b04fb (diff) | |
| download | azalea-drasl-348c71b97b2dfc45d7412ec33f6131e20592bb14.tar.xz | |
Climbing (#121)
* start implementing climbing
* fix tests
* fix bots running at lower tick rate
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::*; |
