Find all chests in a selection bug

Discussion in 'Spigot Plugin Development' started by ShayGFI, May 6, 2017.

  1. Code (Text):
                    for (int x = 0; x != s.getWidth(); x++) {
                        for (int y = 0; y != s.getHeight(); y++) {
                            for (int z = 0; z != s.getHeight(); z++) {
                                Location loc = new Location(s.getWorld(), x, y, z);
                                Block b = loc.getBlock();
                               
                                if(b.getState() instanceof Chest) {
                                    chests.add((Chest) b.getState());
                                    System.out.println("added");
                                }
                            }
                        }
                    }
     
    It doesn't add any chests. Do you guys know what's the problem? Thanks.
     
  2. Debug... is the loop even running?


    Sent from my iPhone using Tapatalk
     
  3. Yeah, the loop runs every time I run the command.
     
  4. You're using #getHeight twice.
     
  5. So I need to do getLength and not getHeight twice?
     
  6. Ideally yes with length being associated to its respective coordinate
     
  7. I did it, still nothing.