From 9d4f738d4e66adf0796e163d1c9368aaba906bba Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 10 Feb 2023 01:56:45 +0000 Subject: make blockstate good --- azalea-block/src/blocks.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'azalea-block/src/blocks.rs') 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(&self) -> Option<&T> { + (self as &dyn Any).downcast_ref::() + } } make_block_states! { -- cgit v1.2.3