Block Regenerating System

Discussion in 'Plugin Development' started by Zombieghost_391, Sep 29, 2014.

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

    Zombieghost_391

    I'm working on a minigame plugin but the regenerating system works poorly. I would like it if someone could help me with a new method of doing this. I had the idea of schematics but not to sure on how to do that. Maybe copying a world file and use the dummy world IdK but help would be appreciated. Also maybe I could use worldedit api but not sure on how to use it :p
     
  2. Offline

    97WaterPolo

    Zombieghost_391
    Well it depends what you are trying to do. If you want the blocks to regenerate while a game is still in procession, I would recommend setting the block back to it's original state on a 20Tick delay. If you want a build regenerated after I would suggest pasting a schematic (there are some tutorials on it). If you want a world regenerated, I would suggest copying the original files (unmodified version of the map) to a seperate location, unloading the world, and copying the saved copy of the original files to the world region. If you want the world one, hopefully someone else can go into better detail on that then me :p
     
  3. Offline

    Zombieghost_391

    Thanks man I'm going to try to delay the regerating by 20 ticks like u said but if it doesn'twork then I'm going to attempt to try the copying and save separate worls which is what I wanted to do in the first place but didn't have the understanding on how to do it
     
  4. Zombieghost_391 if you just want to regenerate a few blocks, you can store their location and thier material in a hasmap with the location as key. then you run a thread or a scheduler and regenerate every single block in ths hashmap. with the blockbreaks event you can get every stone on the server which breaks. if you want to rebuilt whole worlds or a few chunks i would save them into a backup file and reload them if needed. solution nr 1. should only be used if you want to regenerate blocks which were broke by player or something like this. to reset a whole world would be way to much for a single hashmap. also it would laag if you wont run the rebuild method in a seperate thread if there are too many blocks
     
  5. Offline

    CraftCreeper6

    Few of steps:
    1) List<BlockState>
    2) Everytime something destroys a block (event)
    3) Save to the List.
    4) After x seconds use a for loop to set all the blocks back.
     
  6. Offline

    Zombieghost_391

    Yes i know that, thats what I have been doing but the world file being copied is a better way :D
     
  7. Offline

    CraftCreeper6

  8. Offline

    Zombieghost_391

    Ummm I'm having some problems help would be nice to correct me on my mistakes
    Code:java
    1. public static void tester()throws IOException
    2. {
    3. {
    4. File path = new File("MapIWant");
    5.  
    6. FileInputStream from = new FileInputStream(path);
    7. FileOutputStream to = new FileOutputStream("MapPutOut");
    8. byte []buffer = new byte[4096];
    9. int byteRead;
    10. while( (byteRead=from.read(buffer) ) !=-1){
    11. to.write(buffer,0,byteRead);
    12. }
    13.  
    14. from.close();
    15. to.close();
    16. }
    17. }
     
Thread Status:
Not open for further replies.

Share This Page