Skip to main content

ExplosionDamageCalculator

Trait ExplosionDamageCalculator 

Source
pub trait ExplosionDamageCalculator: Send + Sync {
    // Provided methods
    fn block_explosion_resistance(
        &self,
        _explosion: &dyn Explosion,
        _world: &World,
        _pos: BlockPos,
        state: BlockStateId,
        fluid: FluidState,
    ) -> Option<f32> { ... }
    fn should_block_explode(
        &self,
        _explosion: &dyn Explosion,
        _world: &World,
        _pos: BlockPos,
        _state: BlockStateId,
        _power: f32,
    ) -> bool { ... }
    fn should_damage_entity(
        &self,
        _explosion: &dyn Explosion,
        _entity: &dyn Entity,
    ) -> bool { ... }
    fn knockback_multiplier(&self, _entity: &dyn Entity) -> f32 { ... }
    fn entity_damage_amount(
        &self,
        explosion: &dyn Explosion,
        entity: &dyn Entity,
        exposure: f32,
    ) -> f32 { ... }
}
Expand description

Customizable Vanilla explosion resistance, damage, and knockback policy.

Provided Methods§

Source

fn block_explosion_resistance( &self, _explosion: &dyn Explosion, _world: &World, _pos: BlockPos, state: BlockStateId, fluid: FluidState, ) -> Option<f32>

Returns the effective resistance at an affected block position.

Source

fn should_block_explode( &self, _explosion: &dyn Explosion, _world: &World, _pos: BlockPos, _state: BlockStateId, _power: f32, ) -> bool

Returns whether the current ray may affect this block position.

Source

fn should_damage_entity( &self, _explosion: &dyn Explosion, _entity: &dyn Entity, ) -> bool

Returns whether the explosion damages this entity.

Source

fn knockback_multiplier(&self, _entity: &dyn Entity) -> f32

Returns the multiplier applied to this entity’s explosion knockback.

Source

fn entity_damage_amount( &self, explosion: &dyn Explosion, entity: &dyn Entity, exposure: f32, ) -> f32

Calculates Vanilla explosion damage for one entity and exposure value.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§