Alex's Mobs

Alex's Mobs

72M Downloads

Dispenser behaviors are being registered off-thread, causing race-condition crashes with other mods

Commoble opened this issue ยท 0 comments

commented

AMItemRegistry registers dispenser behaviors in common setup, which runs off-thread

https://github.com/Alex-the-666/AlexsMobs/blob/1.19/src/main/java/com/github/alexthe666/alexsmobs/AlexsMobs.java#L165
https://github.com/Alex-the-666/AlexsMobs/blob/1.19/src/main/java/com/github/alexthe666/alexsmobs/item/AMItemRegistry.java#L294

The dispenser behavior map isn't threadsafe, so adding things to this map off-thread can rarely and randomly cause crashes during startup if two or more mods are both doing this, such as in the following crashlog

https://gist.github.com/Commoble/5c8d6fdc13a7eb1cba6800b32d537ee6

This can be averted by registering dispenser behaviors during FMLCommonSetupEvent#enqueueWork, which runs on the main thread