World Regeneration

Discussion in 'Plugin Development' started by Jakeob22, Apr 24, 2012.

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

    Jakeob22

    Is it possible to have players play a world and have a function that switches them to another world? Then, how could the world that they left be converted back to how it was when they started? Is this possible? Thanks! :D
     
  2. you can warp players to other world, you can record their chances and undo it.
     
  3. Offline

    ItsJerry

    You could also regenerate the world. Some plugins already have it like WorldEdit
     
  4. Offline

    Jakeob22

    Recording changes would take up a bit of memory. Is it possible 2 have a few world files with the orignial world that clone themselves? :p
    And ItsJerry do you know how they do it? xD
     
  5. Offline

    ItsJerry

    Nope I don't. I'm guessing they use org.bukkit.generator.ChunkGenerator lol
     
  6. Offline

    Father Of Time

    Chunks themselves have the ability to take a "snapshot" of the chunk, you can simply take a snapshot of every chunk that is generated in that world, then when you decide to "roll it back" you can restore that snapshot, essentially reverting the chunk back to the exact state it was in when the snapshot was taken.

    http://jd.bukkit.org/doxygen/d6/d90/interfaceorg_1_1bukkit_1_1Chunk.html


    I've never used this feature but I would imagine this would be preferable to WorldEdits method; WorldEdit rebuilds the terrain from the original seed, this has two shortcomings

    1) if you change your seed or have map corruption the generator will make undesired results, such as uneven terrain and placing lakes in the middle of forrest... uncool...
    2) It can ONLY regenerate the map back to the state of the original seed, so everything is lost.

    However, if you used a snapshot you can either rollback to the original state, or make some changes and snapshot the changes and rollback to your own personal "default".

    Check out bukkits java docs and look at the chunk.java class, it has a few functions purely desired for saving.

    Hope this helps, good luck!
     
  7. Offline

    Jakeob22



    "However, if you used a snapshot you can either rollback to the original state, or make some changes and snapshot the changes and rollback to your own personal "default"."

    If we built a custom map, how could we go about doing that?
     
  8. Offline

    Father Of Time

    Then this rings even more true for you... If you have a custom map seed regeneration simply doesn't work, seed regeneration is done via a mathematical algorithm.

    As far as restoring a chunk, I couldn't say as I've never played around with chunks... Seeing as their is no restore chunk function within the chunk class I would imagine it would be a matter of using block iterators to cycle through the snapshot and restore each block in the chunk to the state of the block in the snapshot in the same location (but I'm guessing).

    One thing I should note, you may want to offset these "restorations" from one another, only allowing it to perform a restore on one chunk at a time, because I can only imagine that attempting to restore an entire worlds worth of chunks at once will cause insane lag, if not crash the server.

    Sorry, but this is about as much advice as I can give you with my personal experience with the subject, but feel free to ask more questions if they arise, I may unknowingly have the answer. :D
     
  9. Offline

    Jakeob22

  10. Offline

    robin0van0der0v

    The world is generated with an seed, you can stop the server, delete all the Anvil-files and restart the server. ;)
     
  11. Offline

    Father Of Time

    The chunk snapshots don't have serialization methods, so you would need to create your own.

    As far as rolling back, as I stated before this could be handled with block iterators and the chunk snapshot. Remember, these snapshots are thread safe, so you can pass the work to another thread so that it can cycle through the chunk and repair it without causing the main thread any lag.

    The functionality you are seeking does not exist in the Bukkit API, you will need to create your own.
     
  12. Offline

    Darq

    org.bukkit.World.regenerateChunk()?
     
  13. Offline

    Jakeob22

    Darq Apparently, that uses seeds and algorithms to regenerate it to it's original state. I need it to regenerate my custom map :(

    Father Of Time Is it possible to use schematics of what I want to regenerate? :p
     
Thread Status:
Not open for further replies.

Share This Page