pub struct SectionWriteGuard<'a> {
guard: RwLockWriteGuard<'a, ChunkSection>,
randomly_ticking_sections: &'a RandomTickSectionBits,
section_index: usize,
was_randomly_ticking: bool,
}Expand description
A chunk-section write guard that republishes derived lock-free metadata.
Fields§
§guard: RwLockWriteGuard<'a, ChunkSection>§randomly_ticking_sections: &'a RandomTickSectionBits§section_index: usize§was_randomly_ticking: boolImplementations§
Source§impl<'a> SectionWriteGuard<'a>
impl<'a> SectionWriteGuard<'a>
fn new( guard: RwLockWriteGuard<'a, ChunkSection>, randomly_ticking_sections: &'a RandomTickSectionBits, section_index: usize, ) -> Self
Methods from Deref<Target = ChunkSection>§
Sourcepub fn is_randomly_ticking(&self) -> bool
pub fn is_randomly_ticking(&self) -> bool
Returns true if this section contains any randomly-ticking blocks or fluids.
Sourcepub fn is_randomly_ticking_blocks(&self) -> bool
pub fn is_randomly_ticking_blocks(&self) -> bool
Returns true if this section contains any randomly-ticking blocks.
Sourcepub fn is_randomly_ticking_fluids(&self) -> bool
pub 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 fn non_empty_block_count(&self) -> u16
pub fn non_empty_block_count(&self) -> u16
Returns the number of non-air blocks in this section.
Sourcepub fn fluid_count(&self) -> u16
pub fn fluid_count(&self) -> u16
Returns the number of fluid-containing blocks in this section.
Sourcepub fn ticking_block_count(&self) -> u16
pub fn ticking_block_count(&self) -> u16
Returns the number of randomly-ticking blocks in this section.
Sourcepub fn ticking_fluid_count(&self) -> u16
pub 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, )
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.
pub(crate) fn finalize_generation_counts_if_needed(&mut self)
fn ensure_counter_ready_for_delta(&mut self)
fn apply_count_change( &mut self, old_counts: BlockStateSectionCounts, new_counts: BlockStateSectionCounts, )
Trait Implementations§
Source§impl Deref for SectionWriteGuard<'_>
impl Deref for SectionWriteGuard<'_>
Source§impl DerefMut for SectionWriteGuard<'_>
impl DerefMut for SectionWriteGuard<'_>
Source§impl Drop for SectionWriteGuard<'_>
impl Drop for SectionWriteGuard<'_>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for SectionWriteGuard<'a>
impl<'a> !Send for SectionWriteGuard<'a>
impl<'a> !UnwindSafe for SectionWriteGuard<'a>
impl<'a> Freeze for SectionWriteGuard<'a>
impl<'a> Sync for SectionWriteGuard<'a>
impl<'a> Unpin for SectionWriteGuard<'a>
impl<'a> UnsafeUnpin for SectionWriteGuard<'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<>>