Generate Hollow Cube

Discussion in 'Plugin Development' started by GeorgeeeHD, May 6, 2014.

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

    GeorgeeeHD

    Hi, I have written this code so far, but this makes a solid cube of glass, which I don't want, I need it to be hollow. Any ideas? Thanks!

    Code:java
    1. for(int x = 0 ; x <= 20 ; x++) {
    2. for(int y = 0 ; y <= 15 ; y++) {
    3. for(int z = 0 ; z <= 20 ; z++) {
    4. Block b = p.getLocation().add(x, y + 30, z).getBlock();
    5. b.setType(Material.GLASS);
    6. blocks.add(b);
    7. }
    8. }
    9. }


    Edit, "blocks" is a list of Block so that i can remove the blocks at a later point, just so you aren't confused :p
     
  2. Offline

    coasterman10

    Two options.
    1. Create a smaller cube of air inside to hollow it out, or
    2. (Better) Build 6 separate faces of the cube
     
  3. Offline

    RawCode

    you shoud draw hollow cube slice by slice in all projections on paper (real one) and you will notice how you can make it hollow without building multiple cubes or drawning each face at time.

    long ago i managed to draw menger spounge without looking at wiki by smart usage of % operator.
     
  4. Offline

    Zethariel

    GeorgeeeHD You need to understand how a for loop works first. It will iterate through all the coordinates, so naturally all the blocks will be replaced. You could add an if that changes to glass only if x, y or z is at it's minimum or maximum.
     
Thread Status:
Not open for further replies.

Share This Page