pub trait Projectile: Entity + ProjectileEventSource {
Show 34 methods
// Required method
fn projectile_base(&self) -> &ProjectileBase;
// Provided methods
fn calculate_horizontal_hurt_knockback_direction(
&self,
_hurt_entity: &dyn LivingEntity,
_damage_source: &DamageSource,
) -> (f64, f64) { ... }
fn set_owner_uuid(&self, owner: Option<Uuid>) { ... }
fn set_owner_entity(&self, owner: Option<&SharedEntity>) { ... }
fn cache_owner_entity(&self, owner: &SharedEntity) { ... }
fn owner_uuid(&self) -> Option<Uuid> { ... }
fn get_owner(&self) -> Option<SharedEntity> { ... }
fn projectile_may_interact(&self, world: &World, pos: BlockPos) -> bool { ... }
fn may_break(&self, world: &World) -> bool { ... }
fn owned_by(&self, entity: &dyn Entity) -> bool { ... }
fn has_been_shot(&self) -> bool { ... }
fn set_has_been_shot(&self, value: bool) { ... }
fn left_owner(&self) -> bool { ... }
fn check_left_owner(&self) { ... }
fn reset_left_owner_checked(&self) { ... }
fn is_outside_owner_collision_range(&self) -> bool { ... }
fn can_hit_entity(&self, entity: &dyn Entity) -> bool { ... }
fn get_movement_to_shoot(
&self,
direction: DVec3,
power: f32,
uncertainty: f32,
) -> DVec3 { ... }
fn shoot(&self, direction: DVec3, power: f32, uncertainty: f32) { ... }
fn shoot_from_rotation(
&self,
source: &dyn Entity,
x_rot: f32,
y_rot: f32,
y_offset: f32,
power: f32,
uncertainty: f32,
) { ... }
fn update_rotation(&self) { ... }
fn deflect(
&self,
deflection: ProjectileDeflection,
deflecting_entity: Option<&dyn Entity>,
new_owner_uuid: Option<Uuid>,
new_owner_entity: Option<&SharedEntity>,
by_attack: bool,
) -> bool { ... }
fn on_deflection(&self, _by_attack: bool) { ... }
fn should_bounce_on_world_border(&self) -> bool { ... }
fn get_hit_result_on_move_vector(&self) -> Option<ProjectileHit> { ... }
fn hit_target_or_deflect_self(
&self,
hit: &ProjectileHit,
) -> ProjectileDeflection { ... }
fn on_hit(&self, hit: &ProjectileHit) { ... }
fn projectile_on_hit(&self, hit: &ProjectileHit) { ... }
fn on_hit_entity(&self, _entity: &SharedEntity, _location: DVec3) { ... }
fn on_hit_block(&self, hit: &ClipHitResult) { ... }
fn projectile_on_hit_block(&self, hit: &ClipHitResult) { ... }
fn projectile_base_tick(&self) { ... }
fn save_projectile(&self, nbt: &mut NbtCompound) { ... }
fn load_projectile(&self, nbt: BorrowedNbtCompoundView<'_, '_>) { ... }
}Expand description
Vanilla-shaped behavior shared by entities that extend Projectile.
Required Methods§
Sourcefn projectile_base(&self) -> &ProjectileBase
fn projectile_base(&self) -> &ProjectileBase
Returns shared projectile runtime state.
Provided Methods§
Sourcefn calculate_horizontal_hurt_knockback_direction(
&self,
_hurt_entity: &dyn LivingEntity,
_damage_source: &DamageSource,
) -> (f64, f64)
fn calculate_horizontal_hurt_knockback_direction( &self, _hurt_entity: &dyn LivingEntity, _damage_source: &DamageSource, ) -> (f64, f64)
Returns the horizontal hurt-knockback vector used for this projectile.
Sourcefn set_owner_uuid(&self, owner: Option<Uuid>)
fn set_owner_uuid(&self, owner: Option<Uuid>)
Sets the owner UUID. Vanilla stores an EntityReference; Steel stores the
UUID and resolves lazily.
Sourcefn set_owner_entity(&self, owner: Option<&SharedEntity>)
fn set_owner_entity(&self, owner: Option<&SharedEntity>)
Sets the owning entity and caches its live reference.
Sourcefn cache_owner_entity(&self, owner: &SharedEntity)
fn cache_owner_entity(&self, owner: &SharedEntity)
Caches a live owner reference when it matches the saved owner UUID.
Sourcefn owner_uuid(&self) -> Option<Uuid>
fn owner_uuid(&self) -> Option<Uuid>
Returns the owner UUID, if any.
Sourcefn get_owner(&self) -> Option<SharedEntity>
fn get_owner(&self) -> Option<SharedEntity>
Resolves the owning entity in the current world (vanilla Projectile.getOwner).
Sourcefn projectile_may_interact(&self, world: &World, pos: BlockPos) -> bool
fn projectile_may_interact(&self, world: &World, pos: BlockPos) -> bool
Returns vanilla Projectile.mayInteract for a block position.
Sourcefn has_been_shot(&self) -> bool
fn has_been_shot(&self) -> bool
Returns vanilla Projectile.hasBeenShot.
Sourcefn set_has_been_shot(&self, value: bool)
fn set_has_been_shot(&self, value: bool)
Sets vanilla Projectile.hasBeenShot.
Sourcefn left_owner(&self) -> bool
fn left_owner(&self) -> bool
Returns vanilla Projectile.leftOwner.
Sourcefn check_left_owner(&self)
fn check_left_owner(&self)
Runs vanilla Projectile.checkLeftOwner.
Sourcefn reset_left_owner_checked(&self)
fn reset_left_owner_checked(&self)
Resets the per-tick left-owner check flag (vanilla clears it after tick).
Sourcefn is_outside_owner_collision_range(&self) -> bool
fn is_outside_owner_collision_range(&self) -> bool
Returns vanilla Projectile.isOutsideOwnerCollisionRange.
Sourcefn can_hit_entity(&self, entity: &dyn Entity) -> bool
fn can_hit_entity(&self, entity: &dyn Entity) -> bool
Returns vanilla Projectile.canHitEntity.
Sourcefn get_movement_to_shoot(
&self,
direction: DVec3,
power: f32,
uncertainty: f32,
) -> DVec3
fn get_movement_to_shoot( &self, direction: DVec3, power: f32, uncertainty: f32, ) -> DVec3
Returns vanilla Projectile.getMovementToShoot.
Sourcefn shoot_from_rotation(
&self,
source: &dyn Entity,
x_rot: f32,
y_rot: f32,
y_offset: f32,
power: f32,
uncertainty: f32,
)
fn shoot_from_rotation( &self, source: &dyn Entity, x_rot: f32, y_rot: f32, y_offset: f32, power: f32, uncertainty: f32, )
Runs vanilla Projectile.shootFromRotation.
Sourcefn update_rotation(&self)
fn update_rotation(&self)
Runs vanilla Projectile.updateRotation (lerped toward the movement vector).
Sourcefn deflect(
&self,
deflection: ProjectileDeflection,
deflecting_entity: Option<&dyn Entity>,
new_owner_uuid: Option<Uuid>,
new_owner_entity: Option<&SharedEntity>,
by_attack: bool,
) -> bool
fn deflect( &self, deflection: ProjectileDeflection, deflecting_entity: Option<&dyn Entity>, new_owner_uuid: Option<Uuid>, new_owner_entity: Option<&SharedEntity>, by_attack: bool, ) -> bool
Applies a Vanilla projectile deflection.
Sourcefn on_deflection(&self, _by_attack: bool)
fn on_deflection(&self, _by_attack: bool)
Called after a successful Vanilla projectile deflection.
Sourcefn should_bounce_on_world_border(&self) -> bool
fn should_bounce_on_world_border(&self) -> bool
Returns whether this projectile bounces from the world border.
Sourcefn get_hit_result_on_move_vector(&self) -> Option<ProjectileHit>
fn get_hit_result_on_move_vector(&self) -> Option<ProjectileHit>
Casts the move vector and returns the nearest block/entity hit (vanilla
ProjectileUtil.getHitResultOnMoveVector with this::canHitEntity).
Sourcefn hit_target_or_deflect_self(
&self,
hit: &ProjectileHit,
) -> ProjectileDeflection
fn hit_target_or_deflect_self( &self, hit: &ProjectileHit, ) -> ProjectileDeflection
Vanilla Projectile.hitTargetOrDeflectSelf.
Sourcefn on_hit(&self, hit: &ProjectileHit)
fn on_hit(&self, hit: &ProjectileHit)
Vanilla Projectile.onHit. Subclasses override this and call
Projectile::projectile_on_hit for the base dispatch (super.onHit()).
Sourcefn projectile_on_hit(&self, hit: &ProjectileHit)
fn projectile_on_hit(&self, hit: &ProjectileHit)
The base Projectile.onHit dispatch to block/entity handlers. Not meant to
be overridden — override Projectile::on_hit and delegate here instead.
Sourcefn on_hit_entity(&self, _entity: &SharedEntity, _location: DVec3)
fn on_hit_entity(&self, _entity: &SharedEntity, _location: DVec3)
Vanilla Projectile.onHitEntity (no-op by default).
Sourcefn on_hit_block(&self, hit: &ClipHitResult)
fn on_hit_block(&self, hit: &ClipHitResult)
Vanilla Projectile.onHitBlock.
Sourcefn projectile_on_hit_block(&self, hit: &ClipHitResult)
fn projectile_on_hit_block(&self, hit: &ClipHitResult)
The base Projectile.onHitBlock implementation. Concrete projectiles
that override the hook call this to preserve the Java super dispatch.
Sourcefn projectile_base_tick(&self)
fn projectile_base_tick(&self)
Vanilla Projectile.tick (the super.tick() reached from subclasses).
Sourcefn save_projectile(&self, nbt: &mut NbtCompound)
fn save_projectile(&self, nbt: &mut NbtCompound)
Saves vanilla Projectile fields (Owner, LeftOwner, HasBeenShot).
Sourcefn load_projectile(&self, nbt: BorrowedNbtCompoundView<'_, '_>)
fn load_projectile(&self, nbt: BorrowedNbtCompoundView<'_, '_>)
Loads vanilla Projectile fields.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".