For some reason does this code not remove the blocks.

Discussion in 'Plugin Development' started by Tiliondc, Dec 22, 2014.

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

    Tiliondc

    Code:
    public void deleteIsland() {
            Bukkit.broadcastMessage("Deleting an island");
            nLoc = new Location(world, loc.getX() - islandSize, 0, loc.getZ() - islandSize);
            for(int yy = 0; yy <= world.getMaxHeight(); yy++){
                for(int xx = (int) nLoc.getX(); xx <= nLoc.getX() + (islandSize * 2); xx++){
                    for(int zz = (int) nLoc.getZ(); zz <= nLoc.getZ() + (islandSize * 2); zz++) {
                        new Location(world, xx, yy, zz).getBlock().setType(Material.AIR);
                    }
                }
            }
        }
    I'm trying to set all the blocks within the area to air bit the blocks remain. Is it something obvious I'm missing here?
     
  2. Offline

    Skionz

    @Tiliondc Post all relevant classes. Is the method even being invoked? Try debugging.
     
  3. Offline

    Tiliondc

    Yes the method is being invoked. That why I have the broadcast. It does broadcast. I also placed a broadcast within the forloop and noticed it only removes on the y axis and doesn't change the other two axis. The problem is however that the blocks on that axis dind't get removed.


    *EDIT*
    I got it to work. However. It takes too much processor power to remove an island since im removing 128*2*256 blocks. Is it a way to make it faster? Like using a seperate thread on a low priority?

    **EDIT** Again. I solved it. I'm now checking if the block isn't empty first and then replacing it with air :)
     
    Last edited: Dec 22, 2014
Thread Status:
Not open for further replies.

Share This Page