Placing an array of blocks (Like spleef when it resets.)

Discussion in 'Plugin Development' started by AcpSoldier, Sep 12, 2014.

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

    AcpSoldier

    You all know what WorldEdit is, right? Good. So I have two positions set in my plugin, all I did was save the X, Y, and Z coords in the config. But how can I place a ton of blocks going from pos1 to pos2? For example: When a spleef round is over, all the blocks in the arena reset back to snow. How is this done? Thanks! :)
     
  2. Offline

    Yekllurt

  3. Offline

    xTrollxDudex

    Basically, you don't need a ton of extra work. It's a triple nested for loop through the x, y, and z. It would be preferable to save it in a Block[][][] array for this reason.
     
  4. Offline

    fireblast709

  5. Offline

    xTrollxDudex

    Or Material :p
     
  6. Offline

    fireblast709

    xTrollxDudex Poor tile entities will lose their data now ;-;
     
  7. Offline

    xTrollxDudex

    Aww
     
  8. Offline

    mythbusterma

    AcpSoldier

    Personally, I've had good results with TerrainManager from DHutils (Google it).
     
  9. Offline

    16davidjm6

    go to one corner, have your plugin store the coordinates of that corner.
    go to the exact opposite corner, have your plugin store the coordinates of that corner.

    Code:java
    1. Location loc1; //location of corner 1
    2. Location loc2; //location of corner 2
    3.  
    4. //magic to store corner locations here
    5.  
    6. int maxX;
    7. int maxY;
    8. int maxZ;
    9.  
    10. int minX;
    11. int minY;
    12. int minZ;
    13.  
    14. if(loc1.getBlockX() >= loc2.getBlockX()){
    15. maxX = loc1.getBlockX();
    16. minX = loc2.getBlockX();
    17. } else {
    18. maxX = loc2.getBlockX();
    19. minX = loc1.getBlockX();
    20. }
    21.  
    22. //repeat if statement for Y and Z.
    23.  
    24. for(int x = minX; x <= maxX; x++){
    25. for(int y = minY; y <= maxY; y++){
    26. for(int z = minZ; z <= maxZ; z++){
    27. (new Location(<world name>,x,y,z).getBlock().setType(Material.<block you want>);
    28. }
    29. }
    30. }


    Left a few holes for you to fill in, but that should put you in the right direction
     
    AcpSoldier likes this.
Thread Status:
Not open for further replies.

Share This Page