Skip to main content

offset

Macro offset 

Source
macro_rules! offset {
    ($($prop:expr => $value:expr),* $(,)?) => { ... };
}
Expand description

Re-export for easier access Macro to generate offset calculation from property values in all positions.

Takes property objects and their values, automatically converts to indices. All properties must be specified in order.

§Note

For boolean properties, use .index_of(value) to handle the inverted encoding (true=0, false=1 for Java compatibility).

§Example

use steel_registry::{offset, properties::{BlockStateProperties as Props, RedstoneSide}};

const WIRE: Block = Block::new("wire", behavior, PROPS)
    .with_default_state(offset!(
        Props::EAST_REDSTONE => RedstoneSide::Up,
        Props::NORTH_REDSTONE => RedstoneSide::None,
        Props::POWER => 10,
        Props::ATTACHED => Props::ATTACHED.index_of(false)  // Bools need .index_of()
    ));