I want the entity that causes damage to receive the status effect, not the entity that is hit. After replacing hitEntity with damagingEntity , it doesn't work. What should I do?
if (Math.random() < 0.3) {
data.hitEntity.runCommandAsync("execute as @s at @s run summon minecraft:lightning_bolt ~ ~ ~");
}
if (Math.random() < 0.25) {
data.damagingEntity.addEffect('resistance',20, 4);
}
data.hitEntity.applyKnockback(data.damagingEntity.getViewDirection().x, data.damagingEntity.getViewDirection().z, 0.3, 0.3,)
data.damagingEntity.addEffect('regeneration',20, 3)
}```