Skip to main content

Block

Struct Block 

Source
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: StateBooleanData

Vanilla BlockState.isSuffocating values indexed by block-local state offset.

§redstone_conductor: StateBooleanData

Vanilla BlockState.isRedstoneConductor values indexed by block-local state offset.

§fluid_state: StateFluidData

Vanilla BlockState.getFluidState values indexed by block-local state offset.

§randomly_ticking: StateBooleanData

Vanilla BlockState.isRandomlyTicking values indexed by block-local state offset.

§light_properties: LightPropertiesFn

Extracted vanilla light properties indexed by block-local state offset.

§collision_shape: ShapeFn

Function to get collision shape for a state offset

§support_shape: ShapeFn

Function to get block support shape for a state offset

§outline_shape: ShapeFn

Function to get outline shape for a state offset

§occlusion_shape: ShapeFn

Function to get occlusion shape for a state offset

§interaction_shape: ShapeFn

Function to get interaction shape for a state offset

§visual_shape: ShapeFn

Function to get visual shape for a state offset

§shape_offsets: ShapeOffsetFlags

Shape 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

Source

pub const fn new( key: Identifier, config: BlockConfig, properties: &'static [&'static dyn Property], ) -> Self

Source

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.

Source

pub const fn with_suffocating(self, suffocating: StateBooleanData) -> Self

Sets the extracted vanilla BlockState.isSuffocating values for this block.

Source

pub const fn with_redstone_conductor( self, redstone_conductor: StateBooleanData, ) -> Self

Sets the extracted per-state redstone-conductor predicate.

Source

pub const fn with_fluid_state(self, fluid_state: StateFluidData) -> Self

Sets the extracted per-state fluid values.

Source

pub const fn with_randomly_ticking( self, randomly_ticking: StateBooleanData, ) -> Self

Sets the extracted per-state random-tick predicate.

Source

pub const fn with_light_properties( self, light_properties: LightPropertiesFn, ) -> Self

Sets the extracted vanilla light properties for this block.

Source

pub const fn with_shape_offsets(self, offsets: ShapeOffsetFlags) -> Self

Sets which shape channels use the block state’s positional offset.

Source

pub fn get_collision_shape(&self, offset: u16) -> VoxelShape

Gets the collision shape for a given state offset.

Source

pub fn get_support_shape(&self, offset: u16) -> VoxelShape

Gets the block support shape for a given state offset.

Source

pub fn get_outline_shape(&self, offset: u16) -> VoxelShape

Gets the outline shape for a given state offset.

Source

pub fn get_occlusion_shape(&self, offset: u16) -> VoxelShape

Gets the occlusion shape for a given state offset.

Source

pub fn get_interaction_shape(&self, offset: u16) -> VoxelShape

Gets the interaction shape for a given state offset.

Source

pub fn get_visual_shape(&self, offset: u16) -> VoxelShape

Gets the visual shape for a given state offset.

Source

pub fn get_light_properties(&self, offset: u16) -> BlockLightProperties

Source

pub fn get_ticking_metadata(&self, offset: u16) -> BlockStateTickingMetadata

Source

pub fn offset_at(&self, pos: BlockPos) -> DVec3

Returns the vanilla block-state positional offset for this block.

Source

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);
Source

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).

Source

pub fn default_state(&'static self) -> BlockStateId

Source

pub fn state_count(&self) -> u16

Total number of distinct states (the product of every property’s value count).

Source

pub fn has_tag(&'static self, tag: &Identifier) -> bool

Returns true if this block is tagged with the given tag.

Trait Implementations§

Source§

impl Debug for Block

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Block

Source§

impl PartialEq for Block

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl RegistryEntry for Block

Source§

fn key(&self) -> &Identifier

Source§

fn try_id(&self) -> Option<usize>

Source§

fn id(&self) -> usize

Panics Read more
Source§

impl RegistryHolderSetEntry for Block

Source§

const REGISTRY_NAME: &'static str = "block"

Human-readable registry name used in codec errors.
Source§

fn holder_set_by_id(id: usize) -> Option<&'static Self>

Looks up an entry by its protocol registry ID.
Source§

fn holder_set_by_key(key: &Identifier) -> Option<&'static Self>

Looks up an entry by its registry key.
Source§

fn holder_set_tag_exists(tag: &Identifier) -> bool

Returns whether the registry contains this tag.
Source§

fn holder_set_tag_contains(entry: &'static Self, tag: &Identifier) -> bool

Returns whether an entry belongs to this tag.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>>

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<E> StatValueRegistryEntry for E
where E: RegistryEntry + Send + Sync,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more