Skip to main content

WorldGenRegion

Struct WorldGenRegion 

Source
pub struct WorldGenRegion<'a> {
    context: &'a WorldGenContext,
    step: &'a ChunkStep,
    cache: &'a StaticCache2D<Arc<ChunkHolder>>,
    center: ChunkPos,
    chunk_cache_radius: i32,
    chunks: RefCell<Box<[Option<CachedWorldGenChunk<'a>>]>>,
    worldgen_heightmaps: RefCell<Box<[CachedWorldgenHeightmaps]>>,
    random: RandomSource,
}
Expand description

Chunk-cache backed worldgen view for the current generation step.

This deliberately differs from vanilla’s WorldGenRegion in one area: it only exposes chunks already collected by Steel’s StaticCache2D and validated against ChunkStep. That keeps generation deterministic and makes missing dependency declarations fail at the region boundary instead of silently reading farther chunks.

Fields§

§context: &'a WorldGenContext§step: &'a ChunkStep§cache: &'a StaticCache2D<Arc<ChunkHolder>>§center: ChunkPos§chunk_cache_radius: i32§chunks: RefCell<Box<[Option<CachedWorldGenChunk<'a>>]>>§worldgen_heightmaps: RefCell<Box<[CachedWorldgenHeightmaps]>>§random: RandomSource

Implementations§

Source§

impl<'a> WorldGenRegion<'a>

Source

pub fn new( context: &'a WorldGenContext, step: &'a ChunkStep, cache: &'a StaticCache2D<Arc<ChunkHolder>>, center: ChunkPos, random: RandomSource, ) -> Self

Creates a new region over the chunks collected for a generation step.

Source

pub const fn center(&self) -> ChunkPos

Returns the center chunk being generated.

Source

pub const fn random_mut(&mut self) -> &mut RandomSource

Returns the random source exposed by vanilla WorldGenRegion.getRandom().

Source

pub const fn min_y(&self) -> i32

Returns the minimum build height.

Source

pub const fn height(&self) -> i32

Returns the world height.

Source

pub fn generation_min_y(&self) -> i32

Returns the minimum Y coordinate used by vanilla WorldGenerationContext.

Source

pub fn generation_height(&self) -> i32

Returns the vertical generation depth used by vanilla WorldGenerationContext.

Source

pub const fn sea_level(&self) -> i32

Returns this dimension’s sea level.

Source

pub fn seed(&self) -> i64

Returns the world seed.

Source

pub fn weak_world(&self) -> Weak<World>

Returns the weak world reference used by generated chunks and entities.

Source

pub const fn block_light_at(&self, _pos: BlockPos) -> u8

Returns block light as seen by feature-stage worldgen.

Vanilla routes this through the level light engine from WorldGenRegion, but block light is not generated for the feature-stage proto chunks. Treating the region as dark keeps snow and freeze checks aligned with vanilla feature placement.

Source

pub const fn max_y_exclusive(&self) -> i32

Returns the exclusive maximum build height.

Source

pub const fn is_outside_build_height(&self, y: i32) -> bool

Checks if a Y coordinate is outside the build height.

Source

pub const fn required_status_at( &self, chunk_x: i32, chunk_z: i32, ) -> Option<ChunkStatus>

Returns the strongest status directly available for a chunk position in this step.

Source

pub const fn can_write_to_chunk(&self, chunk_x: i32, chunk_z: i32) -> bool

Returns whether block writes are allowed in the given chunk.

Source

pub(crate) fn try_chunk( &self, chunk_x: i32, chunk_z: i32, status: ChunkStatus, ) -> Option<WorldGenChunkRef<'a>>

Gets a chunk if the step declares enough direct dependency status for it.

Source

pub(crate) fn chunk( &self, chunk_x: i32, chunk_z: i32, status: ChunkStatus, ) -> WorldGenChunkRef<'a>

Gets a chunk or panics if generation requested an undeclared dependency.

§Panics

Panics if the chunk is outside this step’s direct dependencies, if the requested status is higher than the dependency contract, or if the holder has not reached the declared status. Those cases indicate a chunk-pyramid or scheduler bug.

Source

fn with_cached_chunk<R>( &self, chunk_x: i32, chunk_z: i32, status: ChunkStatus, f: impl FnOnce(WorldGenChunkRef<'_>) -> R, ) -> R

Source

fn chunk_cache_index(&self, chunk_x: i32, chunk_z: i32) -> Option<usize>

Source

pub fn block_state(&self, pos: BlockPos) -> BlockStateId

Gets a block state through the region dependency contract.

§Panics

Panics if the position’s chunk is outside this step’s direct dependencies.

Source

pub fn block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity>

Gets a block entity through the region dependency contract.

§Panics

Panics if the position’s chunk is outside this step’s direct dependencies.

Source

pub fn noise_biome_id(&self, quart_x: i32, quart_y: i32, quart_z: i32) -> u16

Gets the biome id at quart coordinates through the region dependency contract.

The vertical quart coordinate is clamped to the chunk’s biome section range, matching vanilla ChunkAccess.getNoiseBiome.

§Panics

Panics if the position’s chunk is outside this step’s direct dependencies.

Source

pub fn set_block_state( &self, pos: BlockPos, state: BlockStateId, flags: UpdateFlags, ) -> bool

Sets a block state if the position is inside the step’s write radius.

Returns whether the write was accepted by the region. Positions outside the write radius are rejected without touching chunk data, matching vanilla’s WorldGenRegion.ensureCanWrite gate.

§Panics

Panics if a position inside the write radius is not covered by this step’s direct dependencies, or if the holder has not reached the declared status.

Source

fn postprocess_pos_for_state( state: BlockStateId, pos: BlockPos, ) -> Option<BlockPos>

Mirrors the vanilla Blocks post-process hooks that can affect worldgen output.

Vanilla hardcodes these callbacks in Blocks.java: mushrooms postprocess themselves, while soul sand and magma blocks postprocess the block above.

Source

pub fn set_block_entity_data( &self, pos: BlockPos, block_entity_type: BlockEntityTypeRef, state: BlockStateId, nbt: NbtCompound, ) -> bool

Attaches block entity data at a writable worldgen position.

This mirrors vanilla’s feature paths that place a block first, then configure its block entity. If Steel does not have concrete behavior for the type yet, the raw fallback keeps the NBT intact for later save/load.

Source

pub fn remove_block_entity(&self, pos: BlockPos) -> bool

Removes block entity data at a writable worldgen position.

Source

pub fn add_fresh_entity(&self, entity: SharedEntity) -> bool

Adds an entity to the chunk that owns its position.

Vanilla WorldGenRegion.addFreshEntity does not call ensureCanWrite, so entity insertion is allowed anywhere covered by the generation step’s chunk dependencies.

Source

pub fn schedule_block_tick( &self, pos: BlockPos, block: BlockRef, _delay: i32, priority: TickPriority, ) -> bool

Schedules a block tick in the chunk that owns the target position.

Vanilla WorldGenTickAccess resolves the owning chunk directly and does not apply WorldGenRegion.ensureCanWrite, so ticks can be recorded outside the block write radius as long as the generation step declared the chunk dependency.

Source

pub fn schedule_block_tick_default( &self, pos: BlockPos, block: BlockRef, delay: i32, ) -> bool

Schedules a block tick with vanilla’s normal priority.

Source

pub fn schedule_fluid_tick( &self, pos: BlockPos, fluid: FluidRef, _delay: i32, priority: TickPriority, ) -> bool

Schedules a fluid tick in the chunk that owns the target position.

This mirrors vanilla tick scheduling and intentionally does not apply the block write radius.

Source

pub fn schedule_fluid_tick_default( &self, pos: BlockPos, fluid: FluidRef, delay: i32, ) -> bool

Schedules a fluid tick with vanilla’s normal priority.

Source

pub fn mark_pos_for_postprocessing(&self, pos: BlockPos)

Marks a position for vanilla proto-chunk postprocessing after full promotion.

§Panics

Panics if the target chunk is outside this step’s direct dependencies.

Source

pub fn height_at(&self, heightmap_type: HeightmapType, x: i32, z: i32) -> i32

Gets the first available Y coordinate for a heightmap column.

Mirrors vanilla WorldGenRegion.getHeight, which requests the target chunk at EMPTY and then reads whichever generated status the step dependency cache already holds for that chunk.

Source

fn cached_proto_height_at( &self, proto: &Chunk, heightmap_type: HeightmapType, chunk_x: i32, chunk_z: i32, column_index: usize, ) -> i32

Source

fn proto_heightmap_columns( proto: &Chunk, heightmap_type: HeightmapType, ) -> Box<[i32; 256]>

Source

fn invalidate_cached_worldgen_heightmaps(&self, chunk_x: i32, chunk_z: i32)

Source

fn copy_heightmap_columns(heightmap: &Heightmap, min_y: i32) -> Box<[i32; 256]>

Source

pub(crate) fn bulk_section_access_for_ore<'profile>( &self, profile: Option<&'profile RefCell<OreFeatureStats>>, ) -> WorldGenBulkSectionAccess<'_, 'a, 'profile>

Source

fn writable_chunk_for_pos( &self, pos: BlockPos, action: &str, ) -> Option<(i32, i32, ChunkStatus)>

Source

fn dependency_chunk_for_pos( &self, pos: BlockPos, action: &str, ) -> (i32, i32, ChunkStatus)

Source

const fn chessboard_distance( center: ChunkPos, chunk_x: i32, chunk_z: i32, ) -> usize

Source

fn biome_quart_y_indices( min_y: i32, section_count: usize, quart_y: i32, ) -> (usize, usize)

Trait Implementations§

Source§

impl LevelAccessor for WorldGenRegion<'_>

Source§

fn set_block_state( &self, pos: BlockPos, state: BlockStateId, flags: UpdateFlags, ) -> bool

Sets a block state with vanilla update flags.
Source§

fn play_block_sound( &self, sound: SoundEventRef, pos: BlockPos, volume: f32, pitch: f32, exclude: Option<i32>, )

Plays a block sound when this level surface supports runtime side effects.
Source§

fn game_event( &self, event: GameEventRef, pos: BlockPos, context: &GameEventContext<'_>, )

Dispatches a game event when this level surface supports runtime listeners.
Source§

impl LevelReader for WorldGenRegion<'_>

Source§

fn get_block_state(&self, pos: BlockPos) -> BlockStateId

Gets the block state at a position.
Source§

fn get_block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity>

Gets the block entity at a position when this level surface supports it
Source§

fn is_face_sturdy_for( &self, state: BlockStateId, pos: BlockPos, direction: Direction, support_type: SupportType, ) -> bool

Mirrors vanilla BlockState.isFaceSturdy for a specific support type. Read more
Source§

fn raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8

Returns vanilla raw brightness at a position after sky darkening.
Source§

fn can_see_sky(&self, pos: BlockPos) -> bool

Returns vanilla BlockAndLightGetter.canSeeSky.
Source§

fn ambient_light(&self) -> f32

Returns this dimension’s vanilla ambient light factor.
Source§

fn min_y(&self) -> i32

Returns the minimum build height.
Source§

fn height(&self) -> i32

Returns the build height.
Source§

fn is_face_sturdy( &self, state: BlockStateId, pos: BlockPos, direction: Direction, ) -> bool

Mirrors vanilla BlockState.isFaceSturdy with full-face support.
Source§

fn max_y_exclusive(&self) -> i32

Returns the exclusive maximum build height.
Source§

fn is_outside_build_height(&self, y: i32) -> bool

Checks if a Y coordinate is outside build height.
Source§

fn max_local_raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8

Returns vanilla LevelReader.getMaxLocalRawBrightness.
Source§

fn light_level_dependent_magic_value(&self, pos: BlockPos) -> f32

Returns vanilla LevelReader.getLightLevelDependentMagicValue.
Source§

fn pathfinding_cost_from_light_levels(&self, pos: BlockPos) -> f32

Returns vanilla LevelReader.getPathfindingCostFromLightLevels.
Source§

impl ScheduledTickAccess for WorldGenRegion<'_>

Source§

fn fluid_tick_delay(&self, fluid: FluidRef) -> i32

Returns the fluid tick delay in this level.
Source§

fn schedule_block_tick_default( &self, pos: BlockPos, block: BlockRef, delay: i32, ) -> bool

Schedules a block tick using vanilla’s default priority.
Source§

fn schedule_fluid_tick_default( &self, pos: BlockPos, fluid: FluidRef, delay: i32, ) -> bool

Schedules a fluid tick using vanilla’s default priority.
Source§

fn has_scheduled_block_tick(&self, pos: BlockPos, block: BlockRef) -> bool

Returns whether a tick is already scheduled for the same (pos, block).
Source§

fn will_tick_block_this_tick(&self, pos: BlockPos, block: BlockRef) -> bool

Returns whether the same (pos, block) was selected for this tick and has not started.
Source§

fn will_tick_fluid_this_tick(&self, pos: BlockPos, fluid: FluidRef) -> bool

Returns whether the same (pos, fluid) was selected for this tick and has not started.

Auto Trait Implementations§

§

impl<'a> !Freeze for WorldGenRegion<'a>

§

impl<'a> !RefUnwindSafe for WorldGenRegion<'a>

§

impl<'a> !Sync for WorldGenRegion<'a>

§

impl<'a> !UnwindSafe for WorldGenRegion<'a>

§

impl<'a> Send for WorldGenRegion<'a>

§

impl<'a> Unpin for WorldGenRegion<'a>

§

impl<'a> UnsafeUnpin for WorldGenRegion<'a>

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

impl<T> IntoShared for T

Source§

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
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SignalGetter for T
where T: LevelReader,

Source§

fn is_redstone_conductor(&self, state: BlockStateId, pos: BlockPos) -> bool

Returns whether state conducts direct power at this level position.
Source§

fn get_direct_signal(&self, pos: BlockPos, direction: Direction) -> i32

Returns the direct signal emitted by the block at pos toward direction.
Source§

fn get_direct_signal_to(&self, pos: BlockPos) -> i32

Returns the strongest direct signal entering pos from its six neighbors.
Source§

fn get_control_input_signal( &self, pos: BlockPos, direction: Direction, only_diodes: bool, ) -> i32

Returns the side input used by vanilla diode blocks.
Source§

fn has_signal(&self, pos: BlockPos, direction: Direction) -> bool

Returns whether the block at pos supplies a signal toward direction.
Source§

fn get_signal(&self, pos: BlockPos, direction: Direction) -> i32

Returns the signal supplied by the block at pos toward direction.
Source§

fn get_best_own_or_neighbour_signal(&self, pos: BlockPos) -> i32

Returns the strongest signal at pos, including the block’s own source value.
Source§

fn has_neighbor_signal(&self, pos: BlockPos) -> bool

Returns whether any of the six neighbors supplies signal to pos.
Source§

fn get_best_neighbor_signal(&self, pos: BlockPos) -> i32

Returns the strongest signal supplied to pos by its six neighbors.
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