steel_core/behavior/blocks/building/
rotated_pillar_block.rs1use steel_macros::block_behavior;
6use steel_registry::blocks::BlockRef;
7use steel_registry::blocks::block_state_ext::BlockStateExt;
8use steel_registry::blocks::properties::{BlockStateProperties, EnumProperty};
9use steel_utils::BlockStateId;
10use steel_utils::axis::Axis;
11
12use crate::behavior::block::BlockBehavior;
13use crate::behavior::context::BlockPlaceContext;
14
15#[block_behavior]
20pub struct RotatedPillarBlock {
21 block: BlockRef,
22}
23
24impl RotatedPillarBlock {
25 pub const AXIS: EnumProperty<Axis> = BlockStateProperties::AXIS;
27
28 #[must_use]
30 pub const fn new(block: BlockRef) -> Self {
31 Self { block }
32 }
33
34 #[must_use]
36 pub(super) fn placement_state(
37 block: BlockRef,
38 context: &BlockPlaceContext<'_>,
39 ) -> BlockStateId {
40 block
41 .default_state()
42 .set_value(&Self::AXIS, context.clicked_face().get_axis())
43 }
44}
45
46impl BlockBehavior for RotatedPillarBlock {
47 fn get_state_for_placement(&self, context: &BlockPlaceContext<'_>) -> Option<BlockStateId> {
48 Some(Self::placement_state(self.block, context))
49 }
50}