BlockHugeMushroom .java

net.minecraft.block.BlockHugeMushroom (class, 161 lines): members: smallBlock, EnumType, VARIANT, quantityDropped, onBlockPlaced, getMapColor, getItem.

net.minecraft.blockclass161 linescommonextends Block4.7 KB

API Surface (12)

int quantityDropped(Random random)
MapColor getMapColor(IBlockState state)
Item getItemDropped(IBlockState state, Random rand, int fortune)
Item getItem(World worldIn, BlockPos pos)
IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
IBlockState getStateFromMeta(int meta)
int getMetaFromState(IBlockState state)
BlockState createBlockState()
int getMetadata()
String toString()
BlockHugeMushroom.EnumType byMetadata(int meta)
String getName()

Fields & Constants (2)

VARIANT
smallBlock

String literals (14)

"variant"
"north_west"
"north"
"north_east"
"west"
"center"
"east"
"south_west"
"south"
"south_east"
"stem"
"all_inside"
"all_outside"
"all_stem"

Full Source

BlockHugeMushroom.java161 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import java.util.Random;
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.entity.EntityLivingBase;
11
import net.minecraft.item.Item;
12
import net.minecraft.util.BlockPos;
13
import net.minecraft.util.EnumFacing;
14
import net.minecraft.util.IStringSerializable;
15
import net.minecraft.world.World;
16
17
public class BlockHugeMushroom extends Block
18
{
19
    public static final PropertyEnum<BlockHugeMushroom.EnumType> VARIANT = PropertyEnum.<BlockHugeMushroom.EnumType>create("variant", BlockHugeMushroom.EnumType.class);
20
    private final Block smallBlock;
21
22
    public BlockHugeMushroom(Material p_i46392_1_, MapColor p_i46392_2_, Block p_i46392_3_)
23
    {
24
        super(p_i46392_1_, p_i46392_2_);
25
        this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockHugeMushroom.EnumType.ALL_OUTSIDE));
26
        this.smallBlock = p_i46392_3_;
27
    }
28
29
    /**
30
     * Returns the quantity of items to drop on block destruction.
31
     */
32
    public int quantityDropped(Random random)
33
    {
34
        return Math.max(0, random.nextInt(10) - 7);
35
    }
36
37
    /**
38
     * Get the MapColor for this Block and the given BlockState
39
     */
40
    public MapColor getMapColor(IBlockState state)
41
    {
42
        switch ((BlockHugeMushroom.EnumType)state.getValue(VARIANT))
43
        {
44
            case ALL_STEM:
45
                return MapColor.clothColor;
46
47
            case ALL_INSIDE:
48
                return MapColor.sandColor;
49
50
            case STEM:
51
                return MapColor.sandColor;
52
53
            default:
54
                return super.getMapColor(state);
55
        }
56
    }
57
58
    /**
59
     * Get the Item that this Block should drop when harvested.
60
     */
61
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
62
    {
63
        return Item.getItemFromBlock(this.smallBlock);
64
    }
65
66
    public Item getItem(World worldIn, BlockPos pos)
67
    {
68
        return Item.getItemFromBlock(this.smallBlock);
69
    }
70
71
    /**
72
     * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
73
     * IBlockstate
74
     */
75
    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
76
    {
77
        return this.getDefaultState();
78
    }
79
80
    /**
81
     * Convert the given metadata into a BlockState for this Block
82
     */
83
    public IBlockState getStateFromMeta(int meta)
84
    {
85
        return this.getDefaultState().withProperty(VARIANT, BlockHugeMushroom.EnumType.byMetadata(meta));
86
    }
87
88
    /**
89
     * Convert the BlockState into the correct metadata value
90
     */
91
    public int getMetaFromState(IBlockState state)
92
    {
93
        return ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)).getMetadata();
94
    }
95
96
    protected BlockState createBlockState()
97
    {
98
        return new BlockState(this, new IProperty[] {VARIANT});
99
    }
100
101
    public static enum EnumType implements IStringSerializable
102
    {
103
        NORTH_WEST(1, "north_west"),
104
        NORTH(2, "north"),
105
        NORTH_EAST(3, "north_east"),
106
        WEST(4, "west"),
107
        CENTER(5, "center"),
108
        EAST(6, "east"),
109
        SOUTH_WEST(7, "south_west"),
110
        SOUTH(8, "south"),
111
        SOUTH_EAST(9, "south_east"),
112
        STEM(10, "stem"),
113
        ALL_INSIDE(0, "all_inside"),
114
        ALL_OUTSIDE(14, "all_outside"),
115
        ALL_STEM(15, "all_stem");
116
117
        private static final BlockHugeMushroom.EnumType[] META_LOOKUP = new BlockHugeMushroom.EnumType[16];
118
        private final int meta;
119
        private final String name;
120
121
        private EnumType(int meta, String name)
122
        {
123
            this.meta = meta;
124
            this.name = name;
125
        }
126
127
        public int getMetadata()
128
        {
129
            return this.meta;
130
        }
131
132
        public String toString()
133
        {
134
            return this.name;
135
        }
136
137
        public static BlockHugeMushroom.EnumType byMetadata(int meta)
138
        {
139
            if (meta < 0 || meta >= META_LOOKUP.length)
140
            {
141
                meta = 0;
142
            }
143
144
            BlockHugeMushroom.EnumType blockhugemushroom$enumtype = META_LOOKUP[meta];
145
            return blockhugemushroom$enumtype == null ? META_LOOKUP[0] : blockhugemushroom$enumtype;
146
        }
147
148
        public String getName()
149
        {
150
            return this.name;
151
        }
152
153
        static {
154
            for (BlockHugeMushroom.EnumType blockhugemushroom$enumtype : values())
155
            {
156
                META_LOOKUP[blockhugemushroom$enumtype.getMetadata()] = blockhugemushroom$enumtype;
157
            }
158
        }
159
    }
160
}
161

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