steel_core/behavior/blocks/vegetation/
azalea_block.rs1use steel_macros::block_behavior;
2use steel_registry::{
3 blocks::{BlockRef, block_state_ext::BlockStateExt},
4 vanilla_block_tags::BlockTag,
5};
6use steel_utils::{BlockPos, BlockStateId, Direction};
7
8use crate::{
9 behavior::{
10 BlockBehavior, BlockPlaceContext,
11 blocks::vegetation::{
12 Vegetation, default_surviving_state,
13 vegetation_block::{survival_update_shape, vegetation_can_survive},
14 },
15 },
16 world::{LevelReader, ScheduledTickAccess},
17};
18
19#[block_behavior]
21pub struct AzaleaBlock {
22 block: BlockRef,
23}
24
25impl AzaleaBlock {
26 #[must_use]
28 pub const fn new(block: BlockRef) -> Self {
29 Self { block }
30 }
31}
32
33impl BlockBehavior for AzaleaBlock {
34 fn update_shape(
35 &self,
36 state: BlockStateId,
37 world: &dyn ScheduledTickAccess,
38 pos: BlockPos,
39 _direction: Direction,
40 _neighbor_pos: BlockPos,
41 _neighbor_state: BlockStateId,
42 ) -> BlockStateId {
43 survival_update_shape(self, state, world, pos)
44 }
45
46 fn can_survive(&self, state: BlockStateId, world: &dyn LevelReader, pos: BlockPos) -> bool {
47 vegetation_can_survive(self, state, world, pos)
48 }
49
50 fn get_state_for_placement(&self, context: &BlockPlaceContext<'_>) -> Option<BlockStateId> {
51 default_surviving_state(self.block, self, context)
52 }
53}
54
55impl Vegetation for AzaleaBlock {
56 fn may_place_on(&self, state: BlockStateId, _world: &dyn LevelReader, _pos: BlockPos) -> bool {
57 state.get_block().has_tag(&BlockTag::SUPPORTS_AZALEA)
58 }
59}