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