Skip to main content

Module block_entity

Module block_entity 

Source
Expand description

Block entity system for blocks that need additional data storage.

Block entities provide additional data storage and functionality for blocks that need more than what block state properties can offer (e.g., chests, furnaces, signs, etc.).

ยงArchitecture

Similar to the block/item behavior system, block entities use a registry pattern:

  • BlockEntityRegistry - maps BlockEntityType to factory functions
  • BlockEntityStorage - stores block entities in a chunk

ยงUsage

โ“˜
use steel_core::block_entity::{init_block_entities, BLOCK_ENTITIES};

// After registry is frozen, call once at startup:
init_block_entities();

// Create a block entity:
let entity = BLOCK_ENTITIES.create(block_entity_type, pos, state);

Modulesยง

block_state_nbt ๐Ÿ”’
Vanilla block-state NBT codec shape used by block entities.
entities
Block entity implementations.
registry ๐Ÿ”’
Block entity registry for creating block entity instances.
storage ๐Ÿ”’
Block entity storage for chunks.

Structsยง

BlockEntityBase
Immutable block-entity identity and its short-lived lifecycle state.
BlockEntityLifecycle ๐Ÿ”’
BlockEntityLifecycleDispatchGuard ๐Ÿ”’
BlockEntityRegistry
Registry for block entity factories.
BlockEntityTicker
Erased block-state-selected ticker for one concrete block-entity type.

Enumsยง

BlockEntityLifecycleEvent ๐Ÿ”’

Staticsยง

BLOCK_ENTITIES
Global block entity registry.

Traitsยง

BlockEntity
Trait for all block entities.
BlockEntityLifecycleExt
Final block-entity common-state operations.

Functionsยง

init_block_entities
Initializes the global block entity registry.

Type Aliasesยง

BlockEntityFactory
Factory function type for creating block entities.
SharedBlockEntity
A stable shared block entity without a whole-object mutex.