ItemColored .java

net.minecraft.item.ItemColored (class, 59 lines): members: setSubtypeNames, coloredBlock, subtypeNames, getColorFromItemStack, getMetadata. imports: Block.

net.minecraft.itemclass59 linescommonextends ItemBlock1.6 KB

API Surface (4)

int getColorFromItemStack(ItemStack stack, int renderPass)
int getMetadata(int damage)
ItemColored setSubtypeNames(String[] names)
String getUnlocalizedName(ItemStack stack)

Fields & Constants (2)

coloredBlock
subtypeNames

Code Graph: Dependencies (3)

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

Full Source

ItemColored.java59 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item;
2
3
import net.minecraft.block.Block;
4
5
public class ItemColored extends ItemBlock
6
{
7
    private final Block coloredBlock;
8
    private String[] subtypeNames;
9
10
    public ItemColored(Block block, boolean hasSubtypes)
11
    {
12
        super(block);
13
        this.coloredBlock = block;
14
15
        if (hasSubtypes)
16
        {
17
            this.setMaxDamage(0);
18
            this.setHasSubtypes(true);
19
        }
20
    }
21
22
    public int getColorFromItemStack(ItemStack stack, int renderPass)
23
    {
24
        return this.coloredBlock.getRenderColor(this.coloredBlock.getStateFromMeta(stack.getMetadata()));
25
    }
26
27
    /**
28
     * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is
29
     * placed as a Block (mostly used with ItemBlocks).
30
     */
31
    public int getMetadata(int damage)
32
    {
33
        return damage;
34
    }
35
36
    public ItemColored setSubtypeNames(String[] names)
37
    {
38
        this.subtypeNames = names;
39
        return this;
40
    }
41
42
    /**
43
     * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have
44
     * different names based on their damage or NBT.
45
     */
46
    public String getUnlocalizedName(ItemStack stack)
47
    {
48
        if (this.subtypeNames == null)
49
        {
50
            return super.getUnlocalizedName(stack);
51
        }
52
        else
53
        {
54
            int i = stack.getMetadata();
55
            return i >= 0 && i < this.subtypeNames.length ? super.getUnlocalizedName(stack) + "." + this.subtypeNames[i] : super.getUnlocalizedName(stack);
56
        }
57
    }
58
}
59

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