Workaround for unreliable world load / unload events, possibly fixes #4 #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 staticConcurrentMap<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:WorldData.get()
is called and returns the old, dead world object.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 aFMLServerStoppedEvent
, since no worlds should exist anymore at that time.