ItemFirework .java

net.minecraft.item.ItemFirework (class): members: addInformation, onItemUse. strings: "item.fireworks.flight", "Explosions", "Fireworks", "Flight".

net.minecraft.itemclass80 linescommonextends Item2.7 KB

API Surface (2)

boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)

String literals (4)

"Fireworks"
"Flight"
"item.fireworks.flight"
"Explosions"

Full Source

ItemFirework.java80 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item;
2
3
import com.google.common.collect.Lists;
4
import java.util.List;
5
import net.minecraft.entity.item.EntityFireworkRocket;
6
import net.minecraft.entity.player.EntityPlayer;
7
import net.minecraft.nbt.NBTTagCompound;
8
import net.minecraft.nbt.NBTTagList;
9
import net.minecraft.util.BlockPos;
10
import net.minecraft.util.EnumFacing;
11
import net.minecraft.util.StatCollector;
12
import net.minecraft.world.World;
13
14
public class ItemFirework extends Item
15
{
16
    /**
17
     * Called when a Block is right-clicked with this Item
18
     */
19
    public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
20
    {
21
        if (!worldIn.isRemote)
22
        {
23
            EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(worldIn, (double)((float)pos.getX() + hitX), (double)((float)pos.getY() + hitY), (double)((float)pos.getZ() + hitZ), stack);
24
            worldIn.spawnEntityInWorld(entityfireworkrocket);
25
26
            if (!playerIn.capabilities.isCreativeMode)
27
            {
28
                --stack.stackSize;
29
            }
30
31
            return true;
32
        }
33
        else
34
        {
35
            return false;
36
        }
37
    }
38
39
    /**
40
     * allows items to add custom lines of information to the mouseover description
41
     */
42
    public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
43
    {
44
        if (stack.hasTagCompound())
45
        {
46
            NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Fireworks");
47
48
            if (nbttagcompound != null)
49
            {
50
                if (nbttagcompound.hasKey("Flight", 99))
51
                {
52
                    tooltip.add(StatCollector.translateToLocal("item.fireworks.flight") + " " + nbttagcompound.getByte("Flight"));
53
                }
54
55
                NBTTagList nbttaglist = nbttagcompound.getTagList("Explosions", 10);
56
57
                if (nbttaglist != null && nbttaglist.tagCount() > 0)
58
                {
59
                    for (int i = 0; i < nbttaglist.tagCount(); ++i)
60
                    {
61
                        NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
62
                        List<String> list = Lists.<String>newArrayList();
63
                        ItemFireworkCharge.addExplosionInfo(nbttagcompound1, list);
64
65
                        if (list.size() > 0)
66
                        {
67
                            for (int j = 1; j < ((List)list).size(); ++j)
68
                            {
69
                                list.set(j, "  " + (String)list.get(j));
70
                            }
71
72
                            tooltip.addAll(list);
73
                        }
74
                    }
75
                }
76
            }
77
        }
78
    }
79
}
80

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