    001package net.minecraft.block;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.util.Random;
    006import net.minecraft.block.material.Material;
    007import net.minecraft.client.renderer.texture.IconRegister;
    008import net.minecraft.creativetab.CreativeTabs;
    009import net.minecraft.item.Item;
    010import net.minecraft.util.Icon;
    011
    012public class BlockMelon extends Block
    013{
    014    @SideOnly(Side.CLIENT)
    015    private Icon theIcon;
    016
    017    protected BlockMelon(int par1)
    018    {
    019        super(par1, Material.pumpkin);
    020        this.setCreativeTab(CreativeTabs.tabBlock);
    021    }
    022
    023    @SideOnly(Side.CLIENT)
    024
    025    /**
    026     * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
    027     */
    028    public Icon getIcon(int par1, int par2)
    029    {
    030        return par1 != 1 && par1 != 0 ? this.blockIcon : this.theIcon;
    031    }
    032
    033    /**
    034     * Returns the ID of the items to drop on destruction.
    035     */
    036    public int idDropped(int par1, Random par2Random, int par3)
    037    {
    038        return Item.melon.itemID;
    039    }
    040
    041    /**
    042     * Returns the quantity of items to drop on block destruction.
    043     */
    044    public int quantityDropped(Random par1Random)
    045    {
    046        return 3 + par1Random.nextInt(5);
    047    }
    048
    049    /**
    050     * Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
    051     */
    052    public int quantityDroppedWithBonus(int par1, Random par2Random)
    053    {
    054        int j = this.quantityDropped(par2Random) + par2Random.nextInt(1 + par1);
    055
    056        if (j > 9)
    057        {
    058            j = 9;
    059        }
    060
    061        return j;
    062    }
    063
    064    @SideOnly(Side.CLIENT)
    065
    066    /**
    067     * When this method is called, your block should register all the icons it needs with the given IconRegister. This
    068     * is the only chance you get to register icons.
    069     */
    070    public void registerIcons(IconRegister par1IconRegister)
    071    {
    072        this.blockIcon = par1IconRegister.registerIcon("melon_side");
    073        this.theIcon = par1IconRegister.registerIcon("melon_top");
    074    }
    075}