Adorn

Adorn

11M Downloads

Potential CME on (Neo)Forge due to registering game rules in common setup event

ChiefArug opened this issue ยท 0 comments

commented

In the common setup event you make a call to your game rule class to register them:

private void init(FMLCommonSetupEvent event) {
AdornGameRules.init();

This has the potential to cause a Concurrent Modification Exception because the common setup event runs in parallel for multiple mods at the same time and 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 that it is enqueued in that event to run on the main thread using the enqueueWork method.