Solved Fill an area with water.

Discussion in 'Plugin Development' started by the_merciless, Nov 16, 2013.

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


    Im trying to fill an area with water using this code:

        private void refillWater() {
            final World world = Bukkit.getWorld(config.getString("Bases." + basename + ""));
            int x1 = config.getInt("Bases." + basename + ".waterpos1.x");
            int x2 = config.getInt("Bases." + basename + ".waterpos2.x");
            int z1 = config.getInt("Bases." + basename + ".waterpos1.z");
            int z2 = config.getInt("Bases." + basename + ".waterpos2.z");
            final int y = config.getInt("Bases." + basename + ".waterpos1.y");
            final int xmin = Math.min(x1, x2) - 1;
            final int xmax = Math.max(x1, x2);
            final int zmin = Math.min(z1, z2) - 1;
            final int zmax = Math.max(z1, z2);
            for (int x = xmin; x < xmax; x++){
                for (int z = zmin; z < zmax; z++){
                    world.getBlockAt(x, y, z).setType(Material.WATER);
    The area fills with water but the water does not stay there. It just drains away as if a water source block was removed.
  2. Offline


    You already made this post..
  3. Offline


  4. Offline


    Yeah i didn't get much help from that. Feel like i didnt make it very clear on the last post so made a new 1.

    Already tried.

    Solved by adding this:

    world.getBlockAt(x, y, z).setData((byte) 0);
    This makes the block a source block which will stop it draining away.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page