Skip to main content

steel_core/behavior/blocks/vegetation/
carved_pumpkin_block.rs

1use crate::behavior::{BlockBehavior, BlockPlaceContext, BlockRef};
2use steel_macros::block_behavior;
3use steel_registry::blocks::block_state_ext::BlockStateExt;
4use steel_registry::blocks::properties::{BlockStateProperties, Direction, EnumProperty};
5use steel_utils::BlockStateId;
6
7const HORIZONTAL_FACING: &EnumProperty<Direction> = &BlockStateProperties::HORIZONTAL_FACING;
8
9/// Behavior for carved pumpkins.
10#[block_behavior]
11pub struct CarvedPumpkinBlock {
12    block: BlockRef,
13}
14
15impl CarvedPumpkinBlock {
16    /// Creates a carved pumpkin block behavior.
17    #[must_use]
18    pub const fn new(block: BlockRef) -> Self {
19        Self { block }
20    }
21}
22
23impl BlockBehavior for CarvedPumpkinBlock {
24    fn get_state_for_placement(&self, context: &BlockPlaceContext<'_>) -> Option<BlockStateId> {
25        Some(
26            self.block
27                .default_state()
28                .set_value(HORIZONTAL_FACING, context.horizontal_direction().opposite()),
29        )
30    }
31
32    // TODO: Add golem spawning behavior (iron, copper, snow) including dropper checks
33}