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