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

Workaround for unreliable world load / unload events, possibly fixes #4 #9

Merged
merged 2 commits into from
Jun 29, 2023

Conversation

ThePixelbrain
Copy link
Contributor

As has been previously mentioned by Player on the IC2 Forums, the IC2 Energy Net breaks because of unreliable world load / unload events. If the events are wrongly ordered or missing, the IC2 Energy Net can break.

WorldData saves a static ConcurrentMap<Integer, WorldData>. Every time something world related is needed (Energy Net, Trading Market, WindSim) it is retrieved by the dimension ID. Entries on the map are removed through world unload events. If a world unload event goes missing or a world load event is executed afterwards, the old, unloaded world will still be referenced. This becomes an issue in the following scenario:

  1. World is being unloaded
  2. World Unload event fires
  3. World Load event fires, but the world is actually unloaded
  4. World is being loaded again, new World object gets created
  5. WorldData.get() is called and returns the old, dead world object.
  6. All Energy Net tiles fail to register to the Energy Net.

I added a workaround to prevent this from happening. I check if the world objects are still identical on world load. If they are not, I instantiate a new WorldData object. I also clear the map completely after a FMLServerStoppedEvent, since no worlds should exist anymore at that time.

@ThePixelbrain ThePixelbrain requested a review from Su5eD June 29, 2023 15:27
@Su5eD Su5eD linked an issue Jun 29, 2023 that may be closed by this pull request
@Su5eD Su5eD merged commit 5760730 into Su5eD:master Jun 29, 2023
@Romz24 Romz24 mentioned this pull request Aug 16, 2023
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

Successfully merging this pull request may close these issues.

[Patch Request] IC2 Cable bug
2 participants