    001    package net.minecraft.src;
    002
    003    import java.util.Random;
    004
    005    public class WorldGenMinable extends WorldGenerator
    006    {
    007        /** The block ID of the ore to be placed using this generator. */
    008        private int minableBlockId;
    009        private int minableBlockMeta = 0;
    010
    011        /** The number of blocks to generate. */
    012        private int numberOfBlocks;
    013
    014        public WorldGenMinable(int par1, int par2)
    015        {
    016            this.minableBlockId = par1;
    017            this.numberOfBlocks = par2;
    018        }
    019
    020        public WorldGenMinable(int id, int meta, int number)
    021        {
    022            this(id, number);
    023            minableBlockMeta = meta;
    024        }
    025
    026        public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    027        {
    028            float var6 = par2Random.nextFloat() * (float)Math.PI;
    029            double var7 = (double)((float)(par3 + 8) + MathHelper.sin(var6) * (float)this.numberOfBlocks / 8.0F);
    030            double var9 = (double)((float)(par3 + 8) - MathHelper.sin(var6) * (float)this.numberOfBlocks / 8.0F);
    031            double var11 = (double)((float)(par5 + 8) + MathHelper.cos(var6) * (float)this.numberOfBlocks / 8.0F);
    032            double var13 = (double)((float)(par5 + 8) - MathHelper.cos(var6) * (float)this.numberOfBlocks / 8.0F);
    033            double var15 = (double)(par4 + par2Random.nextInt(3) - 2);
    034            double var17 = (double)(par4 + par2Random.nextInt(3) - 2);
    035
    036            for (int var19 = 0; var19 <= this.numberOfBlocks; ++var19)
    037            {
    038                double var20 = var7 + (var9 - var7) * (double)var19 / (double)this.numberOfBlocks;
    039                double var22 = var15 + (var17 - var15) * (double)var19 / (double)this.numberOfBlocks;
    040                double var24 = var11 + (var13 - var11) * (double)var19 / (double)this.numberOfBlocks;
    041                double var26 = par2Random.nextDouble() * (double)this.numberOfBlocks / 16.0D;
    042                double var28 = (double)(MathHelper.sin((float)var19 * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * var26 + 1.0D;
    043                double var30 = (double)(MathHelper.sin((float)var19 * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * var26 + 1.0D;
    044                int var32 = MathHelper.floor_double(var20 - var28 / 2.0D);
    045                int var33 = MathHelper.floor_double(var22 - var30 / 2.0D);
    046                int var34 = MathHelper.floor_double(var24 - var28 / 2.0D);
    047                int var35 = MathHelper.floor_double(var20 + var28 / 2.0D);
    048                int var36 = MathHelper.floor_double(var22 + var30 / 2.0D);
    049                int var37 = MathHelper.floor_double(var24 + var28 / 2.0D);
    050
    051                for (int var38 = var32; var38 <= var35; ++var38)
    052                {
    053                    double var39 = ((double)var38 + 0.5D - var20) / (var28 / 2.0D);
    054
    055                    if (var39 * var39 < 1.0D)
    056                    {
    057                        for (int var41 = var33; var41 <= var36; ++var41)
    058                        {
    059                            double var42 = ((double)var41 + 0.5D - var22) / (var30 / 2.0D);
    060
    061                            if (var39 * var39 + var42 * var42 < 1.0D)
    062                            {
    063                                for (int var44 = var34; var44 <= var37; ++var44)
    064                                {
    065                                    double var45 = ((double)var44 + 0.5D - var24) / (var28 / 2.0D);
    066
    067                                    Block block = Block.blocksList[par1World.getBlockId(var38, var41, var44)];
    068                                    if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && (block != null && block.isGenMineableReplaceable(par1World, var38, var41, var44)))
    069                                    {
    070                                        par1World.setBlockAndMetadata(var38, var41, var44, this.minableBlockId, minableBlockMeta);
    071                                    }
    072                                }
    073                            }
    074                        }
    075                    }
    076                }
    077            }
    078
    079            return true;
    080        }
    081    }