for some reason the code within the entityDie event is not running properly. It is outputting false when checking if my entity has the projectile component. The rest of the code works as intended except for the hasComponent method. Does anyone know why this is happening and how to fix it? (file names are in comments)
// gun.js
// projectile is zl:shotgun_bullet
// zl:shotgun_bullet json file has projectile component
const bullet = player.dimension.spawnEntity(projectile, player.getHeadLocation());
bullet.getComponent("projectile").owner = player;
bullet.getComponent("projectile").shoot(player.getViewDirection());
//index.js
world.afterEvents.entityDie.subscribe(async evd => {
const target = evd.deadEntity;
const attacker = evd.damageSource.damagingEntity;
world.sendMessage(`${attacker.typeId}`); // outputs zl:shotgun_bullet
world.sendMessage(`${attacker.hasComponent("projectile")}`);
// outputting false
})