diff options
| author | mat <git@matdoes.dev> | 2023-12-09 21:45:36 -0600 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-12-09 21:45:36 -0600 |
| commit | f15f0325c0a9d62f10ea22b891ab7134391b04fb (patch) | |
| tree | 5ac131e9841378a3d8afd1cefa7a2861f7c9bd46 /azalea-block/src | |
| parent | 10ee7e147dc56e12e61ac3bd962abe85ddf25934 (diff) | |
| download | azalea-drasl-f15f0325c0a9d62f10ea22b891ab7134391b04fb.tar.xz | |
add BlockState::property
Diffstat (limited to 'azalea-block/src')
| -rwxr-xr-x | azalea-block/src/generated.rs | 3 | ||||
| -rwxr-xr-x | azalea-block/src/lib.rs | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/azalea-block/src/generated.rs b/azalea-block/src/generated.rs index 3a903b8d..97236b4b 100755 --- a/azalea-block/src/generated.rs +++ b/azalea-block/src/generated.rs @@ -1,4 +1,4 @@ -use crate::{Block, BlockBehavior, BlockState, BlockStates}; +use crate::{Block, BlockBehavior, BlockState, BlockStates, Property}; use azalea_block_macros::make_block_states; use std::fmt::Debug; @@ -5380,3 +5380,4 @@ make_block_states! { }, } } + diff --git a/azalea-block/src/lib.rs b/azalea-block/src/lib.rs index b67a6e76..d590bcea 100755 --- a/azalea-block/src/lib.rs +++ b/azalea-block/src/lib.rs @@ -33,6 +33,12 @@ impl dyn Block { } } +pub trait Property { + type Value; + + fn try_from_block_state(state: BlockState) -> Option<Self::Value>; +} + /// A representation of a state a block can be in. /// /// For example, a stone block only has one state but each possible stair @@ -113,7 +119,10 @@ impl Default for FluidState { impl From<BlockState> for FluidState { fn from(state: BlockState) -> Self { - if state.waterlogged() { + if state + .property::<crate::properties::Waterlogged>() + .unwrap_or_default() + { Self { fluid: azalea_registry::Fluid::Water, height: 15, |
