Generate Cube (Bukkit)

By: a guest on May 2nd, 2012  |  syntax: Java  |  size: 1.43 KB  |  hits: 31  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1.     public void generateCube(Location point, int length){  // public visible method generateCube() with 2 parameters point and location
2.         World world = point.getWorld();
3.
4.         int x_start = point.getBlockX();     // Set the startpoints to the coordinates of the given location
5.         int y_start = point.getBlockY();     // I use getBlockX() instead of getX() because it gives you a int value and so you dont have to cast it with (int)point.getX()
6.         int z_start = point.getBlockZ();
7.
8.         int x_lenght = x_start + length;    // now i set the lenghts for each dimension... should be clear.
9.         int y_lenght = y_start + length;
10.         int z_lenght = z_start + length;
11.
12.         for(int x_operate = x_start; x_operate <= x_length; x_operate++){
13.                 // Loop 1 for the X-Dimension "for x_operate (which is set to x_start)
14.                 //do whats inside the loop while x_operate is
15.                 //<= x_length and after each loop increase
16.                 //x_operate by 1 (x_operate++ is the same as x_operate=x_operate+1;)
17.                 for(int y_operate = y_start; y_operate <= y_length; y_operate++){// Loop 2 for the Y-Dimension
18.                         for(int z_operate = z_start; z_operate <= z_length; z_operate++){// Loop 3 for the Z-Dimension
19.
20.                                 Block blockToChange = world.getBlockAt(x_operate,y_operate,z_operate); // get the block with the current coordinates
21.                                 blockToChange.setTypeId(34);    // set the block to Type 34
22.                         }
23.                 }
24.         }
25.     }