    001package net.minecraft.item;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.util.ArrayList;
    006import java.util.List;
    007import net.minecraft.entity.item.EntityFireworkRocket;
    008import net.minecraft.entity.player.EntityPlayer;
    009import net.minecraft.nbt.NBTTagCompound;
    010import net.minecraft.nbt.NBTTagList;
    011import net.minecraft.util.StatCollector;
    012import net.minecraft.world.World;
    013
    014public class ItemFirework extends Item
    015{
    016    public ItemFirework(int par1)
    017    {
    018        super(par1);
    019    }
    020
    021    /**
    022     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
    023     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
    024     */
    025    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    026    {
    027        if (!par3World.isRemote)
    028        {
    029            EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(par3World, (double)((float)par4 + par8), (double)((float)par5 + par9), (double)((float)par6 + par10), par1ItemStack);
    030            par3World.spawnEntityInWorld(entityfireworkrocket);
    031
    032            if (!par2EntityPlayer.capabilities.isCreativeMode)
    033            {
    034                --par1ItemStack.stackSize;
    035            }
    036
    037            return true;
    038        }
    039        else
    040        {
    041            return false;
    042        }
    043    }
    044
    045    @SideOnly(Side.CLIENT)
    046
    047    /**
    048     * allows items to add custom lines of information to the mouseover description
    049     */
    050    public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
    051    {
    052        if (par1ItemStack.hasTagCompound())
    053        {
    054            NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("Fireworks");
    055
    056            if (nbttagcompound != null)
    057            {
    058                if (nbttagcompound.hasKey("Flight"))
    059                {
    060                    par3List.add(StatCollector.translateToLocal("item.fireworks.flight") + " " + nbttagcompound.getByte("Flight"));
    061                }
    062
    063                NBTTagList nbttaglist = nbttagcompound.getTagList("Explosions");
    064
    065                if (nbttaglist != null && nbttaglist.tagCount() > 0)
    066                {
    067                    for (int i = 0; i < nbttaglist.tagCount(); ++i)
    068                    {
    069                        NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
    070                        ArrayList arraylist = new ArrayList();
    071                        ItemFireworkCharge.func_92107_a(nbttagcompound1, arraylist);
    072
    073                        if (arraylist.size() > 0)
    074                        {
    075                            for (int j = 1; j < arraylist.size(); ++j)
    076                            {
    077                                arraylist.set(j, "  " + (String)arraylist.get(j));
    078                            }
    079
    080                            par3List.addAll(arraylist);
    081                        }
    082                    }
    083                }
    084            }
    085        }
    086    }
    087}