    001    package net.minecraft.block;
    002
    003    import java.util.Random;
    004    import net.minecraft.block.material.Material;
    005    import net.minecraft.creativetab.CreativeTabs;
    006    import net.minecraft.item.Item;
    007    import net.minecraft.util.MathHelper;
    008    import net.minecraft.world.World;
    009
    010    public class BlockOre extends Block
    011    {
    012        public BlockOre(int par1, int par2)
    013        {
    014            super(par1, par2, Material.rock);
    015            this.setCreativeTab(CreativeTabs.tabBlock);
    016        }
    017
    018        /**
    019         * Returns the ID of the items to drop on destruction.
    020         */
    021        public int idDropped(int par1, Random par2Random, int par3)
    022        {
    023            return this.blockID == Block.oreCoal.blockID ? Item.coal.shiftedIndex : (this.blockID == Block.oreDiamond.blockID ? Item.diamond.shiftedIndex : (this.blockID == Block.oreLapis.blockID ? Item.dyePowder.shiftedIndex : (this.blockID == Block.oreEmerald.blockID ? Item.emerald.shiftedIndex : this.blockID)));
    024        }
    025
    026        /**
    027         * Returns the quantity of items to drop on block destruction.
    028         */
    029        public int quantityDropped(Random par1Random)
    030        {
    031            return this.blockID == Block.oreLapis.blockID ? 4 + par1Random.nextInt(5) : 1;
    032        }
    033
    034        /**
    035         * Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
    036         */
    037        public int quantityDroppedWithBonus(int par1, Random par2Random)
    038        {
    039            if (par1 > 0 && this.blockID != this.idDropped(0, par2Random, par1))
    040            {
    041                int var3 = par2Random.nextInt(par1 + 2) - 1;
    042
    043                if (var3 < 0)
    044                {
    045                    var3 = 0;
    046                }
    047
    048                return this.quantityDropped(par2Random) * (var3 + 1);
    049            }
    050            else
    051            {
    052                return this.quantityDropped(par2Random);
    053            }
    054        }
    055
    056        /**
    057         * Drops the block items with a specified chance of dropping the specified items
    058         */
    059        public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
    060        {
    061            super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7);
    062
    063            if (this.idDropped(par5, par1World.rand, par7) != this.blockID)
    064            {
    065                int var8 = 0;
    066
    067                if (this.blockID == Block.oreCoal.blockID)
    068                {
    069                    var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 0, 2);
    070                }
    071                else if (this.blockID == Block.oreDiamond.blockID)
    072                {
    073                    var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 3, 7);
    074                }
    075                else if (this.blockID == Block.oreEmerald.blockID)
    076                {
    077                    var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 3, 7);
    078                }
    079                else if (this.blockID == Block.oreLapis.blockID)
    080                {
    081                    var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 2, 5);
    082                }
    083
    084                this.dropXpOnBlockBreak(par1World, par2, par3, par4, var8);
    085            }
    086        }
    087
    088        /**
    089         * Determines the damage on the item the block drops. Used in cloth and wood.
    090         */
    091        public int damageDropped(int par1)
    092        {
    093            return this.blockID == Block.oreLapis.blockID ? 4 : 0;
    094        }
    095    }