BlockPlanks .java

net.minecraft.block.BlockPlanks (class): members: EnumType, VARIANT, damageDropped, getSubBlocks, getMapColor, getStateFromMeta, createBlockState.

net.minecraft.blockclass146 linescommonextends Block4.4 KB

API Surface (12)

int damageDropped(IBlockState state)
void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
IBlockState getStateFromMeta(int meta)
MapColor getMapColor(IBlockState state)
int getMetaFromState(IBlockState state)
BlockState createBlockState()
int getMetadata()
MapColor getMapColor()
String toString()
BlockPlanks.EnumType byMetadata(int meta)
String getName()
String getUnlocalizedName()

Fields & Constants (1)

VARIANT

String literals (7)

"variant"
"spruce"
"birch"
"jungle"
"acacia"
"dark_oak"
"big_oak"

Full Source

BlockPlanks.java146 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import java.util.List;
4
import net.minecraft.block.material.MapColor;
5
import net.minecraft.block.material.Material;
6
import net.minecraft.block.properties.IProperty;
7
import net.minecraft.block.properties.PropertyEnum;
8
import net.minecraft.block.state.BlockState;
9
import net.minecraft.block.state.IBlockState;
10
import net.minecraft.creativetab.CreativeTabs;
11
import net.minecraft.item.Item;
12
import net.minecraft.item.ItemStack;
13
import net.minecraft.util.IStringSerializable;
14
15
public class BlockPlanks extends Block
16
{
17
    public static final PropertyEnum<BlockPlanks.EnumType> VARIANT = PropertyEnum.<BlockPlanks.EnumType>create("variant", BlockPlanks.EnumType.class);
18
19
    public BlockPlanks()
20
    {
21
        super(Material.wood);
22
        this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockPlanks.EnumType.OAK));
23
        this.setCreativeTab(CreativeTabs.tabBlock);
24
    }
25
26
    /**
27
     * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
28
     * returns the metadata of the dropped item based on the old metadata of the block.
29
     */
30
    public int damageDropped(IBlockState state)
31
    {
32
        return ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
33
    }
34
35
    /**
36
     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
37
     */
38
    public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
39
    {
40
        for (BlockPlanks.EnumType blockplanks$enumtype : BlockPlanks.EnumType.values())
41
        {
42
            list.add(new ItemStack(itemIn, 1, blockplanks$enumtype.getMetadata()));
43
        }
44
    }
45
46
    /**
47
     * Convert the given metadata into a BlockState for this Block
48
     */
49
    public IBlockState getStateFromMeta(int meta)
50
    {
51
        return this.getDefaultState().withProperty(VARIANT, BlockPlanks.EnumType.byMetadata(meta));
52
    }
53
54
    /**
55
     * Get the MapColor for this Block and the given BlockState
56
     */
57
    public MapColor getMapColor(IBlockState state)
58
    {
59
        return ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMapColor();
60
    }
61
62
    /**
63
     * Convert the BlockState into the correct metadata value
64
     */
65
    public int getMetaFromState(IBlockState state)
66
    {
67
        return ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
68
    }
69
70
    protected BlockState createBlockState()
71
    {
72
        return new BlockState(this, new IProperty[] {VARIANT});
73
    }
74
75
    public static enum EnumType implements IStringSerializable
76
    {
77
        OAK(0, "oak", MapColor.woodColor),
78
        SPRUCE(1, "spruce", MapColor.obsidianColor),
79
        BIRCH(2, "birch", MapColor.sandColor),
80
        JUNGLE(3, "jungle", MapColor.dirtColor),
81
        ACACIA(4, "acacia", MapColor.adobeColor),
82
        DARK_OAK(5, "dark_oak", "big_oak", MapColor.brownColor);
83
84
        private static final BlockPlanks.EnumType[] META_LOOKUP = new BlockPlanks.EnumType[values().length];
85
        private final int meta;
86
        private final String name;
87
        private final String unlocalizedName;
88
        private final MapColor mapColor;
89
90
        private EnumType(int p_i46388_3_, String p_i46388_4_, MapColor p_i46388_5_)
91
        {
92
            this(p_i46388_3_, p_i46388_4_, p_i46388_4_, p_i46388_5_);
93
        }
94
95
        private EnumType(int p_i46389_3_, String p_i46389_4_, String p_i46389_5_, MapColor p_i46389_6_)
96
        {
97
            this.meta = p_i46389_3_;
98
            this.name = p_i46389_4_;
99
            this.unlocalizedName = p_i46389_5_;
100
            this.mapColor = p_i46389_6_;
101
        }
102
103
        public int getMetadata()
104
        {
105
            return this.meta;
106
        }
107
108
        public MapColor getMapColor()
109
        {
110
            return this.mapColor;
111
        }
112
113
        public String toString()
114
        {
115
            return this.name;
116
        }
117
118
        public static BlockPlanks.EnumType byMetadata(int meta)
119
        {
120
            if (meta < 0 || meta >= META_LOOKUP.length)
121
            {
122
                meta = 0;
123
            }
124
125
            return META_LOOKUP[meta];
126
        }
127
128
        public String getName()
129
        {
130
            return this.name;
131
        }
132
133
        public String getUnlocalizedName()
134
        {
135
            return this.unlocalizedName;
136
        }
137
138
        static {
139
            for (BlockPlanks.EnumType blockplanks$enumtype : values())
140
            {
141
                META_LOOKUP[blockplanks$enumtype.getMetadata()] = blockplanks$enumtype;
142
            }
143
        }
144
    }
145
}
146

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