mc_vanilla/block/redstone/
mod.rs

1use mc_core::block::{BlockState, BlockStaticMap};
2use mc_core::pos::Direction;
3
4
5pub static REDSTONE_BEHAVIOURS: BlockStaticMap<&'static dyn RedstoneBehaviour> = BlockStaticMap::new();
6
7
8pub trait RedstoneBehaviour: Sync {
9    fn is_signal_source(&self, state: &BlockState) -> bool;
10    fn get_signal(&self, state: &BlockState, direction: Direction) -> u8;
11    fn get_direct_signal(&self, state: &BlockState, direction: Direction) -> u8;
12}
13
14
15pub struct RedstoneConstant(pub u8);
16
17impl RedstoneBehaviour for RedstoneConstant {
18    fn is_signal_source(&self, _state: &BlockState) -> bool { true }
19    fn get_signal(&self, _state: &BlockState, _direction: Direction) -> u8 { self.0 }
20    fn get_direct_signal(&self, _state: &BlockState, _direction: Direction) -> u8 { 0 }
21}
22
23
24pub struct RedstoneEngine {
25    // TODO
26}