Skip to main content

SurfaceRuleContext

Struct SurfaceRuleContext 

Source
pub struct SurfaceRuleContext<'a> {
Show 16 fields pub block_x: i32, pub block_z: i32, pub surface_depth: i32, pub surface_secondary: f64, pub min_surface_level: i32, pub steep: bool, pub block_y: i32, pub stone_depth_above: i32, pub stone_depth_below: i32, pub water_height: i32, biome_id: Option<u16>, biome_provider: Option<&'a mut dyn SurfaceBiomeProvider>, pub system: &'a dyn SurfaceNoiseProvider, condition_noises: &'a SurfaceConditionNoiseCache<'a>, block_states: &'a [BlockStateId], cold_enough_to_snow: Option<bool>,
}
Expand description

Context data passed to transpiled surface rule functions.

This is a flat struct holding all the values a surface rule condition might need. The SurfaceContext in steel-core populates this and passes it to the generated try_apply_surface_rule() function.

Fields§

§block_x: i32

World X coordinate.

§block_z: i32

World Z coordinate.

§surface_depth: i32

Noise-based surface layer thickness (typically 3-6 blocks).

§surface_secondary: f64

Surface secondary noise value for depth variation.

§min_surface_level: i32

Minimum surface level from preliminary surface interpolation.

§steep: bool

Whether this column has a steep slope.

§block_y: i32

World Y coordinate.

§stone_depth_above: i32

How many solid blocks above the current position.

§stone_depth_below: i32

How many solid blocks below until the next cavity.

§water_height: i32

Y of water surface above this block, or i32::MIN if no water.

§biome_id: Option<u16>

Cached numeric biome ID at the current position, if already known.

§biome_provider: Option<&'a mut dyn SurfaceBiomeProvider>

Lazy biome lookup for rules that need the biome at this Y position.

§system: &'a dyn SurfaceNoiseProvider

Reference to the surface system for noise lookups and band generation.

§condition_noises: &'a SurfaceConditionNoiseCache<'a>

Lazily populated column cache for surface condition noise values.

§block_states: &'a [BlockStateId]

Pre-resolved block states returned by generated surface rules.

§cold_enough_to_snow: Option<bool>

Lazily computed temperature condition value.

Implementations§

Source§

impl<'a> SurfaceRuleContext<'a>

Source

pub fn new( block_x: i32, block_z: i32, surface_depth: i32, surface_secondary: f64, min_surface_level: i32, steep: bool, block_y: i32, stone_depth_above: i32, stone_depth_below: i32, water_height: i32, biome_id: Option<u16>, biome_provider: Option<&'a mut dyn SurfaceBiomeProvider>, system: &'a dyn SurfaceNoiseProvider, condition_noises: &'a SurfaceConditionNoiseCache<'a>, block_states: &'a [BlockStateId], ) -> Self

Creates a surface rule context for one block position.

Source

pub fn condition_noise(&self, noise_index: usize) -> f64

Returns a column-cached surface condition noise value.

Source

pub fn condition_noise_3d(&self, noise_index: usize) -> f64

Returns an uncached surface condition noise value sampled at this block.

Source

pub const fn block_state(&self, block_state_index: usize) -> BlockStateId

Returns a pre-resolved block state emitted by the generated surface rule.

Source

pub const fn known_biome_id(&self) -> Option<u16>

Returns a biome ID already supplied by the caller.

Source

pub fn biome_id(&mut self) -> Option<u16>

Returns the current biome ID if this context was built with one.

Source

pub fn cold_enough_to_snow(&mut self) -> bool

Lazily evaluates the vanilla temperature surface condition.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for SurfaceRuleContext<'a>

§

impl<'a> !Send for SurfaceRuleContext<'a>

§

impl<'a> !Sync for SurfaceRuleContext<'a>

§

impl<'a> !UnwindSafe for SurfaceRuleContext<'a>

§

impl<'a> Freeze for SurfaceRuleContext<'a>

§

impl<'a> Unpin for SurfaceRuleContext<'a>

§

impl<'a> UnsafeUnpin for SurfaceRuleContext<'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> 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
§

impl<T> IntoShared for T

§

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