Skip to main content

TickList

Struct TickList 

Source
pub struct TickList<T: TickKey> {
    pending_ticks: Option<Vec<SavedTick<T>>>,
    ticks: BinaryHeap<QueuedTick<T>>,
    scheduled: FxHashSet<ScheduledTickKey>,
    next_insertion_order: u64,
}
Expand description

Per-chunk storage for scheduled ticks of one type (block or fluid).

Saved and proto-chunk entries remain in pending_ticks until the chunk first reaches block-ticking readiness. Live entries use absolute game-time deadlines. A priority queue keeps live work ordered without scanning every tick.

Fields§

§pending_ticks: Option<Vec<SavedTick<T>>>§ticks: BinaryHeap<QueuedTick<T>>§scheduled: FxHashSet<ScheduledTickKey>§next_insertion_order: u64

Implementations§

Source§

impl<T: TickKey> TickList<T>

Source

pub fn new() -> Self

Creates an empty tick list.

Source

pub(crate) fn new_pending() -> Self

Creates an empty proto-chunk list whose entries remain relative until the promoted Full chunk first becomes block-ticking.

Source

pub(crate) fn from_saved_ticks(saved_ticks: Vec<SavedTick<T>>) -> Self

Creates a tick list from relative-delay ticks loaded from chunk storage.

Vanilla assigns loaded entries the range -len..-1 in saved list order, ensuring they execute before newly scheduled entries with equal timing once the list is unpacked.

Source

pub(crate) fn from_proto_saved_ticks(saved_ticks: Vec<SavedTick<T>>) -> Self

Creates a proto-chunk tick list from relative-delay storage entries.

ProtoChunkTicks.load schedules saved entries individually, so duplicate (pos, type) keys are discarded while preserving the first entry. Full chunk loading intentionally uses Self::from_saved_ticks instead because LevelChunkTicks retains its saved list exactly as stored.

Source

pub(crate) fn schedule( &mut self, tick_type: T, pos: BlockPos, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, ) -> bool

Schedules a live tick with an absolute world game-time deadline.

Returns true if the tick was added, or false when the same (pos, type) is already scheduled.

Source

pub(crate) fn schedule_pending( &mut self, tick_type: T, pos: BlockPos, priority: TickPriority, ) -> bool

Stores a proto-chunk tick with Vanilla’s fixed zero delay.

Source

fn schedule_saved_pending(&mut self, saved_tick: SavedTick<T>) -> bool

Source

pub(crate) fn has_tick(&self, pos: BlockPos, tick_type: T) -> bool

Returns true if a tick is scheduled for the given (pos, type).

Source

pub(crate) fn pending_entries(&self) -> &[SavedTick<T>]

Returns the saved entries that have not yet been anchored to game time.

Source

pub(crate) fn remove_pending_matching( &mut self, predicate: impl FnMut(&SavedTick<T>) -> bool, ) -> usize

Removes pending entries matching predicate while keeping deduplication in sync.

Source

pub(super) fn packing_snapshot(&self) -> TickListPackingSnapshot<T>

Source

pub(crate) fn unpack(&mut self, current_tick: i64)

Converts pending saved/proto ticks into live absolute-time ordering.

This mirrors LevelChunkTicks.unpack: delays are anchored to current_tick and entries receive negative sub-tick orders in saved-list order. Repeated calls are no-ops, so later readiness changes cannot re-anchor deadlines.

Source

pub(crate) fn len(&self) -> usize

Returns the number of scheduled ticks.

Source

fn push_unchecked(&mut self, tick: ScheduledTick<T>)

Source

pub(super) fn peek(&self) -> Option<ScheduledTick<T>>

Source

pub(super) fn peek_ready(&self, current_tick: i64) -> Option<ScheduledTick<T>>

Source

pub(super) fn pop_ready( &mut self, current_tick: i64, ) -> Option<ScheduledTick<T>>

Trait Implementations§

Source§

impl<T: Debug + TickKey> Debug for TickList<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: TickKey> Default for TickList<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TickList<T>

§

impl<T> RefUnwindSafe for TickList<T>
where T: RefUnwindSafe,

§

impl<T> Send for TickList<T>
where T: Send,

§

impl<T> Sync for TickList<T>
where T: Sync,

§

impl<T> Unpin for TickList<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TickList<T>

§

impl<T> UnwindSafe for TickList<T>
where T: UnwindSafe,

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