pub struct ChunkSection {
pub states: BlockPalette,
pub biomes: BiomePalette,
non_empty_block_count: u16,
fluid_count: u16,
pub ticking_block_count: u16,
ticking_fluid_count: u16,
}Expand description
A chunk section.
Contains a 16x16x16 cube of block states and biomes, along with cached
counts for optimization (similar to vanilla’s LevelChunkSection).
Fields§
§states: BlockPaletteThe block states in the section.
biomes: BiomePaletteThe biomes in the section.
non_empty_block_count: u16Number of non-air blocks in this section (0-4096). Used to quickly check if a section is empty.
fluid_count: u16Number of fluid-containing blocks in this section (0-4096). Includes water, lava, and waterlogged blocks.
ticking_block_count: u16Number of randomly-ticking blocks in this section (0-4096).
ticking_fluid_count: u16Number of randomly-ticking fluids in this section (0-4096).
Implementations§
Source§impl ChunkSection
impl ChunkSection
Sourcepub const fn new_with_biomes(states: BlockPalette, biomes: BiomePalette) -> Self
pub const fn new_with_biomes(states: BlockPalette, biomes: BiomePalette) -> Self
Creates a new chunk section with the given block states and biomes.
Note: You must call recalculate_counts() after creation to initialize
the cached counters if the states palette contains non-air blocks.
Sourcepub const fn is_randomly_ticking(&self) -> bool
pub const fn is_randomly_ticking(&self) -> bool
Returns true if this section contains any randomly-ticking blocks or fluids.
Sourcepub const fn is_randomly_ticking_blocks(&self) -> bool
pub const fn is_randomly_ticking_blocks(&self) -> bool
Returns true if this section contains any randomly-ticking blocks.
Sourcepub const fn is_randomly_ticking_fluids(&self) -> bool
pub const fn is_randomly_ticking_fluids(&self) -> bool
Returns true if this section contains any randomly-ticking fluids.
Sourcepub fn maybe_has_block_light_sources(&self) -> bool
pub fn maybe_has_block_light_sources(&self) -> bool
Returns true if this section’s palette may contain block-light sources.
Sourcepub fn append_block_light_sources(
&self,
chunk_min_x: i32,
section_min_y: i32,
chunk_min_z: i32,
sources: &mut Vec<BlockPos>,
)
pub fn append_block_light_sources( &self, chunk_min_x: i32, section_min_y: i32, chunk_min_z: i32, sources: &mut Vec<BlockPos>, )
Appends block-light source positions in ScalableLux local-index order.
Sourcepub const fn non_empty_block_count(&self) -> u16
pub const fn non_empty_block_count(&self) -> u16
Returns the number of non-air blocks in this section.
Sourcepub const fn fluid_count(&self) -> u16
pub const fn fluid_count(&self) -> u16
Returns the number of fluid-containing blocks in this section.
Sourcepub const fn ticking_block_count(&self) -> u16
pub const fn ticking_block_count(&self) -> u16
Returns the number of randomly-ticking blocks in this section.
Sourcepub const fn ticking_fluid_count(&self) -> u16
pub const fn ticking_fluid_count(&self) -> u16
Returns the number of randomly-ticking fluids in this section.
Sourcepub fn recalculate_counts(&mut self)
pub fn recalculate_counts(&mut self)
Recalculates cached counters from extracted per-state metadata.
Iterates the palette (O(palette_size)) rather than every cube cell
(O(4096)): each block-state appears at most once in the palette and
carries its own occurrence count, so we just classify each unique state
and multiply by its count. Mirrors Moonrise’s BlockCountingBitStorage.
For a Homogeneous section that’s a single classify; for typical
Heterogeneous sections palette is well under 16 entries.
fn recalculate_counts_from_palette( &mut self, counts_for_state: impl FnMut(BlockStateId) -> BlockStateSectionCounts, )
const fn accumulate_counter_traits( non_empty: &mut u16, fluid: &mut u16, ticking_blocks: &mut u16, ticking_fluids: &mut u16, counts: BlockStateSectionCounts, block_count: u16, )
Sourcepub fn contains_poi(&self) -> bool
pub fn contains_poi(&self) -> bool
Whether this section’s palette contains any POI-type block state.
Lets the Full-stage POI populate skip the full 4096-block
scan_and_populate for the overwhelming majority of sections
(stone/dirt/air) that hold no POI blocks — a palette scan of O(≤16)
instead of O(4096). Mirrors vanilla’s LevelChunkSection.maybeHas.
Sourcepub fn set_block_state(
&mut self,
x: usize,
y: usize,
z: usize,
new_state: BlockStateId,
) -> BlockStateId
pub fn set_block_state( &mut self, x: usize, y: usize, z: usize, new_state: BlockStateId, ) -> BlockStateId
Sets a block state and updates the cached counters.
Returns the old block state.
Sourcepub(crate) fn set_block_state_for_generation(
&mut self,
x: usize,
y: usize,
z: usize,
new_state: BlockStateId,
) -> BlockStateId
pub(crate) fn set_block_state_for_generation( &mut self, x: usize, y: usize, z: usize, new_state: BlockStateId, ) -> BlockStateId
Sets a block state through the raw worldgen building path.
Returns the old block state. Cached counters are intentionally not updated; callers must recount before light, promotion, save, or packet serialization.
Sourcepub(crate) fn block_state_section_counts(
state: BlockStateId,
) -> BlockStateSectionCounts
pub(crate) fn block_state_section_counts( state: BlockStateId, ) -> BlockStateSectionCounts
Returns the cached-counter traits for a block state.
pub(crate) fn finalize_generation_counts_if_needed(&mut self)
fn ensure_counter_ready_for_delta(&mut self)
const fn apply_count_change( &mut self, old_counts: BlockStateSectionCounts, new_counts: BlockStateSectionCounts, )
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChunkSection
impl RefUnwindSafe for ChunkSection
impl Send for ChunkSection
impl Sync for ChunkSection
impl Unpin for ChunkSection
impl UnsafeUnpin for ChunkSection
impl UnwindSafe for ChunkSection
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<>>