ItemMultiTexture .java

net.minecraft.item.ItemMultiTexture (class, 56 lines): members: nameFunction, theBlock, getMetadata, getUnlocalizedName. imports: Function, Block.

net.minecraft.itemclass56 linescommonextends ItemBlock1.6 KB

API Surface (3)

String apply(ItemStack p_apply_1_)
int getMetadata(int damage)
String getUnlocalizedName(ItemStack stack)

Fields & Constants (2)

theBlock
nameFunction

Code Graph: Dependencies (3)

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

Full Source

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

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