ItemFireworkCharge .java

net.minecraft.item.ItemFireworkCharge (class): members: addExplosionInfo, getExplosionTag, addInformation, getColorFromItemStack. strings: "Explosion".

net.minecraft.itemclass188 linescommonextends Item5.1 KB

API Surface (4)

int getColorFromItemStack(ItemStack stack, int renderPass)
NBTBase getExplosionTag(ItemStack stack, String key)
void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
void addExplosionInfo(NBTTagCompound nbt, List<String> tooltip)

String literals (12)

"Colors"
"Explosion"
"item.fireworksCharge.type."
"item.fireworksCharge.type"
"item.fireworksCharge."
"item.fireworksCharge.customColor"
"FadeColors"
"item.fireworksCharge.fadeTo"
"Trail"
"item.fireworksCharge.trail"
"Flicker"
"item.fireworksCharge.flicker"

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ItemFireworkCharge.java188 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item;
2
3
import java.util.List;
4
import net.minecraft.entity.player.EntityPlayer;
5
import net.minecraft.nbt.NBTBase;
6
import net.minecraft.nbt.NBTTagCompound;
7
import net.minecraft.nbt.NBTTagIntArray;
8
import net.minecraft.util.StatCollector;
9
10
public class ItemFireworkCharge extends Item
11
{
12
    public int getColorFromItemStack(ItemStack stack, int renderPass)
13
    {
14
        if (renderPass != 1)
15
        {
16
            return super.getColorFromItemStack(stack, renderPass);
17
        }
18
        else
19
        {
20
            NBTBase nbtbase = getExplosionTag(stack, "Colors");
21
22
            if (!(nbtbase instanceof NBTTagIntArray))
23
            {
24
                return 9079434;
25
            }
26
            else
27
            {
28
                NBTTagIntArray nbttagintarray = (NBTTagIntArray)nbtbase;
29
                int[] aint = nbttagintarray.getIntArray();
30
31
                if (aint.length == 1)
32
                {
33
                    return aint[0];
34
                }
35
                else
36
                {
37
                    int i = 0;
38
                    int j = 0;
39
                    int k = 0;
40
41
                    for (int l : aint)
42
                    {
43
                        i += (l & 16711680) >> 16;
44
                        j += (l & 65280) >> 8;
45
                        k += (l & 255) >> 0;
46
                    }
47
48
                    i = i / aint.length;
49
                    j = j / aint.length;
50
                    k = k / aint.length;
51
                    return i << 16 | j << 8 | k;
52
                }
53
            }
54
        }
55
    }
56
57
    public static NBTBase getExplosionTag(ItemStack stack, String key)
58
    {
59
        if (stack.hasTagCompound())
60
        {
61
            NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Explosion");
62
63
            if (nbttagcompound != null)
64
            {
65
                return nbttagcompound.getTag(key);
66
            }
67
        }
68
69
        return null;
70
    }
71
72
    /**
73
     * allows items to add custom lines of information to the mouseover description
74
     */
75
    public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
76
    {
77
        if (stack.hasTagCompound())
78
        {
79
            NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Explosion");
80
81
            if (nbttagcompound != null)
82
            {
83
                addExplosionInfo(nbttagcompound, tooltip);
84
            }
85
        }
86
    }
87
88
    public static void addExplosionInfo(NBTTagCompound nbt, List<String> tooltip)
89
    {
90
        byte b0 = nbt.getByte("Type");
91
92
        if (b0 >= 0 && b0 <= 4)
93
        {
94
            tooltip.add(StatCollector.translateToLocal("item.fireworksCharge.type." + b0).trim());
95
        }
96
        else
97
        {
98
            tooltip.add(StatCollector.translateToLocal("item.fireworksCharge.type").trim());
99
        }
100
101
        int[] aint = nbt.getIntArray("Colors");
102
103
        if (aint.length > 0)
104
        {
105
            boolean flag = true;
106
            String s = "";
107
108
            for (int i : aint)
109
            {
110
                if (!flag)
111
                {
112
                    s = s + ", ";
113
                }
114
115
                flag = false;
116
                boolean flag1 = false;
117
118
                for (int j = 0; j < ItemDye.dyeColors.length; ++j)
119
                {
120
                    if (i == ItemDye.dyeColors[j])
121
                    {
122
                        flag1 = true;
123
                        s = s + StatCollector.translateToLocal("item.fireworksCharge." + EnumDyeColor.byDyeDamage(j).getUnlocalizedName());
124
                        break;
125
                    }
126
                }
127
128
                if (!flag1)
129
                {
130
                    s = s + StatCollector.translateToLocal("item.fireworksCharge.customColor");
131
                }
132
            }
133
134
            tooltip.add(s);
135
        }
136
137
        int[] aint1 = nbt.getIntArray("FadeColors");
138
139
        if (aint1.length > 0)
140
        {
141
            boolean flag2 = true;
142
            String s1 = StatCollector.translateToLocal("item.fireworksCharge.fadeTo") + " ";
143
144
            for (int l : aint1)
145
            {
146
                if (!flag2)
147
                {
148
                    s1 = s1 + ", ";
149
                }
150
151
                flag2 = false;
152
                boolean flag5 = false;
153
154
                for (int k = 0; k < 16; ++k)
155
                {
156
                    if (l == ItemDye.dyeColors[k])
157
                    {
158
                        flag5 = true;
159
                        s1 = s1 + StatCollector.translateToLocal("item.fireworksCharge." + EnumDyeColor.byDyeDamage(k).getUnlocalizedName());
160
                        break;
161
                    }
162
                }
163
164
                if (!flag5)
165
                {
166
                    s1 = s1 + StatCollector.translateToLocal("item.fireworksCharge.customColor");
167
                }
168
            }
169
170
            tooltip.add(s1);
171
        }
172
173
        boolean flag3 = nbt.getBoolean("Trail");
174
175
        if (flag3)
176
        {
177
            tooltip.add(StatCollector.translateToLocal("item.fireworksCharge.trail"));
178
        }
179
180
        boolean flag4 = nbt.getBoolean("Flicker");
181
182
        if (flag4)
183
        {
184
            tooltip.add(StatCollector.translateToLocal("item.fireworksCharge.flicker"));
185
        }
186
    }
187
}
188

Deobfuscated MCP 1.8.9 source of ItemFireworkCharge from Marcelektro/MavenMCP-1.8.9 (net/minecraft/item/ItemFireworkCharge.java), stored verbatim.