Skip to main content

ImmutableExplosionBlockCalculator

Trait ImmutableExplosionBlockCalculator 

Source
pub(crate) trait ImmutableExplosionBlockCalculator: Send + Sync {
    // Provided methods
    fn bounded_block_read_radius(&self) -> Option<u32> { ... }
    fn can_cache_explosion_resistance(&self) -> bool { ... }
    fn always_allows_block_explosion(&self) -> bool { ... }
    fn explosion_resistance(
        &self,
        _reader: &dyn ExplosionBlockReader,
        _pos: BlockPos,
        state: BlockStateId,
        fluid: FluidState,
    ) -> Option<f32> { ... }
    fn should_explode(
        &self,
        _reader: &dyn ExplosionBlockReader,
        _pos: BlockPos,
        _state: BlockStateId,
        _power: f32,
    ) -> bool { ... }
}
Expand description

Opt-in capability for calculators whose block-ray decisions are pure.

This trait is crate-private so public custom calculators continue through the sequential compatibility lane unless Steel can prove their implementation is immutable. Implementations may only inspect block states through ExplosionBlockReader.

Provided Methods§

Source

fn bounded_block_read_radius(&self) -> Option<u32>

Returns the greatest per-axis block offset (Chebyshev radius) this calculator reads from each ray position. Implementations opting in must never increase ray power through a returned resistance.

Opting in permits one bounded, stable world view for the ray phase. Every reader access made by Self::explosion_resistance and Self::should_explode must remain within this distance. Returning None retains the live-world compatibility path.

Source

fn can_cache_explosion_resistance(&self) -> bool

Whether repeated resistance queries for an unchanged position may reuse one result.

A bounded reader guarantees stable block states during ray traversal. An implementation must still opt in because the compatibility contract permits calculators to observe how often this method runs. Live-world fallback traversal does not cache reads or resistance.

Source

fn always_allows_block_explosion(&self) -> bool

Whether Self::should_explode unconditionally returns true without side effects.

This permits the immutable ray lane to omit the virtual callback and repeated affected-set probes for positions that have already been accepted. Calculators must retain the default unless every state and remaining-power value is allowed.

Source

fn explosion_resistance( &self, _reader: &dyn ExplosionBlockReader, _pos: BlockPos, state: BlockStateId, fluid: FluidState, ) -> Option<f32>

Returns the effective resistance at a ray position.

Source

fn should_explode( &self, _reader: &dyn ExplosionBlockReader, _pos: BlockPos, _state: BlockStateId, _power: f32, ) -> bool

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§