Skip to main content

MobEffectBehavior

Trait MobEffectBehavior 

Source
pub trait MobEffectBehavior: Send + Sync {
    // Provided methods
    fn as_instantaneous(&self) -> Option<&dyn InstantaneousMobEffect> { ... }
    fn should_apply_effect_tick_this_tick(
        &self,
        tick_count: i32,
        _amplifier: i32,
    ) -> bool { ... }
    fn apply_effect_tick(
        &self,
        _world: &World,
        _user: &dyn LivingEntity,
        _amplifier: i32,
    ) -> bool { ... }
    fn on_effect_started(&self, _user: &dyn LivingEntity, _amplifier: i32) { ... }
}
Expand description

One vanilla MobEffect subtype’s runtime behavior. Default methods match vanilla’s own MobEffect base-class defaults, so an effect with no registered behavior (most of them) behaves exactly like a bare vanilla MobEffect instance.

Provided Methods§

Source

fn as_instantaneous(&self) -> Option<&dyn InstantaneousMobEffect>

Returns the instantaneous-only half of this behavior, if any.

Source

fn should_apply_effect_tick_this_tick( &self, tick_count: i32, _amplifier: i32, ) -> bool

Mirrors vanilla MobEffect.shouldApplyEffectTickThisTick.

Source

fn apply_effect_tick( &self, _world: &World, _user: &dyn LivingEntity, _amplifier: i32, ) -> bool

Mirrors vanilla MobEffect.applyEffectTick. Returns whether the effect remains active.

Source

fn on_effect_started(&self, _user: &dyn LivingEntity, _amplifier: i32)

Mirrors vanilla MobEffect.onEffectStarted.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§