Solved Preloading Chunks to Reduce Lag

Discussion in 'Plugin Development' started by Smeary_Subset, Oct 1, 2022.

Thread Status:
Not open for further replies.
  1. Offline

    Smeary_Subset

    I have a minigame that involves teleporting players to a random location within <-10000, -10000> to <10000, 10000> when they start the minigame. With each instance of the minigame, a fresh copy of the same world is loaded (meaning the world contains no region files).

    This creates a ton of lag because the world always has to generate previously unloaded chunks.

    To solve this issue, I propose that I should pre-generate all the chunks in the random spawn area and save that copy of the world as the default so that every time the minigame is run, it pulls the world file with all region files already there instead having to naturally generate them every time.

    Firstly, do you believe this is the best solution? Secondly, how can I go about doing this without running around trying to generate each chunk? I've looked into the Fast Chunk Pregenerator 2.0.6 plugin but wanted to hear other perspectives.
     
  2. Offline

    Kars

    Just use the same world that is already generated?
     
  3. Offline

    Smeary_Subset

    No, I cannot do that because I need an unedited copy of the world because players are able to destroy and place blocks during the minigame.

    Another solution (I guess), would be to track what blocks players have placed/destroyed and revert them back at the end of the game, but that wouldn't allow support for multiple instances of the minigame with multiple copies of the world.
     
  4. Offline

    Kars

    Then figure out how worlds work on the filesystem and have a clean version of the world and copy it each time.
     
  5. Offline

    Smeary_Subset

    What do you mean how worlds work on the file system? I understand that region files are the files that store the generated chunk data. What I'm trying to figure out is how to automatically generate all the region files for a specific area of the world so that I can, just like you said, copy the clean version of the world each time.
     
  6. Offline

    Kars

    @Smeary_Subset that's why i'm suggesting you figure out how a world works on the filesystem of the server. Have the clean world ready to go (in a folder or however it works) and turn a copy of it into a world through file manipulation.
     
  7. Offline

    Smeary_Subset

    I don't think we are on the same page. Forget the copying of the world part, it's irrelevant. I need to know how to generate all the chunks of a particular region. I would prefer to get the region files generated without flying around in creative to get them generated.
     
    Last edited: Oct 15, 2022
  8. Offline

    Tim_M

    I think what @Kars is trying to say is that you should make a world with all of the chunks already generated, and then make a duplicate of the world whenever you need it and then discard it after the game has ended.
     
  9. Offline

    Smeary_Subset

    Right, I understand that. But how am I supposed to generate all the chunks I need without flying around in creative mode? Is there a better way to do it?
     
  10. Offline

    timtower Administrator Administrator Moderator

    You load them, then they get generated.
     
  11. Offline

    Smeary_Subset

    How do I load the chunks without running around in creative mode?
     
  12. Offline

    timtower Administrator Administrator Moderator

  13. Offline

    Kars

    My guy i just told you twice and i guess i'll tell you again.
    You know how worlds work. Yes? They are represented as files on a computer's file system.
    What you do is, you figure out how a world works (probably with 3 folders in the server root called world, world_nether and world_the_end) and you have the clean version of your desired world (SO WITH PRE GENERATED CHUNKS) ready to go in like a folder somewhere.

    Then, when the need arises, you copy the pre-loaded world into a folder or something, however it works (look up how multi world servers work) and load it up -> use it -> discard it.
    Sound simple enough.

    The only challenge is to figure out how to load up a world from an existing folder.
     
  14. Offline

    Tim_M

    timtowers solution is probably very good but there's this tool:
    https://www.minecraftforum.net/foru...ecraft-tools/1261072-minecraft-land-generator
    that you could try, haven't used so can't say if it works.
    Also if you're running on paper you could increase the amount of threads used for chunk loading and generation.
     
  15. Offline

    Smeary_Subset

    "My guy I just told you twice" that you are misunderstanding my question and are repeatedly telling me answers to questions I 1) am not asking and 2) already know the answers to. But I guess I'll tell you again.

    Tim Tower and Tim_M got it, so don't worry about it. I appreciate your time.

    Excellent, thanks for the help. I'll decide which one works better for my situation.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  16. Offline

    Kars

Thread Status:
Not open for further replies.

Share This Page