pub struct EntityRegistryLock(OnceLock<EntityRegistry>);Expand description
Wrapper for the global entity registry that implements Deref.
Tuple Fields§
§0: OnceLock<EntityRegistry>Implementations§
Source§impl EntityRegistryLock
impl EntityRegistryLock
Sourcepub fn set(&self, registry: EntityRegistry) -> Result<(), EntityRegistry>
pub fn set(&self, registry: EntityRegistry) -> Result<(), EntityRegistry>
Sets the registry. Returns Err if already initialized.
fn get_or_init(&self, init: impl FnOnce() -> EntityRegistry) -> &EntityRegistry
Sourcepub fn get(&self) -> Option<&EntityRegistry>
pub fn get(&self) -> Option<&EntityRegistry>
Returns the initialized registry, if entity factories have been installed.
Methods from Deref<Target = EntityRegistry>§
Sourcepub fn create(
&self,
entity_type: EntityTypeRef,
entity_id: i32,
pos: DVec3,
world: Weak<World>,
) -> Option<SharedEntity>
pub fn create( &self, entity_type: EntityTypeRef, entity_id: i32, pos: DVec3, world: Weak<World>, ) -> Option<SharedEntity>
Creates a new entity instance.
Returns None if no factory is registered for the given type.
Sourcepub fn create_and_load_or_raw(
&self,
request: EntityLoadRequest,
nbt: &BorrowedNbtCompound<'_>,
) -> SharedEntity
pub fn create_and_load_or_raw( &self, request: EntityLoadRequest, nbt: &BorrowedNbtCompound<'_>, ) -> SharedEntity
Creates an entity from persisted data, falling back to raw NBT preservation.
Sourcepub fn has_factory(&self, entity_type: EntityTypeRef) -> bool
pub fn has_factory(&self, entity_type: EntityTypeRef) -> bool
Returns whether a factory is registered for the given type.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EntityRegistryLock
impl RefUnwindSafe for EntityRegistryLock
impl Send for EntityRegistryLock
impl Sync for EntityRegistryLock
impl Unpin for EntityRegistryLock
impl UnsafeUnpin for EntityRegistryLock
impl UnwindSafe for EntityRegistryLock
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<>>