Skip to main content

FullChunkRef

Struct FullChunkRef 

Source
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 Chunk

Implementations§

Source§

impl FullChunkRef<'_>

Source

pub(crate) const fn from_full_context(chunk: &Chunk) -> FullChunkRef<'_>

Source

fn runtime(&self) -> &FullChunkRuntime

Source

pub(crate) fn game_event_listeners(&self) -> &FullChunkGameEventListeners

Source

pub(crate) const fn common(&self) -> &Chunk

Returns the data retained across generation and Full runtime access.

Source

pub const fn sections(&self) -> &Sections

Returns the sections shared with the generation phase.

Source

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<'_>

Source

fn adopt_proto_block_entities(&self)

Revalidates proto block entities while retaining the same storage instance.

Source

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

Source

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.

Source

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.

Source

pub(crate) fn deactivate_block_entities( &self, holder: &Arc<ChunkHolder>, ) -> Vec<SharedBlockEntity>

Deactivates one finalized holder and returns callbacks staged before activation.

Source

pub(crate) fn suspend_block_entities(&self, holder: &Arc<ChunkHolder>)

Makes an unloading holder dormant without discarding wrapper identity.

Source

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.

Source

pub(crate) fn block_entity_tick_target( &self, pos: BlockPos, ) -> Option<(BlockStateId, SharedBlockEntity)>

Source

fn finish_block_entity_change( &self, pos: BlockPos, lifecycle_dispatchers: SmallVec<[SharedBlockEntity; 2]>, )

Source

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.

Source

fn refresh_block_entity_ticker(&self, pos: BlockPos)

Source

pub(crate) const fn scheduled_tick_container(&self) -> &Arc<ChunkTickContainer>

Returns this chunk’s stable scheduled-tick container.

Source

pub(crate) fn schedule_unregistered_block_tick( &self, block: BlockRef, pos: BlockPos, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, ) -> Option<bool>

Source

pub(crate) fn schedule_unregistered_fluid_tick( &self, fluid: FluidRef, pos: BlockPos, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, ) -> Option<bool>

Source

pub(crate) fn has_scheduled_block_tick( &self, pos: BlockPos, block: BlockRef, ) -> Result<bool, TickSchedulerError>

Source

pub(crate) fn has_scheduled_fluid_tick( &self, pos: BlockPos, fluid: FluidRef, ) -> Result<bool, TickSchedulerError>

Source

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

Source

pub(crate) fn schedule_fluid_tick( &self, pos: BlockPos, fluid: FluidRef, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, )

Source

pub(crate) fn scheduled_tick_snapshot(&self) -> ScheduledTickSnapshot

Takes an owned persistence snapshot without exposing live scheduler data.

Source

pub fn initialize_light_sources(&self)

Fills the vanilla skylight-source cache from current section contents.

Source

pub(crate) fn take_postprocessing(&self) -> Option<Box<[Vec<u16>]>>

Drains pending vanilla generation postprocessing offsets.

Source

pub(crate) fn postprocessing_for_serialization(&self) -> Vec<Vec<u16>>

Snapshots pending postprocessing offsets for chunk persistence.

Source

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.

Source

fn update_from_neighbor_shapes( world: &Arc<World>, state: BlockStateId, pos: BlockPos, ) -> BlockStateId

Source

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.

Source

pub const fn min_y(&self) -> i32

Returns the minimum Y coordinate of the world.

Source

pub const fn height(&self) -> i32

Returns the total height of the world.

Source

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.

Source

const fn get_section_index(&self, y: i32) -> usize

Gets the section index for a given Y coordinate.

Source

const fn section_y_from_section_index(min_y: i32, index: usize) -> i32

Source

fn mark_unsaved(&self)

Marks the chunk as unsaved.

Source

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.

Source

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.

Source

fn promote_pending_block_entity( &self, pos: BlockPos, ) -> Option<SharedBlockEntity>

Source

fn commit_pending_creation( &self, pos: BlockPos, expected_state: BlockStateId, creation: BlockEntityCreation, ) -> PendingPromotionCommit

Source

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.

Source

pub fn pending_block_entity_positions(&self) -> Vec<BlockPos>

Returns packed block-entity positions without causing promotion.

Source

pub fn set_pending_block_entity(&self, pos: BlockPos)

Retains a Vanilla DUMMY marker for lazy promotion if no concrete entity exists.

Source

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.

Source

pub(crate) fn remove_block_entity_if_same( &self, expected: &dyn BlockEntity, ) -> bool

Removes only the entity that still owns its position.

Source

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.

Source

fn add_and_register_block_entity_staged( &self, block_entity: SharedBlockEntity, ) -> (bool, SmallVec<[SharedBlockEntity; 2]>)

Source

fn with_locked_block_state<R>( &self, pos: BlockPos, f: impl FnOnce(BlockStateId) -> R, ) -> R

Source

fn reconcile_block_entity_after_set(&self, pos: BlockPos, state: BlockStateId)

Source

pub fn get_block_entities(&self) -> Vec<SharedBlockEntity>

Returns all block entities in this chunk.

Source

pub(crate) fn clear_all_block_entities_staged(&self) -> ClearedBlockEntities

Clears entity ownership while deferring lifecycle callbacks to an outer-lock-free caller.

Source

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 position
  • state - The new block state to set
  • flags - Update flags controlling behavior
§Panics

Panics if the behavior registry has not been initialized.

Source

pub(crate) fn set_block_state_if_unchanged( &self, pos: BlockPos, expected_state: BlockStateId, new_state: BlockStateId, flags: UpdateFlags, ) -> Option<FullChunkBlockSetResult>

Source

fn set_block_state_inner( &self, pos: BlockPos, expected_state: Option<BlockStateId>, state: BlockStateId, flags: UpdateFlags, ) -> Option<FullChunkBlockSetResult>

Source

fn update_light_section_emptiness(&self, y: i32, is_empty: bool)

Source

fn update_sky_light_sources(&self, local_x: usize, y: i32, local_z: usize)

Source

pub(crate) fn refresh_light_emptiness_maps(&self)

Source

pub fn get_block_state(&self, pos: BlockPos) -> BlockStateId

Gets a block state at the given position.

Source

pub fn highest_filled_section_index(&self) -> Option<usize>

Mirrors vanilla ChunkAccess.getHighestFilledSectionIndex.

Source

pub fn highest_section_position(&self) -> i32

Mirrors vanilla ChunkAccess.getHighestSectionPosition.

Source

pub fn extract_chunk_data(&self) -> ChunkPacketData

Extracts the chunk data for sending to the client.

Source

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>

Source§

fn clone(&self) -> FullChunkRef<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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