Skip to main content

BlockEntityLifecycleExt

Trait BlockEntityLifecycleExt 

Source
pub trait BlockEntityLifecycleExt: BlockEntity {
    // Provided methods
    fn is_removed(&self) -> bool { ... }
    fn set_block_state(&self, state: BlockStateId) { ... }
    fn set_removed(&self) { ... }
    fn clear_removed(&self) { ... }
    fn dispatch_lifecycle_events(&self) { ... }
}
Expand description

Final block-entity common-state operations.

This blanket implementation prevents concrete entities from replacing metadata transitions. Custom behavior belongs in the corresponding BlockEntity::on_* hook, which runs after the update without storage or section locks.

Provided Methods§

Source

fn is_removed(&self) -> bool

Returns whether this block entity has been marked for removal.

Source

fn set_block_state(&self, state: BlockStateId)

Updates the cached block state and orders its callback.

Source

fn set_removed(&self)

Marks this block entity as removed and orders its lifecycle callback.

Source

fn clear_removed(&self)

Reactivates this block entity and orders its lifecycle callback when the flag changed.

Source

fn dispatch_lifecycle_events(&self)

Drains lifecycle callbacks in flag-update order without retaining the lifecycle lock.

A callback may re-enter the entity. Its event is appended and drained by the active dispatcher rather than recursively invoking another callback.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§