Skip to main content

steel_core/behavior/blocks/vegetation/
glow_lichen_block.rs

1use steel_macros::block_behavior;
2use steel_registry::blocks::properties::Direction;
3use steel_utils::{BlockPos, BlockStateId};
4
5use crate::behavior::block::BlockBehavior;
6use crate::behavior::context::BlockPlaceContext;
7use crate::world::{LevelReader, ScheduledTickAccess};
8
9use super::{BlockRef, default_surviving_state, multiface_can_survive, update_multiface_shape};
10
11/// Vanilla `GlowLichenBlock` survival.
12///
13/// Inherits `canSurvive` from `MultifaceBlock`. Subclass-specific spread and
14/// bonemeal behavior is left as a TODO.
15// TODO: Implement spread, bonemeal, and rotation/mirror overrides.
16#[block_behavior]
17pub struct GlowLichenBlock {
18    block: BlockRef,
19}
20
21impl GlowLichenBlock {
22    /// Creates a new glow lichen block behavior.
23    #[must_use]
24    pub const fn new(block: BlockRef) -> Self {
25        Self { block }
26    }
27}
28
29impl BlockBehavior for GlowLichenBlock {
30    fn update_shape(
31        &self,
32        state: BlockStateId,
33        world: &dyn ScheduledTickAccess,
34        pos: BlockPos,
35        direction: Direction,
36        neighbor_pos: BlockPos,
37        neighbor_state: BlockStateId,
38    ) -> BlockStateId {
39        update_multiface_shape(state, world, pos, direction, neighbor_pos, neighbor_state)
40    }
41
42    fn can_survive(&self, state: BlockStateId, world: &dyn LevelReader, pos: BlockPos) -> bool {
43        multiface_can_survive(state, world, pos)
44    }
45
46    fn get_state_for_placement(&self, context: &BlockPlaceContext<'_>) -> Option<BlockStateId> {
47        // TODO: Vanilla picks a face from nearestLookingDirections; placeholder
48        // accepts the default state if it survives at the click position.
49        default_surviving_state(self.block, self, context)
50    }
51}