Skip to main content

AbstractThrownPotion

Trait AbstractThrownPotion 

Source
pub trait AbstractThrownPotion: ThrowableItemProjectile {
    // Required method
    fn on_hit_as_potion(
        self: &Arc<Self>,
        world: &Arc<World>,
        potion_item: &ItemStack,
        hit: &ProjectileHit,
    );

    // Provided methods
    fn thrown_potion_default_gravity(&self) -> f64 { ... }
    fn thrown_potion_knockback_direction(
        &self,
        hurt_entity: &dyn LivingEntity,
    ) -> (f64, f64) { ... }
    fn thrown_potion_on_hit(self: Arc<Self>, hit: &ProjectileHit)
       where Self: Sized + 'static { ... }
    fn affect_entities_around(
        self: &Arc<Self>,
        world: &Arc<World>,
        contents: &PotionContents,
    )
       where Self: Sized + 'static { ... }
    fn thrown_potion_on_hit_block(&self, hit: &ClipHitResult) { ... }
    fn douse_fire(&self, world: &Arc<World>, pos: BlockPos) { ... }
}
Expand description

Shared behavior for splash and lingering potion projectiles

Required Methods§

Source

fn on_hit_as_potion( self: &Arc<Self>, world: &Arc<World>, potion_item: &ItemStack, hit: &ProjectileHit, )

The effect-specific area-of-effect (splash) or cloud-spawning (lingering) behavior.

Provided Methods§

Source

fn thrown_potion_default_gravity(&self) -> f64

Returns the gravity of thrown potions (default is 0.05)

Source

fn thrown_potion_knockback_direction( &self, hurt_entity: &dyn LivingEntity, ) -> (f64, f64)

Returns the horizontal direction from the potion to the hurt entity

Source

fn thrown_potion_on_hit(self: Arc<Self>, hit: &ProjectileHit)
where Self: Sized + 'static,

Handles impact effects emits the break event and discards the potion

Source

fn affect_entities_around( self: &Arc<Self>, world: &Arc<World>, contents: &PotionContents, )
where Self: Sized + 'static,

Hurts water-sensitive entities in range and extinguishes burning ones, as allowed by the potion’s tags.

Source

fn thrown_potion_on_hit_block(&self, hit: &ClipHitResult)

Handles block impact and douses nearby fire for DOUSES_FIRE potions.

Source

fn douse_fire(&self, world: &Arc<World>, pos: BlockPos)

Puts out fire, lit campfires and lit candles at pos.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§