Detect Newly Loaded Chunks Using Command Blocks/Redstone [duplicate]
With commands it's easy:
/scoreboard objectives add leave custom:leaveGame
This ticks up once for every time you leave the world, so it can be detected on the next server tick (when you have joined again). I do not know how it behaves when Minecraft is killed or crashes.
Example usage:
/execute if entity @a[scores={leave=1..}] run say The world was reopened.
/scoreboard players reset * leave
I showed this question to some experts about the limits of what redstone can do, but they didn't respond. :(
So I found a solution myself: My initial idea was that chunk loading detectors might work as world loading detectors as well. It turns out that this is true, even when you close and re-open the world inside the chunk with the detector inside it. So you just need to put one of those detectors e.g. every 320 blocks in both X and Z direction for render distance 10 and somehow get the output to where you want it.
Now the problem of building a chunk loading detector. I found a very easy one on Reddit, which works in 1.15.2 as well: https://www.reddit.com/r/technicalminecraft/comments/7vr2gz/worldchunk_loaded_detector/
Here is an image. Everything is self-explanatory, except this: The armour stand wears frost walker boots.