Skip to main content

Aquifer

Struct Aquifer 

Source
pub struct Aquifer<N: DimensionNoises> {
Show 18 fields location_cache: Vec<i64>, status_cache: Vec<Option<FluidStatus>>, splitter: RandomSplitter, cache: N::ColumnCache, min_grid_x: i32, min_grid_y: i32, min_grid_z: i32, grid_size_x: i32, grid_size_z: i32, skip_sampling_above_y: i32, sea_level: i32, lava_floor: i32, water_id: BlockStateId, lava_id: BlockStateId, default_fluid_id: BlockStateId, should_schedule_fluid_update: bool, col_cache: AquiferColumnCache, preliminary_surface: Arc<PreliminarySurfaceStore>,
}
Expand description

Noise-based aquifer for a single chunk.

Constructed once per chunk, used throughout the fill loop.

Fields§

§location_cache: Vec<i64>

Packed (x, y, z) locations of aquifer cell centers. i64::MAX = not yet computed.

§status_cache: Vec<Option<FluidStatus>>

Lazily computed fluid statuses per grid cell.

§splitter: RandomSplitter

Positional random for grid cell jitter.

§cache: N::ColumnCache

Column cache owned by the aquifer for density function evaluation.

§min_grid_x: i32

Grid bounds.

§min_grid_y: i32§min_grid_z: i32§grid_size_x: i32§grid_size_z: i32§skip_sampling_above_y: i32

Skip aquifer sampling above this Y (optimization).

§sea_level: i32

Sea level for this dimension.

§lava_floor: i32

Precomputed min(LAVA_LEVEL, sea_level). Hoisted out of global_fluid (which is on the per-block hot path) so we don’t recompute it millions of times per chunk.

§water_id: BlockStateId

Block state IDs.

§lava_id: BlockStateId§default_fluid_id: BlockStateId

The dimension’s default fluid (water for overworld, lava for nether).

§should_schedule_fluid_update: bool

Vanilla’s shouldScheduleFluidUpdate flag from the most recent substance lookup.

§col_cache: AquiferColumnCache

12-cell neighborhood snapshot for the current Y-column. Placed at the end so dimensions with disabled aquifers (nether/end) keep the hot fluid-id fields earlier in the struct’s cache lines.

§preliminary_surface: Arc<PreliminarySurfaceStore>

Generator-wide memo of preliminary_surface_level, replacing vanilla’s per-aquifer Long2IntMap: compute_fluid samples 13 columns per cell and the constructor scans ~121, mostly shared with neighboring chunks.

Implementations§

Source§

impl<N: DimensionNoises> Aquifer<N>

Source

pub fn new( chunk_min_x: i32, chunk_min_z: i32, min_block_y: i32, y_block_size: i32, splitter: &RandomSplitter, noises: &N, preliminary_surface: &Arc<PreliminarySurfaceStore>, cache: N::ColumnCache, ) -> Self

Create an aquifer for a full 16×16 chunk.

chunk_min_x/z are the block coordinates of the chunk’s NW corner. min_block_y and y_block_size define the vertical range. splitter is the seed’s positional splitter. cache should be a pre-initialized column cache for this chunk (avoids a redundant init_grid call).

Source

pub fn new_sized( chunk_min_x: i32, chunk_min_z: i32, width_x: i32, width_z: i32, min_block_y: i32, y_block_size: i32, splitter: &RandomSplitter, noises: &N, preliminary_surface: &Arc<PreliminarySurfaceStore>, cache: N::ColumnCache, ) -> Self

Create an aquifer with custom XZ extent (in blocks). Vanilla’s iterateNoiseColumn uses width=cellWidth (4) for single-column queries.

Source

fn max_preliminary_surface_level( noises: &N, cache: &mut N::ColumnCache, preliminary_surface: &PreliminarySurfaceStore, min_x: i32, min_z: i32, max_x: i32, max_z: i32, ) -> i32

Source

const fn get_index(&self, gx: i32, gy: i32, gz: i32) -> usize

Source

fn uniform_cell_status(&mut self, noises: &N) -> Option<FluidStatus>

shared status if every cached neighbor agrees

Source

fn is_water_over_global_lava( &self, fluid_at: Option<BlockStateId>, world_y: i32, ) -> bool

Whether fluid_at is water directly above the global lava sea.

Source

fn refill_col_cache(&mut self, world_x: i32, world_y: i32, world_z: i32) -> i32

refill in x/y/z order to keep nearest-cell ties unchanged

Source

pub fn compute_substance( &mut self, noises: &N, world_x: i32, world_y: i32, world_z: i32, density: f64, ) -> AquiferResult

Compute what block to place at this position given the interpolated density.

Source

fn compute_substance_sampled( &mut self, noises: &N, world_x: i32, world_y: i32, world_z: i32, density: f64, ) -> AquiferResult

nearest cells and barriers; the column cache must be current

Source

pub fn unsampled_air_min_y(&self) -> i32

first y where every non-positive density gives air without sampling safe to skip: only the fluid-update flag changes, and each call resets it

Source

pub const fn should_schedule_fluid_update(&self) -> bool

Returns whether the most recent substance lookup needs postprocessing for placed fluids.

Source

pub fn preliminary_surface_level(&mut self, noises: &N, x: i32, z: i32) -> i32

Returns the quart-quantized preliminary surface level, reusing this aquifer’s density-column cache and the generator-wide result store.

Source

fn get_aquifer_status(&mut self, index: usize, noises: &N) -> FluidStatus

Get or compute the fluid status for the aquifer cell at the given cache index.

Source

fn compute_fluid(&mut self, x: i32, y: i32, z: i32, noises: &N) -> FluidStatus

Compute the fluid status for an aquifer cell centered at (x, y, z).

Source

fn compute_surface_level( &mut self, x: i32, y: i32, z: i32, noises: &N, gf: FluidStatus, lowest_surface: i32, surface_under_global: bool, ) -> i32

Source

fn compute_randomized_fluid_surface_level( &mut self, x: i32, y: i32, z: i32, noises: &N, lowest_surface: i32, ) -> i32

Source

fn compute_fluid_type( &mut self, x: i32, y: i32, z: i32, noises: &N, gf: FluidStatus, fluid_level: i32, ) -> BlockStateId

Source

fn calculate_pressure( &mut self, noises: &N, x: i32, y: i32, z: i32, barrier_noise: &mut f64, s1: FluidStatus, s2: FluidStatus, ) -> f64

Calculate barrier pressure between two aquifer cells.

Matches vanilla’s check: if lava meets water at this Y, return max pressure.

Auto Trait Implementations§

§

impl<N> Freeze for Aquifer<N>

§

impl<N> RefUnwindSafe for Aquifer<N>

§

impl<N> Send for Aquifer<N>

§

impl<N> Sync for Aquifer<N>

§

impl<N> Unpin for Aquifer<N>

§

impl<N> UnsafeUnpin for Aquifer<N>

§

impl<N> UnwindSafe for Aquifer<N>

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
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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