BlockFlower .java

net.minecraft.block.BlockFlower (class): members: EnumFlowerColor, getTypeProperty, EnumFlowerType, getOffsetType, getBlockType, type, damageDropped.

net.minecraft.blockclass197 linescommonextends BlockBush6.9 KB

API Surface (17)

int damageDropped(IBlockState state)
void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
IBlockState getStateFromMeta(int meta)
IProperty<BlockFlower.EnumFlowerType> getTypeProperty()
boolean apply(BlockFlower.EnumFlowerType p_apply_1_)
int getMetaFromState(IBlockState state)
BlockState createBlockState()
Block.EnumOffsetType getOffsetType()
BlockFlower getBlock()
BlockFlower.EnumFlowerColor getBlockType()
int getMeta()
BlockFlower.EnumFlowerType getType(BlockFlower.EnumFlowerColor blockType, int meta)
BlockFlower.EnumFlowerType[] getTypes(BlockFlower.EnumFlowerColor flowerColor)
String toString()
String getName()
String getUnlocalizedName()
boolean apply(BlockFlower.EnumFlowerType p_apply_1_)

Fields & Constants (1)

type

String literals (16)

"dandelion"
"poppy"
"blue_orchid"
"blueOrchid"
"allium"
"houstonia"
"red_tulip"
"tulipRed"
"orange_tulip"
"tulipOrange"
"white_tulip"
"tulipWhite"
"pink_tulip"
"tulipPink"
"oxeye_daisy"
"oxeyeDaisy"

Full Source

BlockFlower.java197 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import com.google.common.base.Predicate;
4
import com.google.common.collect.Collections2;
5
import com.google.common.collect.Lists;
6
import java.util.Collection;
7
import java.util.List;
8
import net.minecraft.block.properties.IProperty;
9
import net.minecraft.block.properties.PropertyEnum;
10
import net.minecraft.block.state.BlockState;
11
import net.minecraft.block.state.IBlockState;
12
import net.minecraft.creativetab.CreativeTabs;
13
import net.minecraft.init.Blocks;
14
import net.minecraft.item.Item;
15
import net.minecraft.item.ItemStack;
16
import net.minecraft.util.IStringSerializable;
17
18
public abstract class BlockFlower extends BlockBush
19
{
20
    protected PropertyEnum<BlockFlower.EnumFlowerType> type;
21
22
    protected BlockFlower()
23
    {
24
        this.setDefaultState(this.blockState.getBaseState().withProperty(this.getTypeProperty(), this.getBlockType() == BlockFlower.EnumFlowerColor.RED ? BlockFlower.EnumFlowerType.POPPY : BlockFlower.EnumFlowerType.DANDELION));
25
    }
26
27
    /**
28
     * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
29
     * returns the metadata of the dropped item based on the old metadata of the block.
30
     */
31
    public int damageDropped(IBlockState state)
32
    {
33
        return ((BlockFlower.EnumFlowerType)state.getValue(this.getTypeProperty())).getMeta();
34
    }
35
36
    /**
37
     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
38
     */
39
    public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
40
    {
41
        for (BlockFlower.EnumFlowerType blockflower$enumflowertype : BlockFlower.EnumFlowerType.getTypes(this.getBlockType()))
42
        {
43
            list.add(new ItemStack(itemIn, 1, blockflower$enumflowertype.getMeta()));
44
        }
45
    }
46
47
    /**
48
     * Convert the given metadata into a BlockState for this Block
49
     */
50
    public IBlockState getStateFromMeta(int meta)
51
    {
52
        return this.getDefaultState().withProperty(this.getTypeProperty(), BlockFlower.EnumFlowerType.getType(this.getBlockType(), meta));
53
    }
54
55
    /**
56
     * Get the Type of this flower (Yellow/Red)
57
     */
58
    public abstract BlockFlower.EnumFlowerColor getBlockType();
59
60
    public IProperty<BlockFlower.EnumFlowerType> getTypeProperty()
61
    {
62
        if (this.type == null)
63
        {
64
            this.type = PropertyEnum.<BlockFlower.EnumFlowerType>create("type", BlockFlower.EnumFlowerType.class, new Predicate<BlockFlower.EnumFlowerType>()
65
            {
66
                public boolean apply(BlockFlower.EnumFlowerType p_apply_1_)
67
                {
68
                    return p_apply_1_.getBlockType() == BlockFlower.this.getBlockType();
69
                }
70
            });
71
        }
72
73
        return this.type;
74
    }
75
76
    /**
77
     * Convert the BlockState into the correct metadata value
78
     */
79
    public int getMetaFromState(IBlockState state)
80
    {
81
        return ((BlockFlower.EnumFlowerType)state.getValue(this.getTypeProperty())).getMeta();
82
    }
83
84
    protected BlockState createBlockState()
85
    {
86
        return new BlockState(this, new IProperty[] {this.getTypeProperty()});
87
    }
88
89
    /**
90
     * Get the OffsetType for this Block. Determines if the model is rendered slightly offset.
91
     */
92
    public Block.EnumOffsetType getOffsetType()
93
    {
94
        return Block.EnumOffsetType.XZ;
95
    }
96
97
    public static enum EnumFlowerColor
98
    {
99
        YELLOW,
100
        RED;
101
102
        public BlockFlower getBlock()
103
        {
104
            return this == YELLOW ? Blocks.yellow_flower : Blocks.red_flower;
105
        }
106
    }
107
108
    public static enum EnumFlowerType implements IStringSerializable
109
    {
110
        DANDELION(BlockFlower.EnumFlowerColor.YELLOW, 0, "dandelion"),
111
        POPPY(BlockFlower.EnumFlowerColor.RED, 0, "poppy"),
112
        BLUE_ORCHID(BlockFlower.EnumFlowerColor.RED, 1, "blue_orchid", "blueOrchid"),
113
        ALLIUM(BlockFlower.EnumFlowerColor.RED, 2, "allium"),
114
        HOUSTONIA(BlockFlower.EnumFlowerColor.RED, 3, "houstonia"),
115
        RED_TULIP(BlockFlower.EnumFlowerColor.RED, 4, "red_tulip", "tulipRed"),
116
        ORANGE_TULIP(BlockFlower.EnumFlowerColor.RED, 5, "orange_tulip", "tulipOrange"),
117
        WHITE_TULIP(BlockFlower.EnumFlowerColor.RED, 6, "white_tulip", "tulipWhite"),
118
        PINK_TULIP(BlockFlower.EnumFlowerColor.RED, 7, "pink_tulip", "tulipPink"),
119
        OXEYE_DAISY(BlockFlower.EnumFlowerColor.RED, 8, "oxeye_daisy", "oxeyeDaisy");
120
121
        private static final BlockFlower.EnumFlowerType[][] TYPES_FOR_BLOCK = new BlockFlower.EnumFlowerType[BlockFlower.EnumFlowerColor.values().length][];
122
        private final BlockFlower.EnumFlowerColor blockType;
123
        private final int meta;
124
        private final String name;
125
        private final String unlocalizedName;
126
127
        private EnumFlowerType(BlockFlower.EnumFlowerColor blockType, int meta, String name)
128
        {
129
            this(blockType, meta, name, name);
130
        }
131
132
        private EnumFlowerType(BlockFlower.EnumFlowerColor blockType, int meta, String name, String unlocalizedName)
133
        {
134
            this.blockType = blockType;
135
            this.meta = meta;
136
            this.name = name;
137
            this.unlocalizedName = unlocalizedName;
138
        }
139
140
        public BlockFlower.EnumFlowerColor getBlockType()
141
        {
142
            return this.blockType;
143
        }
144
145
        public int getMeta()
146
        {
147
            return this.meta;
148
        }
149
150
        public static BlockFlower.EnumFlowerType getType(BlockFlower.EnumFlowerColor blockType, int meta)
151
        {
152
            BlockFlower.EnumFlowerType[] ablockflower$enumflowertype = TYPES_FOR_BLOCK[blockType.ordinal()];
153
154
            if (meta < 0 || meta >= ablockflower$enumflowertype.length)
155
            {
156
                meta = 0;
157
            }
158
159
            return ablockflower$enumflowertype[meta];
160
        }
161
162
        public static BlockFlower.EnumFlowerType[] getTypes(BlockFlower.EnumFlowerColor flowerColor)
163
        {
164
            return TYPES_FOR_BLOCK[flowerColor.ordinal()];
165
        }
166
167
        public String toString()
168
        {
169
            return this.name;
170
        }
171
172
        public String getName()
173
        {
174
            return this.name;
175
        }
176
177
        public String getUnlocalizedName()
178
        {
179
            return this.unlocalizedName;
180
        }
181
182
        static {
183
            for (final BlockFlower.EnumFlowerColor blockflower$enumflowercolor : BlockFlower.EnumFlowerColor.values())
184
            {
185
                Collection<BlockFlower.EnumFlowerType> collection = Collections2.<BlockFlower.EnumFlowerType>filter(Lists.newArrayList(values()), new Predicate<BlockFlower.EnumFlowerType>()
186
                {
187
                    public boolean apply(BlockFlower.EnumFlowerType p_apply_1_)
188
                    {
189
                        return p_apply_1_.getBlockType() == blockflower$enumflowercolor;
190
                    }
191
                });
192
                TYPES_FOR_BLOCK[blockflower$enumflowercolor.ordinal()] = (BlockFlower.EnumFlowerType[])collection.toArray(new BlockFlower.EnumFlowerType[collection.size()]);
193
            }
194
        }
195
    }
196
}
197

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