Potential CME due to registering game rules in mod construction
ChiefArug opened this issue ยท 3 comments
I am not using performance mods.
- Confirm
Description
In your mod constructor you make a call to your game rule class to register them:
This has the potential to cause a Concurrent Modification Exception because GameRules#register adds an entry to a non threadsafe map. Issues caused by this would be very hard to reproduce and hard to pin the blame on the cause (as only one modifier shows up in the stacktrace).
You should instead ensure the register method is called from the main thread by enqueuing it in the common setup event.
Mod Version
Forge Version
N/A
Link to Crash Log
N/A
Screenshot (if available)
N/A
How to reproduce
Not easily
This does not solve it. The common setup event is still executed in parallel, you need to use event.enqueueWork to enqueue it to run on the main thread.
@robotgryphon not sure if you saw my above comment, the fix implemented does not solve it because the common setup event also runs in parallel. You need to use event.enqueWork to submit work to be done on the main thread.