pub struct BlockEntityRegistry {
entries: Vec<BlockEntityEntry>,
}Expand description
Registry for block entity factories.
Maps BlockEntityType to factory functions that can create block entity instances.
This is used when loading block entities from disk or when blocks with entities
are placed.
Fields§
§entries: Vec<BlockEntityEntry>Implementations§
Source§impl BlockEntityRegistry
impl BlockEntityRegistry
Sourcepub fn register(
&mut self,
block_entity_type: BlockEntityTypeRef,
factory: BlockEntityFactory,
)
pub fn register( &mut self, block_entity_type: BlockEntityTypeRef, factory: BlockEntityFactory, )
Registers a factory function for a block entity type.
Sourcepub fn create(
&self,
block_entity_type: BlockEntityTypeRef,
level: Weak<World>,
pos: BlockPos,
state: BlockStateId,
) -> Option<SharedBlockEntity>
pub fn create( &self, block_entity_type: BlockEntityTypeRef, level: Weak<World>, pos: BlockPos, state: BlockStateId, ) -> Option<SharedBlockEntity>
Creates a new block entity instance.
Returns None if no factory is registered for the given type.
Sourcepub fn create_or_raw(
&self,
block_entity_type: BlockEntityTypeRef,
level: Weak<World>,
pos: BlockPos,
state: BlockStateId,
) -> SharedBlockEntity
pub fn create_or_raw( &self, block_entity_type: BlockEntityTypeRef, level: Weak<World>, pos: BlockPos, state: BlockStateId, ) -> SharedBlockEntity
Creates a block entity, falling back to an NBT-preserving raw entity.
Use this for disk/worldgen paths where an unimplemented block entity type must still
survive save/load. Gameplay paths that require concrete behavior should call
Self::create and handle None.
Sourcepub fn create_and_load_or_raw(
&self,
block_entity_type: BlockEntityTypeRef,
level: Weak<World>,
pos: BlockPos,
state: BlockStateId,
nbt: &BorrowedNbtCompound<'_>,
) -> SharedBlockEntity
pub fn create_and_load_or_raw( &self, block_entity_type: BlockEntityTypeRef, level: Weak<World>, pos: BlockPos, state: BlockStateId, nbt: &BorrowedNbtCompound<'_>, ) -> SharedBlockEntity
Creates a block entity and loads borrowed NBT, falling back to raw preservation.
Sourcepub fn create_and_load_owned_or_raw(
&self,
block_entity_type: BlockEntityTypeRef,
level: Weak<World>,
pos: BlockPos,
state: BlockStateId,
nbt: NbtCompound,
) -> SharedBlockEntity
pub fn create_and_load_owned_or_raw( &self, block_entity_type: BlockEntityTypeRef, level: Weak<World>, pos: BlockPos, state: BlockStateId, nbt: NbtCompound, ) -> SharedBlockEntity
Creates a block entity and loads owned NBT, falling back to raw preservation.
Sourcepub fn has_factory(&self, block_entity_type: BlockEntityTypeRef) -> bool
pub fn has_factory(&self, block_entity_type: BlockEntityTypeRef) -> bool
Returns whether a factory is registered for the given type.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BlockEntityRegistry
impl RefUnwindSafe for BlockEntityRegistry
impl Send for BlockEntityRegistry
impl Sync for BlockEntityRegistry
impl Unpin for BlockEntityRegistry
impl UnsafeUnpin for BlockEntityRegistry
impl UnwindSafe for BlockEntityRegistry
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<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<>>