BlockColored .java

net.minecraft.block.BlockColored (class): members: COLOR, damageDropped, getSubBlocks, getMapColor, getStateFromMeta, createBlockState, getMetaFromState.

net.minecraft.blockclass75 linescommonextends Block2.3 KB

API Surface (6)

int damageDropped(IBlockState state)
void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
MapColor getMapColor(IBlockState state)
IBlockState getStateFromMeta(int meta)
int getMetaFromState(IBlockState state)
BlockState createBlockState()

Fields & Constants (1)

COLOR

String literals (1)

"color"

Full Source

BlockColored.java75 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.EnumDyeColor;
12
import net.minecraft.item.Item;
13
import net.minecraft.item.ItemStack;
14
15
public class BlockColored extends Block
16
{
17
    public static final PropertyEnum<EnumDyeColor> COLOR = PropertyEnum.<EnumDyeColor>create("color", EnumDyeColor.class);
18
19
    public BlockColored(Material materialIn)
20
    {
21
        super(materialIn);
22
        this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumDyeColor.WHITE));
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 ((EnumDyeColor)state.getValue(COLOR)).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 (EnumDyeColor enumdyecolor : EnumDyeColor.values())
41
        {
42
            list.add(new ItemStack(itemIn, 1, enumdyecolor.getMetadata()));
43
        }
44
    }
45
46
    /**
47
     * Get the MapColor for this Block and the given BlockState
48
     */
49
    public MapColor getMapColor(IBlockState state)
50
    {
51
        return ((EnumDyeColor)state.getValue(COLOR)).getMapColor();
52
    }
53
54
    /**
55
     * Convert the given metadata into a BlockState for this Block
56
     */
57
    public IBlockState getStateFromMeta(int meta)
58
    {
59
        return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta));
60
    }
61
62
    /**
63
     * Convert the BlockState into the correct metadata value
64
     */
65
    public int getMetaFromState(IBlockState state)
66
    {
67
        return ((EnumDyeColor)state.getValue(COLOR)).getMetadata();
68
    }
69
70
    protected BlockState createBlockState()
71
    {
72
        return new BlockState(this, new IProperty[] {COLOR});
73
    }
74
}
75

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