pub struct FullChunkRef<'a> {
chunk: &'a Chunk,
}Expand description
Borrowed capability for Full-only live world access.
Similar to Java’s LevelChunk, this holds a weak reference to the world
(called level in Java) for callbacks during block state changes. Ticking
and initial sending additionally require the corresponding neighborhood
readiness confirmation from ChunkMap.
Fields§
§chunk: &'a ChunkImplementations§
Source§impl FullChunkRef<'_>
impl FullChunkRef<'_>
pub(crate) const fn from_full_context(chunk: &Chunk) -> FullChunkRef<'_>
fn runtime(&self) -> &FullChunkRuntime
pub(crate) fn game_event_listeners(&self) -> &FullChunkGameEventListeners
Sourcepub(crate) const fn common(&self) -> &Chunk
pub(crate) const fn common(&self) -> &Chunk
Returns the data retained across generation and Full runtime access.
Sourcepub const fn sections(&self) -> &Sections
pub const fn sections(&self) -> &Sections
Returns the sections shared with the generation phase.
Sourcepub(crate) fn tick_random_blocks(
&self,
world: &Arc<World>,
random_tick_speed: u32,
random_positions: &mut BlockRandomPositionGenerator,
)
pub(crate) fn tick_random_blocks( &self, world: &Arc<World>, random_tick_speed: u32, random_positions: &mut BlockRandomPositionGenerator, )
Runs random block and fluid ticks for this chunk.
Source§impl FullChunkRef<'_>
impl FullChunkRef<'_>
Sourcefn adopt_proto_block_entities(&self)
fn adopt_proto_block_entities(&self)
Revalidates proto block entities while retaining the same storage instance.
Sourcepub fn get_level(&self) -> Option<Arc<World>>
pub fn get_level(&self) -> Option<Arc<World>>
Returns a reference to the world if it’s still alive.
This mirrors Java’s LevelChunk.getLevel().
Sourcepub fn level_weak(&self) -> Weak<World>
pub fn level_weak(&self) -> Weak<World>
Returns the weak reference to the world.
Use this when you need to pass the world reference to block entities at construction time.
Sourcepub(crate) fn prepare_block_entity_activation(
&self,
holder: &Arc<ChunkHolder>,
) -> Option<BlockEntityActivationBatch>
pub(crate) fn prepare_block_entity_activation( &self, holder: &Arc<ChunkHolder>, ) -> Option<BlockEntityActivationBatch>
Activates load-staged block entities at the serialized chunk lifecycle boundary.
The holder is installed before callbacks so reentrant changes register directly into the world ticker. Existing storage order is retained for this load-only step.
Sourcepub(crate) fn deactivate_block_entities(
&self,
holder: &Arc<ChunkHolder>,
) -> Vec<SharedBlockEntity> ⓘ
pub(crate) fn deactivate_block_entities( &self, holder: &Arc<ChunkHolder>, ) -> Vec<SharedBlockEntity> ⓘ
Deactivates one finalized holder and returns callbacks staged before activation.
Sourcepub(crate) fn suspend_block_entities(&self, holder: &Arc<ChunkHolder>)
pub(crate) fn suspend_block_entities(&self, holder: &Arc<ChunkHolder>)
Makes an unloading holder dormant without discarding wrapper identity.
Sourcepub(crate) fn block_entity_tick_state_if_owned(
&self,
pos: BlockPos,
expected: &SharedBlockEntity,
) -> Option<BlockStateId>
pub(crate) fn block_entity_tick_state_if_owned( &self, pos: BlockPos, expected: &SharedBlockEntity, ) -> Option<BlockStateId>
Captures a live state only while expected remains the exact storage owner.
The section read precedes the storage read, matching block-state writers. Both guards are dropped before the caller selects or invokes behavior.
pub(crate) fn block_entity_tick_target( &self, pos: BlockPos, ) -> Option<(BlockStateId, SharedBlockEntity)>
fn finish_block_entity_change( &self, pos: BlockPos, lifecycle_dispatchers: SmallVec<[SharedBlockEntity; 2]>, )
Sourcepub(crate) fn reconcile_block_entity_game_event_listener(&self, pos: BlockPos)
pub(crate) fn reconcile_block_entity_game_event_listener(&self, pos: BlockPos)
Re-selects one listener without retaining section, storage, or binding locks across the block/provider callback.
fn refresh_block_entity_ticker(&self, pos: BlockPos)
Sourcepub(crate) const fn scheduled_tick_container(&self) -> &Arc<ChunkTickContainer> ⓘ
pub(crate) const fn scheduled_tick_container(&self) -> &Arc<ChunkTickContainer> ⓘ
Returns this chunk’s stable scheduled-tick container.
pub(crate) fn schedule_unregistered_block_tick( &self, block: BlockRef, pos: BlockPos, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, ) -> Option<bool>
pub(crate) fn schedule_unregistered_fluid_tick( &self, fluid: FluidRef, pos: BlockPos, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, ) -> Option<bool>
pub(crate) fn has_scheduled_block_tick( &self, pos: BlockPos, block: BlockRef, ) -> Result<bool, TickSchedulerError>
pub(crate) fn has_scheduled_fluid_tick( &self, pos: BlockPos, fluid: FluidRef, ) -> Result<bool, TickSchedulerError>
Sourcepub(crate) fn schedule_block_tick(
&self,
pos: BlockPos,
block: BlockRef,
trigger_tick: i64,
priority: TickPriority,
sub_tick_order: i64,
)
pub(crate) fn schedule_block_tick( &self, pos: BlockPos, block: BlockRef, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, )
Schedules through the world index, or through local pre-publication storage when this chunk has no live world (as in focused unit tests).
pub(crate) fn schedule_fluid_tick( &self, pos: BlockPos, fluid: FluidRef, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, )
Sourcepub(crate) fn scheduled_tick_snapshot(&self) -> ScheduledTickSnapshot
pub(crate) fn scheduled_tick_snapshot(&self) -> ScheduledTickSnapshot
Takes an owned persistence snapshot without exposing live scheduler data.
Sourcepub fn initialize_light_sources(&self)
pub fn initialize_light_sources(&self)
Fills the vanilla skylight-source cache from current section contents.
Sourcepub(crate) fn take_postprocessing(&self) -> Option<Box<[Vec<u16>]>>
pub(crate) fn take_postprocessing(&self) -> Option<Box<[Vec<u16>]>>
Drains pending vanilla generation postprocessing offsets.
Sourcepub(crate) fn postprocessing_for_serialization(&self) -> Vec<Vec<u16>>
pub(crate) fn postprocessing_for_serialization(&self) -> Vec<Vec<u16>>
Snapshots pending postprocessing offsets for chunk persistence.
Sourcepub(crate) fn post_process_generation(
world: &Arc<World>,
chunk_pos: ChunkPos,
min_y: i32,
postprocessing: Box<[Vec<u16>]>,
)
pub(crate) fn post_process_generation( world: &Arc<World>, chunk_pos: ChunkPos, min_y: i32, postprocessing: Box<[Vec<u16>]>, )
Runs pending vanilla generation postprocessing at the r1 readiness transition.
fn update_from_neighbor_shapes( world: &Arc<World>, state: BlockStateId, pos: BlockPos, ) -> BlockStateId
Sourcefn populate_poi(
level: &Weak<World>,
sections: &Sections,
pos: ChunkPos,
min_y: i32,
)
fn populate_poi( level: &Weak<World>, sections: &Sections, pos: ChunkPos, min_y: i32, )
Scans chunk sections for POI block states and populates world POI storage.
Sourcepub fn get_height(
&self,
heightmap_type: HeightmapType,
local_x: usize,
local_z: usize,
) -> i32
pub fn get_height( &self, heightmap_type: HeightmapType, local_x: usize, local_z: usize, ) -> i32
Gets the first available Y coordinate for a heightmap column.
Sourceconst fn get_section_index(&self, y: i32) -> usize
const fn get_section_index(&self, y: i32) -> usize
Gets the section index for a given Y coordinate.
const fn section_y_from_section_index(min_y: i32, index: usize) -> i32
Sourcefn mark_unsaved(&self)
fn mark_unsaved(&self)
Marks the chunk as unsaved.
Sourcepub fn get_block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity>
pub fn get_block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity>
Gets a block entity at the given position.
Returns None if no block entity exists at the position.
Sourcepub(crate) fn get_block_entity_immediate(
&self,
pos: BlockPos,
) -> Option<SharedBlockEntity>
pub(crate) fn get_block_entity_immediate( &self, pos: BlockPos, ) -> Option<SharedBlockEntity>
Gets a block entity, creating the live block’s implementation when storage is missing.
This is Vanilla’s EntityCreationType.IMMEDIATE path used by Level.getBlockEntity.
fn promote_pending_block_entity( &self, pos: BlockPos, ) -> Option<SharedBlockEntity>
fn commit_pending_creation( &self, pos: BlockPos, expected_state: BlockStateId, creation: BlockEntityCreation, ) -> PendingPromotionCommit
Sourcepub(crate) fn promote_pending_block_entities(&self)
pub(crate) fn promote_pending_block_entities(&self)
Attempts every packed promotion after generation postprocessing.
Intentional Unimplemented markers remain packed until Steel gains their block factory.
Sourcepub fn pending_block_entity_positions(&self) -> Vec<BlockPos>
pub fn pending_block_entity_positions(&self) -> Vec<BlockPos>
Returns packed block-entity positions without causing promotion.
Sourcepub fn set_pending_block_entity(&self, pos: BlockPos)
pub fn set_pending_block_entity(&self, pos: BlockPos)
Retains a Vanilla DUMMY marker for lazy promotion if no concrete entity exists.
Sourcepub fn remove_block_entity(&self, pos: BlockPos) -> bool
pub fn remove_block_entity(&self, pos: BlockPos) -> bool
Removes a block entity at the given position.
Marks the entity as removed and unbinds its world ticker.
Sourcepub(crate) fn remove_block_entity_if_same(
&self,
expected: &dyn BlockEntity,
) -> bool
pub(crate) fn remove_block_entity_if_same( &self, expected: &dyn BlockEntity, ) -> bool
Removes only the entity that still owns its position.
Sourcepub fn add_and_register_block_entity(
&self,
block_entity: SharedBlockEntity,
) -> bool
pub fn add_and_register_block_entity( &self, block_entity: SharedBlockEntity, ) -> bool
Adds a block entity and reconciles its state-selected world ticker.
Note: The world reference should be passed at block entity construction time. Returns false when the entity’s position or type does not match the live state.
fn add_and_register_block_entity_staged( &self, block_entity: SharedBlockEntity, ) -> (bool, SmallVec<[SharedBlockEntity; 2]>)
fn with_locked_block_state<R>( &self, pos: BlockPos, f: impl FnOnce(BlockStateId) -> R, ) -> R
fn reconcile_block_entity_after_set(&self, pos: BlockPos, state: BlockStateId)
Sourcepub fn get_block_entities(&self) -> Vec<SharedBlockEntity> ⓘ
pub fn get_block_entities(&self) -> Vec<SharedBlockEntity> ⓘ
Returns all block entities in this chunk.
Sourcepub(crate) fn clear_all_block_entities_staged(&self) -> ClearedBlockEntities
pub(crate) fn clear_all_block_entities_staged(&self) -> ClearedBlockEntities
Clears entity ownership while deferring lifecycle callbacks to an outer-lock-free caller.
Sourcepub fn set_block_state(
&self,
pos: BlockPos,
state: BlockStateId,
flags: UpdateFlags,
) -> Option<BlockStateId>
pub fn set_block_state( &self, pos: BlockPos, state: BlockStateId, flags: UpdateFlags, ) -> Option<BlockStateId>
Sets a block state at the given position.
Returns the old block state, or None if nothing changed.
The world scheduler serializes gameplay mutations. This method makes the palette and block-entity ownership transition atomic, but its later Vanilla-ordered callbacks and derived-cache updates are not a general concurrent transaction for the same position.
§Arguments
pos- The absolute block positionstate- The new block state to setflags- Update flags controlling behavior
§Panics
Panics if the behavior registry has not been initialized.
pub(crate) fn set_block_state_if_unchanged( &self, pos: BlockPos, expected_state: BlockStateId, new_state: BlockStateId, flags: UpdateFlags, ) -> Option<FullChunkBlockSetResult>
fn set_block_state_inner( &self, pos: BlockPos, expected_state: Option<BlockStateId>, state: BlockStateId, flags: UpdateFlags, ) -> Option<FullChunkBlockSetResult>
fn update_light_section_emptiness(&self, y: i32, is_empty: bool)
fn update_sky_light_sources(&self, local_x: usize, y: i32, local_z: usize)
pub(crate) fn refresh_light_emptiness_maps(&self)
Sourcepub fn get_block_state(&self, pos: BlockPos) -> BlockStateId
pub fn get_block_state(&self, pos: BlockPos) -> BlockStateId
Gets a block state at the given position.
Sourcepub fn highest_filled_section_index(&self) -> Option<usize>
pub fn highest_filled_section_index(&self) -> Option<usize>
Mirrors vanilla ChunkAccess.getHighestFilledSectionIndex.
Sourcepub fn highest_section_position(&self) -> i32
pub fn highest_section_position(&self) -> i32
Mirrors vanilla ChunkAccess.getHighestSectionPosition.
Sourcepub fn extract_chunk_data(&self) -> ChunkPacketData
pub fn extract_chunk_data(&self) -> ChunkPacketData
Extracts the chunk data for sending to the client.
Sourcepub fn extract_light_data(&self, has_skylight: bool) -> LightUpdatePacketData
pub fn extract_light_data(&self, has_skylight: bool) -> LightUpdatePacketData
Extracts the light data for sending to the client.
Trait Implementations§
Source§impl<'a> Clone for FullChunkRef<'a>
impl<'a> Clone for FullChunkRef<'a>
Source§fn clone(&self) -> FullChunkRef<'a>
fn clone(&self) -> FullChunkRef<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for FullChunkRef<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for FullChunkRef<'a>
impl<'a> !UnwindSafe for FullChunkRef<'a>
impl<'a> Freeze for FullChunkRef<'a>
impl<'a> Send for FullChunkRef<'a>
impl<'a> Sync for FullChunkRef<'a>
impl<'a> Unpin for FullChunkRef<'a>
impl<'a> UnsafeUnpin for FullChunkRef<'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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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<>>