Blocks manipulation

Discussion in 'Plugin Development' started by girardcome, Jun 8, 2019.

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

    girardcome

    Hello,

    What I wanted:
    Replace all the water and stationary water blocks with a block of grass above and below the dirt blocks in a predefined radius.

    What I got: I was able to replace all the water and stationary water with dirt and grass blocks but the grass blocks are not aligned at all and have a disgusting appearance (as in the picture).

    upload_2019-6-9_1-3-57.png

    What I would like to get:

    [​IMG]

    My code:

    PHP:
        public void settingBiome(World worldint radius) {
            for (
    double x world.getSpawnLocation().getX() - radius<= world.getSpawnLocation().getX() + radiusx++) {
                for (
    double y world.getSpawnLocation().getY() - radius<= world.getSpawnLocation().getY() + radiusy++) {
                    for (
    double z world.getSpawnLocation().getZ() - radius<= world.getSpawnLocation().getZ() + radiusz++) {
                        
    Location loc = new Location(worldx1z);
                        if(
    loc.getBlock().getType() == Material.WATER || loc.getBlock().getType() == Material.STATIONARY_WATER) {
                            
    loc.getBlock().getRelative(BlockFace.UP).setType(Material.GRASS);
                            
    loc.getBlock().setType(Material.DIRT);
                        }
                    }
                }
            }
        }
    Thanks to all people who will help me to solve this problem, the others, go your way.
     
Thread Status:
Not open for further replies.

Share This Page