Skip to main content

steel_core/behavior/blocks/vegetation/
sculk_vein_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 `SculkVeinBlock` survival.
12///
13/// Inherits `canSurvive` from `MultifaceBlock`. Sculk-specific spread is left
14/// as a TODO.
15// TODO: Implement sculk spread, charge handling, and rotation/mirror overrides.
16#[block_behavior]
17pub struct SculkVeinBlock {
18    block: BlockRef,
19}
20
21impl SculkVeinBlock {
22    /// Creates a new sculk vein block behavior.
23    #[must_use]
24    pub const fn new(block: BlockRef) -> Self {
25        Self { block }
26    }
27}
28
29impl BlockBehavior for SculkVeinBlock {
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        default_surviving_state(self.block, self, context)
48    }
49}