aboutsummaryrefslogtreecommitdiff
path: root/azalea-block/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-12-09 21:45:36 -0600
committermat <git@matdoes.dev>2023-12-09 21:45:36 -0600
commitf15f0325c0a9d62f10ea22b891ab7134391b04fb (patch)
tree5ac131e9841378a3d8afd1cefa7a2861f7c9bd46 /azalea-block/src
parent10ee7e147dc56e12e61ac3bd962abe85ddf25934 (diff)
downloadazalea-drasl-f15f0325c0a9d62f10ea22b891ab7134391b04fb.tar.xz
add BlockState::property
Diffstat (limited to 'azalea-block/src')
-rwxr-xr-xazalea-block/src/generated.rs3
-rwxr-xr-xazalea-block/src/lib.rs11
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,