    001    package net.minecraft.src;
    002
    003    import java.util.Random;
    004
    005    public class WorldGenSpikes extends WorldGenerator
    006    {
    007        /**
    008         * The Block ID that the generator is allowed to replace while generating the terrain.
    009         */
    010        private int replaceID;
    011
    012        public WorldGenSpikes(int par1)
    013        {
    014            this.replaceID = par1;
    015        }
    016
    017        public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    018        {
    019            if (par1World.isAirBlock(par3, par4, par5) && par1World.getBlockId(par3, par4 - 1, par5) == this.replaceID)
    020            {
    021                int var6 = par2Random.nextInt(32) + 6;
    022                int var7 = par2Random.nextInt(4) + 1;
    023                int var8;
    024                int var9;
    025                int var10;
    026                int var11;
    027
    028                for (var8 = par3 - var7; var8 <= par3 + var7; ++var8)
    029                {
    030                    for (var9 = par5 - var7; var9 <= par5 + var7; ++var9)
    031                    {
    032                        var10 = var8 - par3;
    033                        var11 = var9 - par5;
    034
    035                        if (var10 * var10 + var11 * var11 <= var7 * var7 + 1 && par1World.getBlockId(var8, par4 - 1, var9) != this.replaceID)
    036                        {
    037                            return false;
    038                        }
    039                    }
    040                }
    041
    042                for (var8 = par4; var8 < par4 + var6 && var8 < 128; ++var8)
    043                {
    044                    for (var9 = par3 - var7; var9 <= par3 + var7; ++var9)
    045                    {
    046                        for (var10 = par5 - var7; var10 <= par5 + var7; ++var10)
    047                        {
    048                            var11 = var9 - par3;
    049                            int var12 = var10 - par5;
    050
    051                            if (var11 * var11 + var12 * var12 <= var7 * var7 + 1)
    052                            {
    053                                par1World.setBlockWithNotify(var9, var8, var10, Block.obsidian.blockID);
    054                            }
    055                        }
    056                    }
    057                }
    058
    059                EntityEnderCrystal var13 = new EntityEnderCrystal(par1World);
    060                var13.setLocationAndAngles((double)((float)par3 + 0.5F), (double)(par4 + var6), (double)((float)par5 + 0.5F), par2Random.nextFloat() * 360.0F, 0.0F);
    061                par1World.spawnEntityInWorld(var13);
    062                par1World.setBlockWithNotify(par3, par4 + var6, par5, Block.bedrock.blockID);
    063                return true;
    064            }
    065            else
    066            {
    067                return false;
    068            }
    069        }
    070    }