Skip to main content

spawn_throwable_item_projectile

Function spawn_throwable_item_projectile 

Source
pub fn spawn_throwable_item_projectile<E>(
    world: &Arc<World>,
    player: &Player,
    item_stack: &mut ItemStack,
    power: f32,
    uncertainty: f32,
    create: impl FnOnce(DVec3) -> E,
) -> Option<SharedEntity>
where E: Projectile + ThrowableItemProjectile + Entity + 'static,
Expand description

Spawns a throwable-item projectile from the source’s eye along its look direction and registers it in the world.

Mirrors vanilla Projectile.spawnProjectileFromRotation + spawnProjectile: create the projectile at the eye minus 0.1, set its owner, shoot it with shootFromRotation, add it to the world, then run applyOnProjectileSpawned (the minecraft:projectile_spawned enchantment effects). create receives the spawn position and must return the concrete projectile type. Returns None when the world rejects the projectile so the caller can fail the use.