pub struct Block {Show 17 fields
pub key: Identifier,
pub config: BlockConfig,
pub properties: &'static [&'static dyn Property],
pub default_state_offset: u16,
pub suffocating: StateBooleanData,
pub redstone_conductor: StateBooleanData,
pub fluid_state: StateFluidData,
pub randomly_ticking: StateBooleanData,
pub light_properties: LightPropertiesFn,
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 shape_offsets: ShapeOffsetFlags,
pub id: OnceLock<usize>,
}Fields§
§key: Identifier§config: BlockConfig§properties: &'static [&'static dyn Property]§default_state_offset: u16§suffocating: StateBooleanDataVanilla BlockState.isSuffocating values indexed by block-local state offset.
redstone_conductor: StateBooleanDataVanilla BlockState.isRedstoneConductor values indexed by block-local state offset.
fluid_state: StateFluidDataVanilla BlockState.getFluidState values indexed by block-local state offset.
randomly_ticking: StateBooleanDataVanilla BlockState.isRandomlyTicking values indexed by block-local state offset.
light_properties: LightPropertiesFnExtracted vanilla light properties indexed by block-local state offset.
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
shape_offsets: ShapeOffsetFlagsShape channels whose extracted boxes are normalized and need positional 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 Property], ) -> 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 const fn with_suffocating(self, suffocating: StateBooleanData) -> Self
pub const fn with_suffocating(self, suffocating: StateBooleanData) -> Self
Sets the extracted vanilla BlockState.isSuffocating values for this block.
Sourcepub const fn with_redstone_conductor(
self,
redstone_conductor: StateBooleanData,
) -> Self
pub const fn with_redstone_conductor( self, redstone_conductor: StateBooleanData, ) -> Self
Sets the extracted per-state redstone-conductor predicate.
Sourcepub const fn with_fluid_state(self, fluid_state: StateFluidData) -> Self
pub const fn with_fluid_state(self, fluid_state: StateFluidData) -> Self
Sets the extracted per-state fluid values.
Sourcepub const fn with_randomly_ticking(
self,
randomly_ticking: StateBooleanData,
) -> Self
pub const fn with_randomly_ticking( self, randomly_ticking: StateBooleanData, ) -> Self
Sets the extracted per-state random-tick predicate.
Sourcepub const fn with_light_properties(
self,
light_properties: LightPropertiesFn,
) -> Self
pub const fn with_light_properties( self, light_properties: LightPropertiesFn, ) -> Self
Sets the extracted vanilla light properties for this block.
Sourcepub const fn with_shape_offsets(self, offsets: ShapeOffsetFlags) -> Self
pub const fn with_shape_offsets(self, offsets: ShapeOffsetFlags) -> Self
Sets which shape channels use the block state’s positional offset.
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.
pub fn get_light_properties(&self, offset: u16) -> BlockLightProperties
pub fn get_ticking_metadata(&self, offset: u16) -> BlockStateTickingMetadata
Sourcepub fn offset_at(&self, pos: BlockPos) -> DVec3
pub fn offset_at(&self, pos: BlockPos) -> DVec3
Returns the vanilla block-state positional offset for this block.
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 state_count(&self) -> u16
pub fn state_count(&self) -> u16
Total number of distinct states (the product of every property’s value count).
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.
Trait Implementations§
impl Eq for Block
Source§impl RegistryEntry for Block
impl RegistryEntry for Block
Source§impl RegistryHolderSetEntry for Block
impl RegistryHolderSetEntry for Block
Source§const REGISTRY_NAME: &'static str = "block"
const REGISTRY_NAME: &'static str = "block"
Source§fn holder_set_by_id(id: usize) -> Option<&'static Self>
fn holder_set_by_id(id: usize) -> Option<&'static Self>
Source§fn holder_set_by_key(key: &Identifier) -> Option<&'static Self>
fn holder_set_by_key(key: &Identifier) -> Option<&'static Self>
Source§fn holder_set_tag_exists(tag: &Identifier) -> bool
fn holder_set_tag_exists(tag: &Identifier) -> bool
Source§fn holder_set_tag_contains(entry: &'static Self, tag: &Identifier) -> bool
fn holder_set_tag_contains(entry: &'static Self, tag: &Identifier) -> bool
Auto Trait Implementations§
impl !Freeze for Block
impl !RefUnwindSafe for Block
impl !UnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnsafeUnpin for Block
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>