TeamGalacticraft / Galacticraft

The classic space mod, rewritten for modern versions of Minecraft.
MIT License
416 stars 83 forks source link

fix: Prevent infinite loop on world close caused by wires #287

Closed benreid24 closed 8 months ago

benreid24 commented 1 year ago

Resolves #257

See above issue for problem description.

This PR modifies WireNetworkImpl to fetch Wire objects from its own map instead of going to the world state. Doing it this way prevents chunks from being (re)loaded while the world is saving and shutting down, which was causing the infinite loop.

Applied the same approach to PipeNetworkImpl as pipe networks had the same issue.

benreid24 commented 1 year ago

Updated the approach to simply bail early instead of rebuilding the networks multiple times from cached state. This approach may cause issues if there are legitimate scenarios where a wire can be removed from an unloaded chunk, but I can't think of how that would occur besides on world shutdown.

supersimple33 commented 8 months ago

These changes work for me