pub struct Sections {
pub sections: Box<[SectionHolder]>,
randomly_ticking_sections: Arc<RandomTickSectionBits>,
}Expand description
A collection of chunk sections.
Fields§
§sections: Box<[SectionHolder]>The sections in the collection.
randomly_ticking_sections: Arc<RandomTickSectionBits>Implementations§
Source§impl Sections
impl Sections
Sourcepub fn from_owned(sections: Box<[ChunkSection]>) -> Self
pub fn from_owned(sections: Box<[ChunkSection]>) -> Self
Creates a new Sections from a box of owned ChunkSections.
Sourcepub(crate) const fn random_tick_sections(&self) -> &Arc<RandomTickSectionBits> ⓘ
pub(crate) const fn random_tick_sections(&self) -> &Arc<RandomTickSectionBits> ⓘ
Returns the shared lock-free random-tick section index.
Sourcepub fn get_relative_block(
&self,
relative_x: usize,
relative_y: usize,
relative_z: usize,
) -> Option<BlockStateId>
pub fn get_relative_block( &self, relative_x: usize, relative_y: usize, relative_z: usize, ) -> Option<BlockStateId>
Gets a block at a relative position in the chunk.
Sourcepub fn read_column_into(&self, x: usize, z: usize, buf: &mut Vec<BlockStateId>)
pub fn read_column_into(&self, x: usize, z: usize, buf: &mut Vec<BlockStateId>)
Reads an entire column at (x, z) across all sections into a caller-owned buffer.
Holds each section’s read lock once for 16 Y reads instead of acquiring
a lock per block. Indexed by relative_y (0 = chunk min-y).
The buffer is resized if needed and reused across calls to avoid allocation.
Sourcepub fn read_all_biomes(&self) -> Box<[u16]>
pub fn read_all_biomes(&self) -> Box<[u16]>
Reads all biome palette values into a flat array.
Indexed as [section_idx * 64 + qy * 16 + qz * 4 + qx].
Holds each section’s read lock once for all 64 biome reads.
Sourcepub fn for_each_biome_id(&self, visitor: impl FnMut(u16))
pub fn for_each_biome_id(&self, visitor: impl FnMut(u16))
Visits every biome palette value in section order while holding each section’s read lock once.
Sourcepub fn section_emptiness_map(&self) -> Box<[bool]>
pub fn section_emptiness_map(&self) -> Box<[bool]>
Returns whether each real chunk section contains no non-air blocks.
Sourcepub fn block_light_sources(
&self,
chunk_pos: ChunkPos,
min_y: i32,
) -> Vec<BlockPos>
pub fn block_light_sources( &self, chunk_pos: ChunkPos, min_y: i32, ) -> Vec<BlockPos>
Returns block-light source positions in ScalableLux section/local-index order.
Sourcepub fn write_column_blocks(
&self,
x: usize,
z: usize,
blocks: &[(usize, BlockStateId)],
)
pub fn write_column_blocks( &self, x: usize, z: usize, blocks: &[(usize, BlockStateId)], )
Writes multiple blocks in one column, holding each section’s write guard
across all writes to that section. Most efficient when blocks are grouped
by section (e.g. descending relative_y from a top-to-bottom scan).
Sourcepub fn write_block_batch(&self, blocks: &[(usize, usize, usize, BlockStateId)])
pub fn write_block_batch(&self, blocks: &[(usize, usize, usize, BlockStateId)])
Writes a batch of blocks at arbitrary positions, holding each section’s write guard across consecutive entries in the same section. Blocks should be roughly grouped by section index for best performance.
Each touched section enters worldgen Building mode (raw cube, no palette
tracking) so writes are O(1) stores. Per-write goes through a flat
&mut [V] view of the cube — bypasses the 3-arm set match and the
unused old-value load. recalculate_counts finalizes.
Sourcepub(crate) fn write_tracked_block_batch(
&self,
blocks: &[(usize, usize, usize, BlockStateId)],
)
pub(crate) fn write_tracked_block_batch( &self, blocks: &[(usize, usize, usize, BlockStateId)], )
Writes a batch of blocks while maintaining section counters and palette state.
Blocks should be grouped by section index so each touched section only needs one write guard.
Sourcepub fn set_relative_block(
&self,
relative_x: usize,
relative_y: usize,
relative_z: usize,
value: BlockStateId,
)
pub fn set_relative_block( &self, relative_x: usize, relative_y: usize, relative_z: usize, value: BlockStateId, )
Sets a block at a relative position in the chunk and keeps section counters/palette serialization ready.
Sourcepub(crate) fn set_relative_block_for_generation(
&self,
relative_x: usize,
relative_y: usize,
relative_z: usize,
value: BlockStateId,
)
pub(crate) fn set_relative_block_for_generation( &self, relative_x: usize, relative_y: usize, relative_z: usize, value: BlockStateId, )
Sets a block during worldgen using the raw building palette path.
Callers must finalize by recounting touched sections before save, promotion, or packet serialization.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Sections
impl Freeze for Sections
impl Send for Sections
impl Sync for Sections
impl Unpin for Sections
impl UnsafeUnpin for Sections
impl UnwindSafe for Sections
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<>>