Skip to main content

GenerationContext

Struct GenerationContext 

Source
pub struct GenerationContext<'ctx, 'src, N: DimensionNoises>
where 'src: 'ctx,
{
Show 20 fields seed: i64, chunk_x: i32, chunk_z: i32, chunk_min_x: i32, chunk_min_z: i32, center_block_x: i32, center_block_z: i32, sea_level: i32, surface_y_cache: &'ctx mut Option<i32>, height_cache_grid_ready: &'ctx mut bool, noises: &'src N, splitter: &'src RandomSplitter, template_pools: &'src FxHashMap<Identifier, TemplatePoolData>, templates: &'src FxHashMap<Identifier, TemplateData>, biome_sampler: &'ctx mut ChunkBiomeSampler<'src>, height_cache: &'ctx mut N::ColumnCache, aquifer: &'ctx mut LazyAquifer<'src, N>, terrain_height_cache: RefCell<FxHashMap<(i32, i32, bool), i32>>, terrain_opaque_cache: RefCell<FxHashMap<(i32, i32, i32, bool), bool>>, terrain_probes: RefCell<FxHashMap<(i32, i32), TerrainProbe<N>>>,
}
Expand description

Per-chunk context shared by every structure’s findGenerationPoint.

Holds mutable per-chunk state (biome sampler, height cache, aquifer) so structures don’t each allocate their own. Wraps VanillaGenerator’s helpers.

Fields§

§seed: i64

World seed.

§chunk_x: i32

Chunk being populated.

§chunk_z: i32

Chunk being populated.

§chunk_min_x: i32

chunk_x * 16.

§chunk_min_z: i32

chunk_z * 16.

§center_block_x: i32

chunk_min_x + 8.

§center_block_z: i32

chunk_min_z + 8.

§sea_level: i32

Sea level for this dimension.

§surface_y_cache: &'ctx mut Option<i32>

Shared memoisation slot for the chunk-center surface Y.

§height_cache_grid_ready: &'ctx mut bool

Whether height_cache’s 5×5 quart grid has been populated. Shared across per-structure contexts in the same chunk.

§noises: &'src N

Dimension noise router.

§splitter: &'src RandomSplitter

Positional splitter for per-chunk RNG.

§template_pools: &'src FxHashMap<Identifier, TemplatePoolData>

Template pool registry for jigsaw assembly.

§templates: &'src FxHashMap<Identifier, TemplateData>

Template data registry for jigsaw assembly.

§biome_sampler: &'ctx mut ChunkBiomeSampler<'src>

Biome sampler scoped to this chunk.

§height_cache: &'ctx mut N::ColumnCache

Column cache for height/density queries (grid-initialized on demand).

§aquifer: &'ctx mut LazyAquifer<'src, N>

Aquifer built on first query; skipped on chunks where no structure needs it.

§terrain_height_cache: RefCell<FxHashMap<(i32, i32, bool), i32>>

Cache for terrain height checks.

§terrain_opaque_cache: RefCell<FxHashMap<(i32, i32, i32, bool), bool>>

Cache for terrain opacity checks.

§terrain_probes: RefCell<FxHashMap<(i32, i32), TerrainProbe<N>>>

Probes for off-chunk height/opaque checks.

Implementations§

Source§

impl<'ctx, 'src, N: DimensionNoises> GenerationContext<'ctx, 'src, N>
where 'src: 'ctx,

Source

pub fn new( seed: i64, chunk_x: i32, chunk_z: i32, sea_level: i32, noises: &'src N, splitter: &'src RandomSplitter, template_pools: &'src FxHashMap<Identifier, TemplatePoolData>, templates: &'src FxHashMap<Identifier, TemplateData>, biome_sampler: &'ctx mut ChunkBiomeSampler<'src>, height_cache: &'ctx mut N::ColumnCache, aquifer: &'ctx mut LazyAquifer<'src, N>, surface_y_cache: &'ctx mut Option<i32>, height_cache_grid_ready: &'ctx mut bool, ) -> Self

Creates a per-chunk structure generation context.

Source

pub fn base_height(&mut self, x: i32, z: i32, ocean_floor: bool) -> i32

getBaseHeight(WORLD_SURFACE_WG) — aquifer-aware, scans from preliminary_surface_level + 16.

ocean_floor=false → opaque is Solid+Fluid; true → opaque is Solid only.

In dimensions with a constant preliminary_surface_level (End), use base_height_full instead.

Source

pub fn base_height_full(&mut self, x: i32, z: i32, ocean_floor: bool) -> i32

Full-column scan from chunk top. Matches vanilla’s iterateNoiseColumn.

Source

pub fn biome_at(&mut self, block_x: i32, block_y: i32, block_z: i32) -> BiomeRef

Biome at a block position (quantized to quart).

Source

pub fn column_state(&mut self, x: i32, y: i32, z: i32) -> ColumnBlock

Classify a single block in the base-noise column.

Source

pub fn solid_block_below_air( &mut self, x: i32, z: i32, start_y: i32, min_solid_y: i32, ) -> Option<i32>

Highest solid base-terrain block directly below air in [min_solid_y, start_y).

Source

pub fn surface_y(&mut self) -> i32

Surface Y at chunk center, memoised across per-structure contexts.

Source

fn ensure_height_cache_grid(&mut self)

Trait Implementations§

Source§

impl<N: DimensionNoises> StructureGenerationContext for GenerationContext<'_, '_, N>

Source§

fn seed(&self) -> i64

World seed.
Source§

fn chunk_x(&self) -> i32

Chunk X being populated.
Source§

fn chunk_z(&self) -> i32

Chunk Z being populated.
Source§

fn chunk_min_x(&self) -> i32

Minimum block X of the chunk.
Source§

fn chunk_min_z(&self) -> i32

Minimum block Z of the chunk.
Source§

fn center_block_x(&self) -> i32

Center block X of the chunk.
Source§

fn center_block_z(&self) -> i32

Center block Z of the chunk.
Source§

fn sea_level(&self) -> i32

Sea level for this generator/dimension.
Source§

fn min_y(&self) -> i32

Minimum build Y.
Source§

fn height(&self) -> i32

Total build height.
Source§

fn template_pools(&self) -> &FxHashMap<Identifier, TemplatePoolData>

Template pool registry for jigsaw assembly.
Source§

fn templates(&self) -> &FxHashMap<Identifier, TemplateData>

Structure templates (piece definitions + sizes).
Source§

fn base_height(&mut self, x: i32, z: i32, ocean_floor: bool) -> i32

Base height at a column.
Source§

fn base_height_full(&mut self, x: i32, z: i32, ocean_floor: bool) -> i32

Full-column base height scan.
Source§

fn biome_at(&mut self, block_x: i32, block_y: i32, block_z: i32) -> BiomeRef

Biome at a block position.
Source§

fn column_state(&mut self, x: i32, y: i32, z: i32) -> ColumnBlock

Classify a block in the generator’s base terrain.
Source§

fn solid_block_below_air( &mut self, x: i32, z: i32, start_y: i32, min_solid_y: i32, ) -> Option<i32>

Highest solid base-terrain block directly below air in [min_solid_y, start_y).
Source§

fn surface_y(&mut self) -> i32

Chunk-center surface Y, memoised by the concrete context.
Source§

fn terrain_surface_height(&self, x: i32, z: i32, ocean_floor: bool) -> i32

Surface height for off-chunk terrain queries used by piece placement.
Source§

fn terrain_is_opaque(&self, x: i32, y: i32, z: i32, ocean_floor: bool) -> bool

Opaque terrain test for off-chunk terrain queries used by piece placement.
Source§

fn max_y(&self) -> i32

One-past-maximum build Y.

Auto Trait Implementations§

§

impl<'ctx, 'src, N> !Freeze for GenerationContext<'ctx, 'src, N>

§

impl<'ctx, 'src, N> !RefUnwindSafe for GenerationContext<'ctx, 'src, N>

§

impl<'ctx, 'src, N> !Sync for GenerationContext<'ctx, 'src, N>

§

impl<'ctx, 'src, N> !UnwindSafe for GenerationContext<'ctx, 'src, N>

§

impl<'ctx, 'src, N> Send for GenerationContext<'ctx, 'src, N>

§

impl<'ctx, 'src, N> Unpin for GenerationContext<'ctx, 'src, N>

§

impl<'ctx, 'src, N> UnsafeUnpin for GenerationContext<'ctx, 'src, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> IntoShared for T

§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>>

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more