Pumpkin/crates/pumpkin/src/plugin/api/events/entity/projectile_hit.rs
2026-08-14 15:58:16 +02:00

31 lines
741 B
Rust

use pumpkin_macros::{Event, cancellable};
use pumpkin_util::math::vector3::Vector3;
/// An event that occurs when a projectile hits an entity or block.
#[cancellable]
#[derive(Event, Clone)]
pub struct ProjectileHitEvent {
/// The ID of the projectile entity.
pub entity_id: i32,
/// Hit position.
pub hit_position: Vector3<f64>,
/// ID of hit entity if applicable.
pub hit_entity_id: Option<i32>,
}
impl ProjectileHitEvent {
#[must_use]
pub const fn new(
entity_id: i32,
hit_position: Vector3<f64>,
hit_entity_id: Option<i32>,
) -> Self {
Self {
entity_id,
hit_position,
hit_entity_id,
cancelled: false,
}
}
}