pub struct BaseSpawner {
state: SyncMutex<SpawnerState>,
}Expand description
Vanilla-style mutable spawner state shared by normal spawner block entities.
Fields§
§state: SyncMutex<SpawnerState>Implementations§
Source§impl BaseSpawner
impl BaseSpawner
fn get_or_create_next_spawn_data_with_rng<R: Rng + ?Sized>( &self, random: &mut R, ) -> (SpawnData, bool)
Sourcepub fn set_entity_id(&self, entity_type: EntityTypeRef)
pub fn set_entity_id(&self, entity_type: EntityTypeRef)
Configures the active spawn entity.
Sourcepub fn set_entity_data(&self, entity_data: &EntityData)
pub fn set_entity_data(&self, entity_data: &EntityData)
Sets the active spawn entity type and merges the rest of entity_data into it.
Sourcepub const fn on_event_triggered(&self, event: i32) -> bool
pub const fn on_event_triggered(&self, event: i32) -> bool
Returns whether this spawner handles the given block event.
Sourcepub fn spawn_delay(&self) -> i32
pub fn spawn_delay(&self) -> i32
Returns the ticks left until the next spawn cycle. -1 means a new delay is rolled
on the next tick.
Sourcepub fn set_spawn_delay(&self, delay: i32)
pub fn set_spawn_delay(&self, delay: i32)
Sets the ticks left until the next spawn cycle.
Sourcepub fn config(&self) -> BaseSpawnerConfig
pub fn config(&self) -> BaseSpawnerConfig
Returns the spawn-cycle limits.
Sourcepub fn set_config(&self, config: BaseSpawnerConfig)
pub fn set_config(&self, config: BaseSpawnerConfig)
Replaces the spawn-cycle limits.
Sourcepub fn spawn_potentials(&self) -> Vec<WeightedSpawnData>
pub fn spawn_potentials(&self) -> Vec<WeightedSpawnData>
Returns the weighted entries the next spawn data is picked from.
Sourcepub fn set_spawn_potentials(&self, potentials: Vec<WeightedSpawnData>)
pub fn set_spawn_potentials(&self, potentials: Vec<WeightedSpawnData>)
Replaces the weighted entries the next spawn data is picked from. The active spawn data is kept until the next delay roll.
Sourcepub fn next_spawn_data(&self) -> Option<SpawnData>
pub fn next_spawn_data(&self) -> Option<SpawnData>
Returns the active spawn data, if one has been selected.
Sourcepub fn set_next_spawn_data(&self, data: SpawnData)
pub fn set_next_spawn_data(&self, data: SpawnData)
Replaces the active spawn data.
pub(super) fn server_tick( &self, world: &Arc<World>, pos: BlockPos, ) -> SpawnerTickResult
fn delay_result<R: Rng + ?Sized>( &self, world: &Arc<World>, pos: BlockPos, random: &mut R, result: SpawnerTickResult, ) -> SpawnerTickResult
fn delay<R: Rng + ?Sized>( &self, world: &Arc<World>, pos: BlockPos, random: &mut R, ) -> SpawnerTickResult
fn decrement_spawn_delay(&self) -> bool
Trait Implementations§
Source§impl Debug for BaseSpawner
impl Debug for BaseSpawner
Auto Trait Implementations§
impl !Freeze for BaseSpawner
impl !RefUnwindSafe for BaseSpawner
impl Send for BaseSpawner
impl Sync for BaseSpawner
impl Unpin for BaseSpawner
impl UnsafeUnpin for BaseSpawner
impl UnwindSafe for BaseSpawner
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<>>