    001    package net.minecraft.world.gen.feature;
    002
    003    import java.util.Random;
    004    import net.minecraft.block.Block;
    005    import net.minecraft.world.World;
    006
    007    public class WorldGenLiquids extends WorldGenerator
    008    {
    009        /** The ID of the liquid block used in this liquid generator. */
    010        private int liquidBlockId;
    011
    012        public WorldGenLiquids(int par1)
    013        {
    014            this.liquidBlockId = par1;
    015        }
    016
    017        public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    018        {
    019            if (par1World.getBlockId(par3, par4 + 1, par5) != Block.stone.blockID)
    020            {
    021                return false;
    022            }
    023            else if (par1World.getBlockId(par3, par4 - 1, par5) != Block.stone.blockID)
    024            {
    025                return false;
    026            }
    027            else if (par1World.getBlockId(par3, par4, par5) != 0 && par1World.getBlockId(par3, par4, par5) != Block.stone.blockID)
    028            {
    029                return false;
    030            }
    031            else
    032            {
    033                int var6 = 0;
    034
    035                if (par1World.getBlockId(par3 - 1, par4, par5) == Block.stone.blockID)
    036                {
    037                    ++var6;
    038                }
    039
    040                if (par1World.getBlockId(par3 + 1, par4, par5) == Block.stone.blockID)
    041                {
    042                    ++var6;
    043                }
    044
    045                if (par1World.getBlockId(par3, par4, par5 - 1) == Block.stone.blockID)
    046                {
    047                    ++var6;
    048                }
    049
    050                if (par1World.getBlockId(par3, par4, par5 + 1) == Block.stone.blockID)
    051                {
    052                    ++var6;
    053                }
    054
    055                int var7 = 0;
    056
    057                if (par1World.isAirBlock(par3 - 1, par4, par5))
    058                {
    059                    ++var7;
    060                }
    061
    062                if (par1World.isAirBlock(par3 + 1, par4, par5))
    063                {
    064                    ++var7;
    065                }
    066
    067                if (par1World.isAirBlock(par3, par4, par5 - 1))
    068                {
    069                    ++var7;
    070                }
    071
    072                if (par1World.isAirBlock(par3, par4, par5 + 1))
    073                {
    074                    ++var7;
    075                }
    076
    077                if (var6 == 3 && var7 == 1)
    078                {
    079                    par1World.setBlockWithNotify(par3, par4, par5, this.liquidBlockId);
    080                    par1World.scheduledUpdatesAreImmediate = true;
    081                    Block.blocksList[this.liquidBlockId].updateTick(par1World, par3, par4, par5, par2Random);
    082                    par1World.scheduledUpdatesAreImmediate = false;
    083                }
    084
    085                return true;
    086            }
    087        }
    088    }