Skip to main content

Sections

Struct Sections 

Source
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

Source

pub fn from_owned(sections: Box<[ChunkSection]>) -> Self

Creates a new Sections from a box of owned ChunkSections.

Source

pub(crate) const fn random_tick_sections(&self) -> &Arc<RandomTickSectionBits>

Returns the shared lock-free random-tick section index.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn section_emptiness_map(&self) -> Box<[bool]>

Returns whether each real chunk section contains no non-air blocks.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Debug for Sections

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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