    001    package net.minecraft.item;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import java.util.List;
    006    import net.minecraft.entity.player.EntityPlayer;
    007    import net.minecraft.nbt.NBTBase;
    008    import net.minecraft.nbt.NBTTagCompound;
    009    import net.minecraft.nbt.NBTTagIntArray;
    010    import net.minecraft.util.StatCollector;
    011
    012    public class ItemFireworkCharge extends Item
    013    {
    014        public ItemFireworkCharge(int par1)
    015        {
    016            super(par1);
    017        }
    018
    019        @SideOnly(Side.CLIENT)
    020
    021        /**
    022         * Gets an icon index based on an item's damage value and the given render pass
    023         */
    024        public int getIconFromDamageForRenderPass(int par1, int par2)
    025        {
    026            return par2 == 1 ? this.iconIndex + 1 : super.getIconFromDamageForRenderPass(par1, par2);
    027        }
    028
    029        @SideOnly(Side.CLIENT)
    030        public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
    031        {
    032            if (par2 != 1)
    033            {
    034                return super.getColorFromItemStack(par1ItemStack, par2);
    035            }
    036            else
    037            {
    038                NBTBase var3 = func_92108_a(par1ItemStack, "Colors");
    039
    040                if (var3 == null)
    041                {
    042                    return 9079434;
    043                }
    044                else
    045                {
    046                    NBTTagIntArray var4 = (NBTTagIntArray)var3;
    047
    048                    if (var4.intArray.length == 1)
    049                    {
    050                        return var4.intArray[0];
    051                    }
    052                    else
    053                    {
    054                        int var5 = 0;
    055                        int var6 = 0;
    056                        int var7 = 0;
    057                        int[] var8 = var4.intArray;
    058                        int var9 = var8.length;
    059
    060                        for (int var10 = 0; var10 < var9; ++var10)
    061                        {
    062                            int var11 = var8[var10];
    063                            var5 += (var11 & 16711680) >> 16;
    064                            var6 += (var11 & 65280) >> 8;
    065                            var7 += (var11 & 255) >> 0;
    066                        }
    067
    068                        var5 /= var4.intArray.length;
    069                        var6 /= var4.intArray.length;
    070                        var7 /= var4.intArray.length;
    071                        return var5 << 16 | var6 << 8 | var7;
    072                    }
    073                }
    074            }
    075        }
    076
    077        @SideOnly(Side.CLIENT)
    078        public boolean requiresMultipleRenderPasses()
    079        {
    080            return true;
    081        }
    082
    083        @SideOnly(Side.CLIENT)
    084        public static NBTBase func_92108_a(ItemStack par0ItemStack, String par1Str)
    085        {
    086            if (par0ItemStack.hasTagCompound())
    087            {
    088                NBTTagCompound var2 = par0ItemStack.getTagCompound().getCompoundTag("Explosion");
    089
    090                if (var2 != null)
    091                {
    092                    return var2.getTag(par1Str);
    093                }
    094            }
    095
    096            return null;
    097        }
    098
    099        @SideOnly(Side.CLIENT)
    100
    101        /**
    102         * allows items to add custom lines of information to the mouseover description
    103         */
    104        public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
    105        {
    106            if (par1ItemStack.hasTagCompound())
    107            {
    108                NBTTagCompound var5 = par1ItemStack.getTagCompound().getCompoundTag("Explosion");
    109
    110                if (var5 != null)
    111                {
    112                    func_92107_a(var5, par3List);
    113                }
    114            }
    115        }
    116
    117        @SideOnly(Side.CLIENT)
    118        public static void func_92107_a(NBTTagCompound par0NBTTagCompound, List par1List)
    119        {
    120            byte var2 = par0NBTTagCompound.getByte("Type");
    121
    122            if (var2 >= 0 && var2 <= 4)
    123            {
    124                par1List.add(StatCollector.translateToLocal("item.fireworksCharge.type." + var2).trim());
    125            }
    126            else
    127            {
    128                par1List.add(StatCollector.translateToLocal("item.fireworksCharge.type").trim());
    129            }
    130
    131            int[] var3 = par0NBTTagCompound.getIntArray("Colors");
    132            int var8;
    133            int var9;
    134
    135            if (var3.length > 0)
    136            {
    137                boolean var4 = true;
    138                String var5 = "";
    139                int[] var6 = var3;
    140                int var7 = var3.length;
    141
    142                for (var8 = 0; var8 < var7; ++var8)
    143                {
    144                    var9 = var6[var8];
    145
    146                    if (!var4)
    147                    {
    148                        var5 = var5 + ", ";
    149                    }
    150
    151                    var4 = false;
    152                    boolean var10 = false;
    153
    154                    for (int var11 = 0; var11 < 16; ++var11)
    155                    {
    156                        if (var9 == ItemDye.dyeColors[var11])
    157                        {
    158                            var10 = true;
    159                            var5 = var5 + StatCollector.translateToLocal("item.fireworksCharge." + ItemDye.dyeColorNames[var11]);
    160                            break;
    161                        }
    162                    }
    163
    164                    if (!var10)
    165                    {
    166                        var5 = var5 + StatCollector.translateToLocal("item.fireworksCharge.customColor");
    167                    }
    168                }
    169
    170                par1List.add(var5);
    171            }
    172
    173            int[] var13 = par0NBTTagCompound.getIntArray("FadeColors");
    174            boolean var16;
    175
    176            if (var13.length > 0)
    177            {
    178                var16 = true;
    179                String var14 = StatCollector.translateToLocal("item.fireworksCharge.fadeTo") + " ";
    180                int[] var15 = var13;
    181                var8 = var13.length;
    182
    183                for (var9 = 0; var9 < var8; ++var9)
    184                {
    185                    int var18 = var15[var9];
    186
    187                    if (!var16)
    188                    {
    189                        var14 = var14 + ", ";
    190                    }
    191
    192                    var16 = false;
    193                    boolean var19 = false;
    194
    195                    for (int var12 = 0; var12 < 16; ++var12)
    196                    {
    197                        if (var18 == ItemDye.dyeColors[var12])
    198                        {
    199                            var19 = true;
    200                            var14 = var14 + StatCollector.translateToLocal("item.fireworksCharge." + ItemDye.dyeColorNames[var12]);
    201                            break;
    202                        }
    203                    }
    204
    205                    if (!var19)
    206                    {
    207                        var14 = var14 + StatCollector.translateToLocal("item.fireworksCharge.customColor");
    208                    }
    209                }
    210
    211                par1List.add(var14);
    212            }
    213
    214            var16 = par0NBTTagCompound.getBoolean("Trail");
    215
    216            if (var16)
    217            {
    218                par1List.add(StatCollector.translateToLocal("item.fireworksCharge.trail"));
    219            }
    220
    221            boolean var17 = par0NBTTagCompound.getBoolean("Flicker");
    222
    223            if (var17)
    224            {
    225                par1List.add(StatCollector.translateToLocal("item.fireworksCharge.flicker"));
    226            }
    227        }
    228    }