import { Vector3 } from "../../vector/vector3";

export function machineBow(player) {
    const direction = new Vector3().toVector(player.getViewDirection())
    const loc = new Vector3().toVector(player.getHeadLocation())
    
    // Spawn the arrow 2 blocks above the player's head
    const spawnLocation = new Vector3(loc.x, loc.y + 1, loc.z)

    const arrow = player.dimension.spawnEntity(`minecraft:arrow`, spawnLocation)
    arrow.setDynamicProperty("block_ha_despawn", true)

    arrow.applyImpulse(direction.multiply(1.5))
}