Adding block coordinates to array list

Discussion in 'Plugin Development' started by Honeyjuice14, Dec 21, 2014.

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

    Honeyjuice14

    Hey, i am having trouble adding the block coordingates of a cude to an array list so i can refer to it later in my code. here is my code for the cube:
    Code:
        int center = 0;
        int radius = 6;
        int height = 80;
        public void saveBoxCoords(){
            for (int y = height - (2 * radius); y < height; y++) {
                for (int x = -radius + center; x < radius + center; x++) {
                    for (int z = -radius + center; z < radius + center; z++) {
                        Block b = getServer().getWorld("world").getBlockAt(x, y, z);
                       
                    }
                }
            }
        }
    How would i go about adding JUST the coordinates to a list, eg myList = ((x,y,z),(x1,y1,z1),(x2,y2,z2)) etc...
     
  2. Offline

    leon3001

    @Honeyjuice14 Create a custom Object that holds the data you want to store.
     
  3. Offline

    spy_1134

  4. Offline

    Honeyjuice14

    Thanks for the reply, but what i ended up doing was using a list of blocks rather than just its coords:
    List<Block> boxCoords = new ArrayList<Block>();
    for (int y = height - (2 * radius); y < height; y++) {
    for (int x = -radius + center; x < radius + center; x++) {
    for (int z = -radius + center; z < radius + center; z++) {
    Block b = getServer().getWorld("world").getBlockAt(x, y, z);
    boxCoords.add(b);

    }
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page