Massive block changes

Discussion in 'Plugin Development' started by EvilPeanut, Dec 30, 2013.

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

    EvilPeanut

    Hello,

    I'm writing a plugin similar to WorldEdit.
    How can I change a huge area of blocks without lagging out connected players.

    Thanks,
    Reece
     
  2. Offline

    TheJakubx

    you need to sellect two block and changing block in three whiles.
    in looks line in my plugin:
    Code:java
    1. if(Frix > Secx){
    2. int temp = Frix;
    3. Frix = Secx;
    4. Secx = temp;
    5. }
    6. if(Friy > Secy){
    7. int temp = Friy;
    8. Friy = Secy;
    9. Secy = temp;
    10. }
    11. if(Friz > Secz){
    12. int temp = Friz;
    13. Friz = Secz;
    14. Secz = temp;
    15. }
    16. for(int x = Frix;x<=Secx;x++){
    17. for(int y = Friy;y<=Secy;y++){
    18. for(int z = Friz;z<=Secz;z++){
    19. Set(Material.getMaterial(name),x,y,z, world);
    20. }
    21. }
    22. }


    before the change blocks you need to check and change values of First and Second selection of Second was less than First x/y/z because whiles executes only when Second less First.
    Firx, Firy, Firz - First Selection x,y,z
    Secx, Secy, Secz - Second Selection x,y,z
     
  3. Offline

    EvilPeanut

    Just for the record my plugin already works and does the same job, but I need it to fill huge areas without flooding block change packets. (At the moment it uses a scheduler to send 20 block changes a second).
     
  4. Offline

    TheJakubx

    Make new thread and at 20 change sleep for x seconds
     
  5. Offline

    EvilPeanut

    Thanks not what im looking for. I believe theres a way of adding blocks to the server packet que or something which people use for massive block changes, thats what im interested in. NOT sending individual packets.
     
  6. Offline

    Codex Arcanum

    You may find this thread useful.
     
  7. Offline

    NathanWolf

    There are many threads discussing this topic, please try searching for details and example code. The short explanation is you need to break up the work and spread it across multiple ticks with a synchronous repeating task.
     
  8. Offline

    EvilPeanut

    His code is outdated and the links are broken in his posts, so not really.. :S
     
Thread Status:
Not open for further replies.

Share This Page