Fixed conccurent modification exception when updating fire and inferno spells. Fixes #137, #129

This commit is contained in:
Sollace 2023-07-06 17:03:00 +01:00
parent 9d90932ce9
commit 37c62b7d0c
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -122,22 +122,18 @@ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileDele
}
protected boolean applyEntities(Caster<?> source, Vec3d pos) {
return source.findAllEntitiesInRange(Math.max(0, 3 + getTraits().get(Trait.POWER)), i -> applyEntitySingle(source, i)).count() > 0;
}
protected boolean applyEntitySingle(Caster<?> source, Entity e) {
LivingEntity master = source.getMaster();
if ((!(e.equals(source.asEntity()) || e.equals(master)) ||
(master instanceof PlayerEntity && !EquinePredicates.PLAYER_UNICORN.test(master))) && !(e instanceof ItemEntity)
&& !(e instanceof Caster<?>)) {
return source.findAllEntitiesInRange(Math.max(0, 3 + getTraits().get(Trait.POWER)), e -> {
LivingEntity master = source.getMaster();
return (!(e.equals(source.asEntity()) || e.equals(master)) ||
(master instanceof PlayerEntity && !EquinePredicates.PLAYER_UNICORN.test(master))) && !(e instanceof ItemEntity)
&& !(e instanceof Caster<?>);
}).filter(e -> {
e.setOnFireFor(60);
e.damage(getDamageCause(source, e), 0.1f);
playEffect(source.asWorld(), e.getBlockPos());
return true;
}
return false;
})
.count() > 0;
}
protected DamageSource getDamageCause(Caster<?> source, Entity target) {