diff options
| author | Ubuntu <github@matdoes.dev> | 2023-02-10 01:56:45 +0000 |
|---|---|---|
| committer | Ubuntu <github@matdoes.dev> | 2023-02-10 01:56:45 +0000 |
| commit | 9d4f738d4e66adf0796e163d1c9368aaba906bba (patch) | |
| tree | ae7b3c7fca0ff054eb67c1311955e9321a37e559 /azalea-block/src/blocks.rs | |
| parent | 48b2a37aa09f0302b40d0678cdde2703f919ed18 (diff) | |
| download | azalea-drasl-9d4f738d4e66adf0796e163d1c9368aaba906bba.tar.xz | |
make blockstate good
Diffstat (limited to 'azalea-block/src/blocks.rs')
| -rwxr-xr-x | azalea-block/src/blocks.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/azalea-block/src/blocks.rs b/azalea-block/src/blocks.rs index 226542dc..e6923d59 100755 --- a/azalea-block/src/blocks.rs +++ b/azalea-block/src/blocks.rs @@ -1,9 +1,18 @@ +use std::any::Any; + use crate::BlockBehavior; use azalea_block_macros::make_block_states; +use std::fmt::Debug; -pub trait Block { +pub trait Block: Debug + Any { fn behavior(&self) -> BlockBehavior; fn id(&self) -> &'static str; + fn as_blockstate(&self) -> BlockState; +} +impl dyn Block { + pub fn downcast_ref<T: Block>(&self) -> Option<&T> { + (self as &dyn Any).downcast_ref::<T>() + } } make_block_states! { |
