Checking blocks within 2 given locations

Discussion in 'Plugin Development' started by -_Husky_-, Feb 16, 2013.

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

    -_Husky_-

    Hey guys, just need some help with checking all blocks within 2 locations.

    Code:java
    1.  
    2. public ArrayList<Block> getBlocks() {
    3. ArrayList<Block> blocks = new ArrayList<Block>();
    4. for (int x = this.getMinX(); x <= this.getMaxY(); x++) {
    5. for (int y = this.getMinY(); y <= this.getMaxY(); y++) {
    6. for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
    7. blocks.add(getWorld().getBlockAt(x, y, z));
    8. }
    9. }
    10. }
    11. return blocks;
    12. }
    13.  

    That's the current code, but it returns a really whacky number.

    Cheers.
     
  2. check the first for()
     
    -_Husky_- likes this.
  3. Code:java
    1. x <= this.getMaxY();


    Change to.

    Code:java
    1. x <= this.getMaxX();
     
    -_Husky_- likes this.
  4. Offline

    -_Husky_-

    Ta, didn't get alerts for some reason, apologies, haven't tested this yet, will in 16 hours.
     
Thread Status:
Not open for further replies.

Share This Page