From f15f0325c0a9d62f10ea22b891ab7134391b04fb Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 9 Dec 2023 21:45:36 -0600 Subject: add BlockState::property --- azalea-block/src/generated.rs | 3 ++- azalea-block/src/lib.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'azalea-block/src') 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; +} + /// 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 for FluidState { fn from(state: BlockState) -> Self { - if state.waterlogged() { + if state + .property::() + .unwrap_or_default() + { Self { fluid: azalea_registry::Fluid::Water, height: 15, -- cgit v1.2.3