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: RandomSourceImplementations§
Source§impl<'a> WorldGenRegion<'a>
impl<'a> WorldGenRegion<'a>
Sourcepub fn new(
context: &'a WorldGenContext,
step: &'a ChunkStep,
cache: &'a StaticCache2D<Arc<ChunkHolder>>,
center: ChunkPos,
random: RandomSource,
) -> Self
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.
Sourcepub const fn random_mut(&mut self) -> &mut RandomSource
pub const fn random_mut(&mut self) -> &mut RandomSource
Returns the random source exposed by vanilla WorldGenRegion.getRandom().
Sourcepub fn generation_min_y(&self) -> i32
pub fn generation_min_y(&self) -> i32
Returns the minimum Y coordinate used by vanilla WorldGenerationContext.
Sourcepub fn generation_height(&self) -> i32
pub fn generation_height(&self) -> i32
Returns the vertical generation depth used by vanilla WorldGenerationContext.
Sourcepub fn weak_world(&self) -> Weak<World>
pub fn weak_world(&self) -> Weak<World>
Returns the weak world reference used by generated chunks and entities.
Sourcepub const fn block_light_at(&self, _pos: BlockPos) -> u8
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.
Sourcepub const fn max_y_exclusive(&self) -> i32
pub const fn max_y_exclusive(&self) -> i32
Returns the exclusive maximum build height.
Sourcepub const fn is_outside_build_height(&self, y: i32) -> bool
pub const fn is_outside_build_height(&self, y: i32) -> bool
Checks if a Y coordinate is outside the build height.
Sourcepub const fn required_status_at(
&self,
chunk_x: i32,
chunk_z: i32,
) -> Option<ChunkStatus>
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.
Sourcepub const fn can_write_to_chunk(&self, chunk_x: i32, chunk_z: i32) -> bool
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.
Sourcepub(crate) fn try_chunk(
&self,
chunk_x: i32,
chunk_z: i32,
status: ChunkStatus,
) -> Option<WorldGenChunkRef<'a>>
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.
Sourcepub(crate) fn chunk(
&self,
chunk_x: i32,
chunk_z: i32,
status: ChunkStatus,
) -> WorldGenChunkRef<'a>
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.
fn with_cached_chunk<R>( &self, chunk_x: i32, chunk_z: i32, status: ChunkStatus, f: impl FnOnce(WorldGenChunkRef<'_>) -> R, ) -> R
fn chunk_cache_index(&self, chunk_x: i32, chunk_z: i32) -> Option<usize>
Sourcepub fn block_state(&self, pos: BlockPos) -> BlockStateId
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.
Sourcepub fn block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity>
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.
Sourcepub fn noise_biome_id(&self, quart_x: i32, quart_y: i32, quart_z: i32) -> u16
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.
Sourcepub fn set_block_state(
&self,
pos: BlockPos,
state: BlockStateId,
flags: UpdateFlags,
) -> bool
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.
Sourcefn postprocess_pos_for_state(
state: BlockStateId,
pos: BlockPos,
) -> Option<BlockPos>
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.
Sourcepub fn set_block_entity_data(
&self,
pos: BlockPos,
block_entity_type: BlockEntityTypeRef,
state: BlockStateId,
nbt: NbtCompound,
) -> bool
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.
Sourcepub fn remove_block_entity(&self, pos: BlockPos) -> bool
pub fn remove_block_entity(&self, pos: BlockPos) -> bool
Removes block entity data at a writable worldgen position.
Sourcepub fn add_fresh_entity(&self, entity: SharedEntity) -> bool
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.
Sourcepub fn schedule_block_tick(
&self,
pos: BlockPos,
block: BlockRef,
_delay: i32,
priority: TickPriority,
) -> bool
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.
Sourcepub fn schedule_block_tick_default(
&self,
pos: BlockPos,
block: BlockRef,
delay: i32,
) -> bool
pub fn schedule_block_tick_default( &self, pos: BlockPos, block: BlockRef, delay: i32, ) -> bool
Schedules a block tick with vanilla’s normal priority.
Sourcepub fn schedule_fluid_tick(
&self,
pos: BlockPos,
fluid: FluidRef,
_delay: i32,
priority: TickPriority,
) -> bool
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.
Sourcepub fn schedule_fluid_tick_default(
&self,
pos: BlockPos,
fluid: FluidRef,
delay: i32,
) -> bool
pub fn schedule_fluid_tick_default( &self, pos: BlockPos, fluid: FluidRef, delay: i32, ) -> bool
Schedules a fluid tick with vanilla’s normal priority.
Sourcepub fn mark_pos_for_postprocessing(&self, pos: BlockPos)
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.
Sourcepub fn height_at(&self, heightmap_type: HeightmapType, x: i32, z: i32) -> i32
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.
fn cached_proto_height_at( &self, proto: &Chunk, heightmap_type: HeightmapType, chunk_x: i32, chunk_z: i32, column_index: usize, ) -> i32
fn proto_heightmap_columns( proto: &Chunk, heightmap_type: HeightmapType, ) -> Box<[i32; 256]>
fn invalidate_cached_worldgen_heightmaps(&self, chunk_x: i32, chunk_z: i32)
fn copy_heightmap_columns(heightmap: &Heightmap, min_y: i32) -> Box<[i32; 256]>
pub(crate) fn bulk_section_access_for_ore<'profile>( &self, profile: Option<&'profile RefCell<OreFeatureStats>>, ) -> WorldGenBulkSectionAccess<'_, 'a, 'profile>
fn writable_chunk_for_pos( &self, pos: BlockPos, action: &str, ) -> Option<(i32, i32, ChunkStatus)>
fn dependency_chunk_for_pos( &self, pos: BlockPos, action: &str, ) -> (i32, i32, ChunkStatus)
const fn chessboard_distance( center: ChunkPos, chunk_x: i32, chunk_z: i32, ) -> usize
fn biome_quart_y_indices( min_y: i32, section_count: usize, quart_y: i32, ) -> (usize, usize)
Trait Implementations§
Source§impl LevelAccessor for WorldGenRegion<'_>
impl LevelAccessor for WorldGenRegion<'_>
Source§fn set_block_state(
&self,
pos: BlockPos,
state: BlockStateId,
flags: UpdateFlags,
) -> bool
fn set_block_state( &self, pos: BlockPos, state: BlockStateId, flags: UpdateFlags, ) -> bool
Source§fn play_block_sound(
&self,
sound: SoundEventRef,
pos: BlockPos,
volume: f32,
pitch: f32,
exclude: Option<i32>,
)
fn play_block_sound( &self, sound: SoundEventRef, pos: BlockPos, volume: f32, pitch: f32, exclude: Option<i32>, )
Source§fn game_event(
&self,
event: GameEventRef,
pos: BlockPos,
context: &GameEventContext<'_>,
)
fn game_event( &self, event: GameEventRef, pos: BlockPos, context: &GameEventContext<'_>, )
Source§impl LevelReader for WorldGenRegion<'_>
impl LevelReader for WorldGenRegion<'_>
Source§fn get_block_state(&self, pos: BlockPos) -> BlockStateId
fn get_block_state(&self, pos: BlockPos) -> BlockStateId
Source§fn get_block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity>
fn get_block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity>
Source§fn is_face_sturdy_for(
&self,
state: BlockStateId,
pos: BlockPos,
direction: Direction,
support_type: SupportType,
) -> bool
fn is_face_sturdy_for( &self, state: BlockStateId, pos: BlockPos, direction: Direction, support_type: SupportType, ) -> bool
BlockState.isFaceSturdy for a specific support type. Read moreSource§fn raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8
fn raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8
Source§fn can_see_sky(&self, pos: BlockPos) -> bool
fn can_see_sky(&self, pos: BlockPos) -> bool
BlockAndLightGetter.canSeeSky.Source§fn ambient_light(&self) -> f32
fn ambient_light(&self) -> f32
Source§fn is_face_sturdy(
&self,
state: BlockStateId,
pos: BlockPos,
direction: Direction,
) -> bool
fn is_face_sturdy( &self, state: BlockStateId, pos: BlockPos, direction: Direction, ) -> bool
BlockState.isFaceSturdy with full-face support.Source§fn max_y_exclusive(&self) -> i32
fn max_y_exclusive(&self) -> i32
Source§fn is_outside_build_height(&self, y: i32) -> bool
fn is_outside_build_height(&self, y: i32) -> bool
Source§fn max_local_raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8
fn max_local_raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8
LevelReader.getMaxLocalRawBrightness.Source§fn light_level_dependent_magic_value(&self, pos: BlockPos) -> f32
fn light_level_dependent_magic_value(&self, pos: BlockPos) -> f32
LevelReader.getLightLevelDependentMagicValue.Source§fn pathfinding_cost_from_light_levels(&self, pos: BlockPos) -> f32
fn pathfinding_cost_from_light_levels(&self, pos: BlockPos) -> f32
LevelReader.getPathfindingCostFromLightLevels.Source§impl ScheduledTickAccess for WorldGenRegion<'_>
impl ScheduledTickAccess for WorldGenRegion<'_>
Source§fn fluid_tick_delay(&self, fluid: FluidRef) -> i32
fn fluid_tick_delay(&self, fluid: FluidRef) -> i32
Source§fn schedule_block_tick_default(
&self,
pos: BlockPos,
block: BlockRef,
delay: i32,
) -> bool
fn schedule_block_tick_default( &self, pos: BlockPos, block: BlockRef, delay: i32, ) -> bool
Source§fn schedule_fluid_tick_default(
&self,
pos: BlockPos,
fluid: FluidRef,
delay: i32,
) -> bool
fn schedule_fluid_tick_default( &self, pos: BlockPos, fluid: FluidRef, delay: i32, ) -> bool
Source§fn has_scheduled_block_tick(&self, pos: BlockPos, block: BlockRef) -> bool
fn has_scheduled_block_tick(&self, pos: BlockPos, block: BlockRef) -> bool
(pos, block).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> 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<>>§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> SignalGetter for Twhere
T: LevelReader,
impl<T> SignalGetter for Twhere
T: LevelReader,
Source§fn is_redstone_conductor(&self, state: BlockStateId, pos: BlockPos) -> bool
fn is_redstone_conductor(&self, state: BlockStateId, pos: BlockPos) -> bool
state conducts direct power at this level position.Source§fn get_direct_signal(&self, pos: BlockPos, direction: Direction) -> i32
fn get_direct_signal(&self, pos: BlockPos, direction: Direction) -> i32
pos toward direction.Source§fn get_direct_signal_to(&self, pos: BlockPos) -> i32
fn get_direct_signal_to(&self, pos: BlockPos) -> i32
pos from its six neighbors.Source§fn get_control_input_signal(
&self,
pos: BlockPos,
direction: Direction,
only_diodes: bool,
) -> i32
fn get_control_input_signal( &self, pos: BlockPos, direction: Direction, only_diodes: bool, ) -> i32
Source§fn has_signal(&self, pos: BlockPos, direction: Direction) -> bool
fn has_signal(&self, pos: BlockPos, direction: Direction) -> bool
pos supplies a signal toward direction.Source§fn get_signal(&self, pos: BlockPos, direction: Direction) -> i32
fn get_signal(&self, pos: BlockPos, direction: Direction) -> i32
pos toward direction.Source§fn get_best_own_or_neighbour_signal(&self, pos: BlockPos) -> i32
fn get_best_own_or_neighbour_signal(&self, pos: BlockPos) -> i32
pos, including the block’s own source value.Source§fn has_neighbor_signal(&self, pos: BlockPos) -> bool
fn has_neighbor_signal(&self, pos: BlockPos) -> bool
pos.Source§fn get_best_neighbor_signal(&self, pos: BlockPos) -> i32
fn get_best_neighbor_signal(&self, pos: BlockPos) -> i32
pos by its six neighbors.