    001package net.minecraft.world.gen.feature;
    002
    003import java.util.Random;
    004import net.minecraft.block.Block;
    005import net.minecraft.world.World;
    006
    007public 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 l = 0;
    034
    035            if (par1World.getBlockId(par3 - 1, par4, par5) == Block.stone.blockID)
    036            {
    037                ++l;
    038            }
    039
    040            if (par1World.getBlockId(par3 + 1, par4, par5) == Block.stone.blockID)
    041            {
    042                ++l;
    043            }
    044
    045            if (par1World.getBlockId(par3, par4, par5 - 1) == Block.stone.blockID)
    046            {
    047                ++l;
    048            }
    049
    050            if (par1World.getBlockId(par3, par4, par5 + 1) == Block.stone.blockID)
    051            {
    052                ++l;
    053            }
    054
    055            int i1 = 0;
    056
    057            if (par1World.isAirBlock(par3 - 1, par4, par5))
    058            {
    059                ++i1;
    060            }
    061
    062            if (par1World.isAirBlock(par3 + 1, par4, par5))
    063            {
    064                ++i1;
    065            }
    066
    067            if (par1World.isAirBlock(par3, par4, par5 - 1))
    068            {
    069                ++i1;
    070            }
    071
    072            if (par1World.isAirBlock(par3, par4, par5 + 1))
    073            {
    074                ++i1;
    075            }
    076
    077            if (l == 3 && i1 == 1)
    078            {
    079                par1World.setBlock(par3, par4, par5, this.liquidBlockId, 0, 2);
    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}