From 37c62b7d0c3b7ddea8fc5a488a6861ca187e11f1 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 6 Jul 2023 17:03:00 +0100 Subject: [PATCH] Fixed conccurent modification exception when updating fire and inferno spells. Fixes #137, #129 --- .../ability/magic/spell/effect/FireSpell.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java index cdb75bd4..e3675153 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java @@ -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) {