import { world, Player } from "@minecraft/server";

world.afterEvents.projectileHitEntity.subscribe((data) => {
    const { projectile, source: player } = data;
    if (!(player instanceof Player)) return;
    const health = data.getEntityHit().entity?.getComponent('health');
    const bullet = Indoarsenal.bullets[projectile.typeId.replace("bullet:", "")];
    health.setCurrentValue(health.currentValue - bullet.damage);
});