001package net.minecraft.block; 002 003import java.util.Random; 004import net.minecraft.block.material.Material; 005import net.minecraft.creativetab.CreativeTabs; 006import net.minecraft.item.Item; 007import net.minecraft.util.MathHelper; 008import net.minecraft.world.World; 009 010public class BlockOre extends Block 011{ 012 public BlockOre(int par1) 013 { 014 super(par1, 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.itemID : (this.blockID == Block.oreDiamond.blockID ? Item.diamond.itemID : (this.blockID == Block.oreLapis.blockID ? Item.dyePowder.itemID : (this.blockID == Block.oreEmerald.blockID ? Item.emerald.itemID : (this.blockID == Block.field_94342_cr.blockID ? Item.field_94583_ca.itemID : 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 j = par2Random.nextInt(par1 + 2) - 1; 042 043 if (j < 0) 044 { 045 j = 0; 046 } 047 048 return this.quantityDropped(par2Random) * (j + 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 j1 = 0; 066 067 if (this.blockID == Block.oreCoal.blockID) 068 { 069 j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 0, 2); 070 } 071 else if (this.blockID == Block.oreDiamond.blockID) 072 { 073 j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 3, 7); 074 } 075 else if (this.blockID == Block.oreEmerald.blockID) 076 { 077 j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 3, 7); 078 } 079 else if (this.blockID == Block.oreLapis.blockID) 080 { 081 j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 2, 5); 082 } 083 else if (this.blockID == Block.field_94342_cr.blockID) 084 { 085 j1 = MathHelper.getRandomIntegerInRange(par1World.rand, 2, 5); 086 } 087 088 this.dropXpOnBlockBreak(par1World, par2, par3, par4, j1); 089 } 090 } 091 092 /** 093 * Determines the damage on the item the block drops. Used in cloth and wood. 094 */ 095 public int damageDropped(int par1) 096 { 097 return this.blockID == Block.oreLapis.blockID ? 4 : 0; 098 } 099}