    001package net.minecraft.item;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.util.HashMap;
    006import java.util.List;
    007import java.util.Map;
    008import net.minecraft.block.Block;
    009import net.minecraft.block.BlockJukeBox;
    010import net.minecraft.client.renderer.texture.IconRegister;
    011import net.minecraft.creativetab.CreativeTabs;
    012import net.minecraft.entity.player.EntityPlayer;
    013import net.minecraft.util.Icon;
    014import net.minecraft.world.World;
    015
    016public class ItemRecord extends Item
    017{
    018    /** List of all record items and their names. */
    019    private static final Map records = new HashMap();
    020
    021    /** The name of the record. */
    022    public final String recordName;
    023
    024    protected ItemRecord(int par1, String par2Str)
    025    {
    026        super(par1);
    027        this.recordName = par2Str;
    028        this.maxStackSize = 1;
    029        this.setCreativeTab(CreativeTabs.tabMisc);
    030        records.put(par2Str, this);
    031    }
    032
    033    @SideOnly(Side.CLIENT)
    034
    035    /**
    036     * Gets an icon index based on an item's damage value
    037     */
    038    public Icon getIconFromDamage(int par1)
    039    {
    040        return this.iconIndex;
    041    }
    042
    043    /**
    044     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
    045     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
    046     */
    047    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    048    {
    049        if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)
    050        {
    051            if (par3World.isRemote)
    052            {
    053                return true;
    054            }
    055            else
    056            {
    057                ((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack);
    058                par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID);
    059                --par1ItemStack.stackSize;
    060                return true;
    061            }
    062        }
    063        else
    064        {
    065            return false;
    066        }
    067    }
    068
    069    @SideOnly(Side.CLIENT)
    070
    071    /**
    072     * allows items to add custom lines of information to the mouseover description
    073     */
    074    public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
    075    {
    076        par3List.add(this.getRecordTitle());
    077    }
    078
    079    @SideOnly(Side.CLIENT)
    080
    081    /**
    082     * Return the title for this record.
    083     */
    084    public String getRecordTitle()
    085    {
    086        return "C418 - " + this.recordName;
    087    }
    088
    089    @SideOnly(Side.CLIENT)
    090
    091    /**
    092     * Return an item rarity from EnumRarity
    093     */
    094    public EnumRarity getRarity(ItemStack par1ItemStack)
    095    {
    096        return EnumRarity.rare;
    097    }
    098
    099    @SideOnly(Side.CLIENT)
    100
    101    /**
    102     * Return the record item corresponding to the given name.
    103     */
    104    public static ItemRecord getRecord(String par0Str)
    105    {
    106        return (ItemRecord)records.get(par0Str);
    107    }
    108
    109    @SideOnly(Side.CLIENT)
    110    public void func_94581_a(IconRegister par1IconRegister)
    111    {
    112        this.iconIndex = par1IconRegister.func_94245_a("record_" + this.recordName);
    113    }
    114}