Minecraft World Loaded Detection Using Redstone (Save file load detection)

minecraft-commandsminecraft-java-editionminecraft-redstone

I've been trying to search for an answer to this question for some time now
(World Load Detection / Chunk Load Detection / Join World / etc)

However, despite my effort, I've been unable to find a solution…

Details:

  • This is a single-player world, NOT a private or public server
  • The use of command blocks is acceptable
  • It needs to activate when I open the world, but only once
    • (and every time the save is loaded, but only once)
  • It is a 1.15 save file

I found a lead on this reddit post: https://www.reddit.com/r/technicalminecraft/comments/7vr2gz/worldchunk_loaded_detector/

This also seemed promising but I couldn't quite follow…
https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/commands-command-blocks-and/2828667-custom-join-message

However, the solution appears to be outdated (1+ year ago) and no longer works in version 1.15

Does anyone have any ideas?

I've tried the /tag and /scoreboard approach but those only seem to work on servers (local or public) since the command blocks will be running regardless of players being on the server
With this being a local save (and not a server), that does not appear to work.

Best Answer

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