    001    package net.minecraft.item;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import java.util.ArrayList;
    006    import java.util.List;
    007    import net.minecraft.entity.item.EntityFireworkRocket;
    008    import net.minecraft.entity.player.EntityPlayer;
    009    import net.minecraft.nbt.NBTTagCompound;
    010    import net.minecraft.nbt.NBTTagList;
    011    import net.minecraft.util.StatCollector;
    012    import net.minecraft.world.World;
    013
    014    public 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 var11 = new EntityFireworkRocket(par3World, (double)((float)par4 + par8), (double)((float)par5 + par9), (double)((float)par6 + par10), par1ItemStack);
    030                par3World.spawnEntityInWorld(var11);
    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 var5 = par1ItemStack.getTagCompound().getCompoundTag("Fireworks");
    055
    056                if (var5 != null)
    057                {
    058                    if (var5.hasKey("Flight"))
    059                    {
    060                        par3List.add(StatCollector.translateToLocal("item.fireworks.flight") + " " + var5.getByte("Flight"));
    061                    }
    062
    063                    NBTTagList var6 = var5.getTagList("Explosions");
    064
    065                    if (var6 != null && var6.tagCount() > 0)
    066                    {
    067                        for (int var7 = 0; var7 < var6.tagCount(); ++var7)
    068                        {
    069                            NBTTagCompound var8 = (NBTTagCompound)var6.tagAt(var7);
    070                            ArrayList var9 = new ArrayList();
    071                            ItemFireworkCharge.func_92107_a(var8, var9);
    072
    073                            if (var9.size() > 0)
    074                            {
    075                                for (int var10 = 1; var10 < var9.size(); ++var10)
    076                                {
    077                                    var9.set(var10, "  " + (String)var9.get(var10));
    078                                }
    079
    080                                par3List.addAll(var9);
    081                            }
    082                        }
    083                    }
    084                }
    085            }
    086        }
    087    }