Electroblob's Wizardry

Electroblob's Wizardry

18M Downloads

ConcurrentModificationException in LightningWeb

SettingDust opened this issue ยท 5 comments

commented

Minecraft version: 1.12.2
Wizardry version: 4.2.11
Environment: Singleplayer

Issue details:

java.util.ConcurrentModificationException
    at java.util.ArrayList$SubList$1.checkForComodification(ArrayList.java:1213)
    at java.util.ArrayList$SubList$1.next(ArrayList.java:1114)
    at electroblob.wizardry.spell.LightningWeb.onEntityHit(LightningWeb.java:73)
    at electroblob.wizardry.spell.SpellRay.shootSpell(SpellRay.java:286)
    at electroblob.wizardry.spell.SpellRay.cast(SpellRay.java:165)
    at electroblob.wizardry.item.ItemScroll.cast(ItemScroll.java:177)
    at electroblob.wizardry.item.ItemScroll.onUsingTick(ItemScroll.java:151)
commented

Finally got round to looking at this, but I don't understand how this can possibly happen. Here's the bit of code where the exception happened:

List<EntityLivingBase> secondaryTargets = EntityUtils.getLivingWithinRadius(
getProperty(SECONDARY_RANGE).floatValue(), target.posX, target.posY + target.height / 2,
target.posZ, world);
secondaryTargets.remove(target);
secondaryTargets.removeIf(e -> !EntityUtils.isLiving(e));
secondaryTargets.removeIf(e -> !AllyDesignationSystem.isValidTarget(caster, e));
if(secondaryTargets.size() > getProperty(SECONDARY_MAX_TARGETS).intValue())
secondaryTargets = secondaryTargets.subList(0, getProperty(SECONDARY_MAX_TARGETS).intValue());
for(EntityLivingBase secondaryTarget : secondaryTargets){
electrocute(world, caster, target.getPositionVector().add(0, target.height/2, 0), secondaryTarget,
getProperty(SECONDARY_DAMAGE).floatValue() * modifiers.get(SpellModifiers.POTENCY), ticksInUse);
// Tertiary chaining effect
List<EntityLivingBase> tertiaryTargets = EntityUtils.getLivingWithinRadius(
getProperty(TERTIARY_RANGE).floatValue(), secondaryTarget.posX,
secondaryTarget.posY + secondaryTarget.height / 2, secondaryTarget.posZ, world);
tertiaryTargets.remove(target);
tertiaryTargets.removeAll(secondaryTargets);
tertiaryTargets.removeIf(e -> !EntityUtils.isLiving(e));
tertiaryTargets.removeIf(e -> !AllyDesignationSystem.isValidTarget(caster, e));
if(tertiaryTargets.size() > getProperty(TERTIARY_MAX_TARGETS).intValue())
tertiaryTargets = tertiaryTargets.subList(0, getProperty(TERTIARY_MAX_TARGETS).intValue());
for(EntityLivingBase tertiaryTarget : tertiaryTargets){
electrocute(world, caster, secondaryTarget.getPositionVector().add(0, secondaryTarget.height/2, 0),
tertiaryTarget, getProperty(TERTIARY_DAMAGE).floatValue() * modifiers.get(SpellModifiers.POTENCY), ticksInUse);
}

The list in question, secondaryTargets, is a list I have created, and its scope is local to that method. I'm not modifying it inside the loop at all. The tertiaryTargets list is completely separate from secondaryTargets and a fresh one is created each loop iteration. This can't be client/server related because as I said, the scope is local to that method. Same goes for other mods interfering, this is within a single method in my code only so it's nothing to do with other mods. If this was a pure Java problem, it would be happening for everyone.

What gives?

commented

Tried. Can't reproduce. Sorry T T.
Tested every mob that can be spawned by egg in vanilla and ebw.
Tested in openjdk8 232b09 & jdk8 231.

commented

Same as #567

commented

Okay, I'll take a look. Thanks.

commented

Okay, I'll take a look. Thanks.

Maybe caused by OpenJDK?