Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ChiefArug opened this issue Jan 18, 2025 · 0 comments

Comments

@ChiefArug
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant