pub struct BlockEntityRegistryLock(OnceLock<BlockEntityRegistry>);Expand description
Wrapper for the global block entity registry that implements Deref.
Tuple Fields§
§0: OnceLock<BlockEntityRegistry>Implementations§
Source§impl BlockEntityRegistryLock
impl BlockEntityRegistryLock
Sourcepub fn set(
&self,
registry: BlockEntityRegistry,
) -> Result<(), BlockEntityRegistry>
pub fn set( &self, registry: BlockEntityRegistry, ) -> Result<(), BlockEntityRegistry>
Sets the registry. Returns Err if already initialized.
fn get_or_init( &self, init: impl FnOnce() -> BlockEntityRegistry, ) -> &BlockEntityRegistry
Methods from Deref<Target = BlockEntityRegistry>§
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 BlockEntityRegistryLock
impl RefUnwindSafe for BlockEntityRegistryLock
impl Send for BlockEntityRegistryLock
impl Sync for BlockEntityRegistryLock
impl Unpin for BlockEntityRegistryLock
impl UnsafeUnpin for BlockEntityRegistryLock
impl UnwindSafe for BlockEntityRegistryLock
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
Mutably borrows from an owned value. Read more
§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> ⓘ
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 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> ⓘ
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 moreWraps this value in an
Arc<SyncMutex<>>