steel_core/behavior/blocks/redstone/
powered_block.rs1use steel_macros::block_behavior;
4use steel_registry::blocks::BlockRef;
5use steel_utils::{BlockPos, BlockStateId};
6
7use crate::behavior::block::BlockBehavior;
8use crate::behavior::context::BlockPlaceContext;
9use crate::world::{LevelReader, SignalQueryContext};
10
11#[block_behavior]
13pub struct PoweredBlock {
14 block: BlockRef,
15}
16
17impl PoweredBlock {
18 #[must_use]
20 pub const fn new(block: BlockRef) -> Self {
21 Self { block }
22 }
23}
24
25impl BlockBehavior for PoweredBlock {
26 fn get_state_for_placement(&self, _context: &BlockPlaceContext<'_>) -> Option<BlockStateId> {
27 Some(self.block.default_state())
28 }
29
30 fn is_signal_source(&self, _state: BlockStateId, _context: SignalQueryContext) -> bool {
31 true
32 }
33
34 fn get_own_signal(
35 &self,
36 _state: BlockStateId,
37 _world: &dyn LevelReader,
38 _pos: BlockPos,
39 _context: SignalQueryContext,
40 ) -> i32 {
41 15
42 }
43}