pub struct WorldGenContext {
pub generator: Arc<ChunkGeneratorType>,
world: Weak<World>,
min_y: i32,
height: i32,
sea_level: i32,
}Expand description
Context for world generation.
Similar to vanilla’s WorldGenContext, this provides access to the level/dimension
and generation infrastructure.
Fields§
§generator: Arc<ChunkGeneratorType>The chunk generator to use.
world: Weak<World>Weak reference to the world (to avoid circular Arc reference).
Use world() to get a strong reference when needed.
min_y: i32Cached dimension minimum build Y. Immutable for the world’s lifetime;
cached here so per-block queries avoid a Weak<World>::upgrade (a
cross-thread atomic refcount round-trip) on every call.
height: i32Cached dimension build height. See Self::min_y.
sea_level: i32Cached dimension sea level. Immutable for the world’s lifetime. Read
per-column by the freeze_top_layer feature (snow/ice placement);
cached here so it avoids a Weak<World>::upgrade (cross-thread atomic
on the shared Arc<World>) on every column. See Self::min_y.
Implementations§
Source§impl WorldGenContext
impl WorldGenContext
Sourcepub const fn new(
generator: Arc<ChunkGeneratorType>,
world: Weak<World>,
min_y: i32,
height: i32,
sea_level: i32,
) -> Self
pub const fn new( generator: Arc<ChunkGeneratorType>, world: Weak<World>, min_y: i32, height: i32, sea_level: i32, ) -> Self
Creates a new WorldGenContext.
min_y/height are the dimension’s build bounds (DimensionType::min_y
/ ::height); they are cached rather than read from the world per call.
Sourcepub const fn sea_level(&self) -> i32
pub const fn sea_level(&self) -> i32
Returns the dimension’s sea level (cached; see Self::min_y).
Sourcepub fn weak_world(&self) -> Weak<World>
pub fn weak_world(&self) -> Weak<World>
Gets a weak reference to the world.
This is useful for passing to chunks without creating a strong reference cycle.
Sourcepub fn generation_min_y(&self) -> i32
pub fn generation_min_y(&self) -> i32
Returns the minimum Y coordinate used by WorldGenerationContext.
Sourcepub fn generation_height(&self) -> i32
pub fn generation_height(&self) -> i32
Returns the height used by WorldGenerationContext.
Sourcepub const fn section_count(&self) -> usize
pub const fn section_count(&self) -> usize
How many sections this dimension has
Auto Trait Implementations§
impl !RefUnwindSafe for WorldGenContext
impl !UnwindSafe for WorldGenContext
impl Freeze for WorldGenContext
impl Send for WorldGenContext
impl Sync for WorldGenContext
impl Unpin for WorldGenContext
impl UnsafeUnpin for WorldGenContext
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<>>