Skip to main content

Projectile

Trait Projectile 

Source
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§

Source

fn projectile_base(&self) -> &ProjectileBase

Returns shared projectile runtime state.

Provided Methods§

Source

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.

Source

fn set_owner_uuid(&self, owner: Option<Uuid>)

Sets the owner UUID. Vanilla stores an EntityReference; Steel stores the UUID and resolves lazily.

Source

fn set_owner_entity(&self, owner: Option<&SharedEntity>)

Sets the owning entity and caches its live reference.

Source

fn cache_owner_entity(&self, owner: &SharedEntity)

Caches a live owner reference when it matches the saved owner UUID.

Source

fn owner_uuid(&self) -> Option<Uuid>

Returns the owner UUID, if any.

Source

fn get_owner(&self) -> Option<SharedEntity>

Resolves the owning entity in the current world (vanilla Projectile.getOwner).

Source

fn projectile_may_interact(&self, world: &World, pos: BlockPos) -> bool

Returns vanilla Projectile.mayInteract for a block position.

Source

fn may_break(&self, world: &World) -> bool

Returns vanilla Projectile.mayBreak.

Source

fn owned_by(&self, entity: &dyn Entity) -> bool

Returns vanilla Projectile.ownedBy.

Source

fn has_been_shot(&self) -> bool

Returns vanilla Projectile.hasBeenShot.

Source

fn set_has_been_shot(&self, value: bool)

Sets vanilla Projectile.hasBeenShot.

Source

fn left_owner(&self) -> bool

Returns vanilla Projectile.leftOwner.

Source

fn check_left_owner(&self)

Runs vanilla Projectile.checkLeftOwner.

Source

fn reset_left_owner_checked(&self)

Resets the per-tick left-owner check flag (vanilla clears it after tick).

Source

fn is_outside_owner_collision_range(&self) -> bool

Returns vanilla Projectile.isOutsideOwnerCollisionRange.

Source

fn can_hit_entity(&self, entity: &dyn Entity) -> bool

Returns vanilla Projectile.canHitEntity.

Source

fn get_movement_to_shoot( &self, direction: DVec3, power: f32, uncertainty: f32, ) -> DVec3

Returns vanilla Projectile.getMovementToShoot.

Source

fn shoot(&self, direction: DVec3, power: f32, uncertainty: f32)

Runs vanilla Projectile.shoot.

Source

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.

Source

fn update_rotation(&self)

Runs vanilla Projectile.updateRotation (lerped toward the movement vector).

Source

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.

Source

fn on_deflection(&self, _by_attack: bool)

Called after a successful Vanilla projectile deflection.

Source

fn should_bounce_on_world_border(&self) -> bool

Returns whether this projectile bounces from the world border.

Source

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).

Source

fn hit_target_or_deflect_self( &self, hit: &ProjectileHit, ) -> ProjectileDeflection

Vanilla Projectile.hitTargetOrDeflectSelf.

Source

fn on_hit(&self, hit: &ProjectileHit)

Vanilla Projectile.onHit. Subclasses override this and call Projectile::projectile_on_hit for the base dispatch (super.onHit()).

Source

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.

Source

fn on_hit_entity(&self, _entity: &SharedEntity, _location: DVec3)

Vanilla Projectile.onHitEntity (no-op by default).

Source

fn on_hit_block(&self, hit: &ClipHitResult)

Vanilla Projectile.onHitBlock.

Source

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.

Source

fn projectile_base_tick(&self)

Vanilla Projectile.tick (the super.tick() reached from subclasses).

Source

fn save_projectile(&self, nbt: &mut NbtCompound)

Saves vanilla Projectile fields (Owner, LeftOwner, HasBeenShot).

Source

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".

Implementors§