let dmgnum = 0;
world.afterEvents.entityHurt.subscribe(({damage, damageSource, hurtEntity}) => {
const player = damageSource.damagingEntity;
const hitbox = hurtEntity;
if (hitbox.typeId == "dungeonscombat:hitbox" && player.typeId == "minecraft:player" && damageSource.cause == EntityDamageCause.entityAttack ) {
dmgnum = damage;
let nearbyEntities = player.dimension.getEntities({
maxDistance: 4,
closest: 1,
excludeTypes: ['player', 'item', 'xp_orb'],
excludeFamilies: ['dchitbox', 'dchitboxride'],
location: player.location
});
for (const entity of nearbyEntities) {
entity.applyDamage(dmgnum,{cause: EntityDamageCause.entityAttack, damagingEntity: player});
}
world.sendMessage(`damage is ${dmgnum}`);
}
});
the code checks the damage done to dummy entity by the player, and then it applies damage to nearby closest mob with the same damage done to the dummy entity
but theres a limit where dummy entity gets into iframes on hit, making applyDamage to run inconsistently because the code runs if the dummy entity is damaged
using entityHitEntity event partially works but it doesnt track the number of damage done reliably since entityHurt fires only when the entity gets damaged
is there any workaround for this?
