pub(super) struct SpreadContext<'a> {
state_cache: FxHashMap<i16, BlockStateId>,
hole_cache: FxHashMap<i16, bool>,
world: &'a Arc<World>,
origin: BlockPos,
}Expand description
Context for fluid spread calculations with local caching.
This is created fresh for each get_spread() call and caches:
BlockStatelookups by relative position- Hole check results by relative position
Fields§
§state_cache: FxHashMap<i16, BlockStateId>Cache for block states by encoded relative position
hole_cache: FxHashMap<i16, bool>Cache for hole check results by encoded relative position
world: &'a Arc<World>Reference to world for cache misses
origin: BlockPosThe block from which spreading originates — used to compute relative cache keys.
Implementations§
Source§impl<'a> SpreadContext<'a>
impl<'a> SpreadContext<'a>
Sourcepub(super) fn new(world: &'a Arc<World>, origin: BlockPos) -> Self
pub(super) fn new(world: &'a Arc<World>, origin: BlockPos) -> Self
Creates a new SpreadContext anchored at origin.
origin must be the block that triggered the spread (the block passed to
get_spread()), matching vanilla’s new FlowingFluid.SpreadContext(level, blockPos).
Sourcefn encode_key(&self, pos: BlockPos) -> i16
fn encode_key(&self, pos: BlockPos) -> i16
Encodes a world position into a short cache key relative to the spread origin.
Sourcepub fn get_block_state(&mut self, pos: BlockPos) -> BlockStateId
pub fn get_block_state(&mut self, pos: BlockPos) -> BlockStateId
Gets the cached block state at the given position, querying the world if not cached.
Sourcepub fn cache_block_state(&mut self, pos: BlockPos, state: BlockStateId)
pub fn cache_block_state(&mut self, pos: BlockPos, state: BlockStateId)
Seeds a state already read by the outer spread calculation.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for SpreadContext<'a>
impl<'a> !UnwindSafe for SpreadContext<'a>
impl<'a> Freeze for SpreadContext<'a>
impl<'a> Send for SpreadContext<'a>
impl<'a> Sync for SpreadContext<'a>
impl<'a> Unpin for SpreadContext<'a>
impl<'a> UnsafeUnpin for SpreadContext<'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<>>