PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

50M Downloads

[1.15.2] java.util.ConcurrentModificationException Crash

twistedkento opened this issue ยท 12 comments

commented

Minecraft Version

1.15.2

Forge Version

31.2.43

Mod Version

1.15.2-1.5.0-73

Describe your problem, including steps to reproduce it

Pneumaticcraft-Repressurized probably makes minecraft throw an exception when spawning a skeleton horse.
Spawning the skeleton horse without pneumaticcraft-repressurized doesn't cause any crash.

How I can reproduce it:
Install a fresh forge instance with only pneumaticcraft-repressurized in it's mod folder.
Start a new game with cheat enabled and spawn a skeleton horse with a rider on it by using this command:
/summon skeleton_horse ~ ~ ~ {SkeletonTrap:1} it should crash the game.

Any other comments?

See the crash log.
crash-2020-10-07_21.49.39-server.txt

commented

Spawning one without a rider on it doesn't crash the game.

commented

Interesting. I tested this out on a 1.16.3 dev world with PNC and a bunch of other mods installed, and I got the crash you reported.

Then I went to a fresh 1.15.2 world with only PNC installed and tested again... and no crash. Worked fine.

So PNC may be involved, but the jury's out. I'll try some more tests but I've no idea why PNC would have an effect here, unless it's something to do with capability attachment (PNC does attach one capability to entities, but it does it in a very standard way via the Forge AttachCapabilitiesEvent). The stacktrace certainly doesn't give any useful clues.

commented

Just found this: https://www.minecraftforum.net/forums/support/server-support-and/3004378-crash-report-server-skeleton-horse

Same crash as you're getting (although on 1.14.4) but this user doesn't have PNC installed. I'd say this may be more of a modded problem in general (some interaction between Forge & vanilla) than anything mod-specific.

commented

Strange... I cloned the repo and build the 1.15 branch and was able to get the error. So maybe Its a racing condition or something.

I think I'm able to identify what's causing the error to occur also since when commenting out this addGoal function made the exception go away for me:
@SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (!event.getWorld().isRemote) { if (event.getEntity() instanceof MobEntity) { ((MobEntity) event.getEntity()).goalSelector.addGoal(Integer.MIN_VALUE, new EntityAINoAIWhenRidingDrone((MobEntity) event.getEntity())); } } }

commented

Bah it removed the newlines... well it's EventHandlerPneumaticCraft.java:141 on the 1.15 branch.

commented

Ah, yes - I seem to recall adding goals to ridden entity can cause problems (in a hard to reproduce way). Thanks for spotting that. That goal is necessary though, since without it drones can't pick up entities and carry them around (the carried entity's AI messes up the drone's AI).

Should hopefully be possible to work around by not adding the goal to skeleton horses, but I'll do some testing...

commented

I see what's happening. Skeleton horseman are triggered by player proximity, and the trigger is itself an entity goal - TriggerSkeletonTrapGoal. So the entity spawn event ends up adding a goal from within an executing goal... that explains the CME quite nicely.

commented

Ah yeah that sounds pretty logical.
I just did a hack instead of digging for answers if (event.getEntity() instanceof MobEntity && !(event.getEntity() instanceof SkeletonHorseEntity && ((SkeletonHorseEntity)event.getEntity()).isTrap())) :)

commented

Yeah I found that too. But a better way is to defer the goal addition until the end of this server tick (a bit more coding but I think I have something that works...)

commented

OK, with the added change I can't make it crash at all, but would appreciate if you could test it too, with build 77 from https://jenkins.k-4u.nl/job/PneumaticCraft-Repressurized-1.15/

commented

Yeah that seems to work fine. A simple but elegant solution. ๐Ÿ‘

commented

Fixed in 1.5.1 release