pub struct Block {
pub key: Identifier,
pub config: BlockConfig,
pub properties: &'static [&'static dyn DynProperty],
pub default_state_offset: u16,
pub collision_shape: ShapeFn,
pub support_shape: ShapeFn,
pub outline_shape: ShapeFn,
pub occlusion_shape: ShapeFn,
pub interaction_shape: ShapeFn,
pub visual_shape: ShapeFn,
pub id: OnceLock<usize>,
}Fields§
§key: Identifier§config: BlockConfig§properties: &'static [&'static dyn DynProperty]§default_state_offset: u16§collision_shape: ShapeFnFunction to get collision shape for a state offset
support_shape: ShapeFnFunction to get block support shape for a state offset
outline_shape: ShapeFnFunction to get outline shape for a state offset
occlusion_shape: ShapeFnFunction to get occlusion shape for a state offset
interaction_shape: ShapeFnFunction to get interaction shape for a state offset
visual_shape: ShapeFnFunction to get visual shape for a state offset
id: OnceLock<usize>Cached registry ID, set during registration for O(1) lookup on hot paths.
Implementations§
Source§impl Block
impl Block
pub const fn new( key: Identifier, config: BlockConfig, properties: &'static [&'static dyn DynProperty], ) -> Self
Sourcepub const fn with_shapes(
self,
collision: ShapeFn,
support: ShapeFn,
outline: ShapeFn,
occlusion: ShapeFn,
interaction: ShapeFn,
visual: ShapeFn,
) -> Self
pub const fn with_shapes( self, collision: ShapeFn, support: ShapeFn, outline: ShapeFn, occlusion: ShapeFn, interaction: ShapeFn, visual: ShapeFn, ) -> Self
Sets the shape functions for this block.
Sourcepub fn get_collision_shape(&self, offset: u16) -> VoxelShape
pub fn get_collision_shape(&self, offset: u16) -> VoxelShape
Gets the collision shape for a given state offset.
Sourcepub fn get_support_shape(&self, offset: u16) -> VoxelShape
pub fn get_support_shape(&self, offset: u16) -> VoxelShape
Gets the block support shape for a given state offset.
Sourcepub fn get_outline_shape(&self, offset: u16) -> VoxelShape
pub fn get_outline_shape(&self, offset: u16) -> VoxelShape
Gets the outline shape for a given state offset.
Sourcepub fn get_occlusion_shape(&self, offset: u16) -> VoxelShape
pub fn get_occlusion_shape(&self, offset: u16) -> VoxelShape
Gets the occlusion shape for a given state offset.
Sourcepub fn get_interaction_shape(&self, offset: u16) -> VoxelShape
pub fn get_interaction_shape(&self, offset: u16) -> VoxelShape
Gets the interaction shape for a given state offset.
Sourcepub fn get_visual_shape(&self, offset: u16) -> VoxelShape
pub fn get_visual_shape(&self, offset: u16) -> VoxelShape
Gets the visual shape for a given state offset.
Sourcepub(crate) const fn with_default_state(self, offset: u16) -> Self
pub(crate) const fn with_default_state(self, offset: u16) -> Self
Sets the default state offset for this block. The offset is relative to the block’s base state ID.
For easier usage, consider using with_default_state_from_indices or the
default_state! macro instead of calculating the offset manually.
§Example
const REPEATER: Block = Block::new("repeater", props, &[...])
.with_default_state(4);Sourcepub const fn calculate_offset(
property_indices: &[usize],
property_counts: &[usize],
) -> u16
pub const fn calculate_offset( property_indices: &[usize], property_counts: &[usize], ) -> u16
Const helper to calculate state offset from property indices and counts. Properties are processed in reverse order to match Minecraft’s encoding (last property = inner loop with multiplier 1).
pub fn default_state(&'static self) -> BlockStateId
Sourcepub fn has_tag(&'static self, tag: &Identifier) -> bool
pub fn has_tag(&'static self, tag: &Identifier) -> bool
Returns true if this block is tagged with the given tag.