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(super) fn spawn_rule(
&self,
entity_type: EntityTypeRef,
) -> Option<fn(EntityTypeRef, &dyn LevelReader, EntitySpawnReason, BlockPos, &mut dyn Rng) -> bool>
pub(super) fn spawn_rule( &self, entity_type: EntityTypeRef, ) -> Option<fn(EntityTypeRef, &dyn LevelReader, EntitySpawnReason, BlockPos, &mut dyn Rng) -> bool>
Returns the spawn placement predicate of an entity type, if it has one.
Read it through SpawnPlacements: registered predicates are only checked
against vanilla for spawner reasons.
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(
&self,
request: EntityLoadRequest,
nbt: &BorrowedNbtCompound<'_>,
) -> Option<SharedEntity>
pub fn create_and_load( &self, request: EntityLoadRequest, nbt: &BorrowedNbtCompound<'_>, ) -> Option<SharedEntity>
Creates an entity from persisted data.
Returns None and logs a warning when Steel has no load factory for the type.
Skipped entities and their passenger trees are not retained when the chunk is saved.
Sourcepub(crate) fn create_and_load_for_spawn_view(
&self,
request: EntityLoadRequest,
nbt: &BorrowedNbtCompoundView<'_, '_>,
) -> Option<SharedEntity>
pub(crate) fn create_and_load_for_spawn_view( &self, request: EntityLoadRequest, nbt: &BorrowedNbtCompoundView<'_, '_>, ) -> Option<SharedEntity>
Creates an entity for the normal spawner path from an already borrowed NBT view.
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.
Sourcepub fn get_implemented(&self) -> impl Iterator<Item = EntityTypeRef> + '_
pub fn get_implemented(&self) -> impl Iterator<Item = EntityTypeRef> + '_
Get all entity types with a registered factory.
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
§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<>>