BlockQuartz .java

net.minecraft.block.BlockQuartz (class): members: createStackedBlock, EnumType, VARIANT, damageDropped, onBlockPlaced, getSubBlocks, getMapColor.

net.minecraft.blockclass165 linescommonextends Block5.8 KB

API Surface (12)

IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
int damageDropped(IBlockState state)
ItemStack createStackedBlock(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()
int getMetadata()
String toString()
BlockQuartz.EnumType byMetadata(int meta)
String getName()

Fields & Constants (1)

VARIANT

String literals (7)

"variant"
"default"
"chiseled"
"lines_y"
"lines"
"lines_x"
"lines_z"

Full Source

BlockQuartz.java165 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.entity.EntityLivingBase;
12
import net.minecraft.item.Item;
13
import net.minecraft.item.ItemStack;
14
import net.minecraft.util.BlockPos;
15
import net.minecraft.util.EnumFacing;
16
import net.minecraft.util.IStringSerializable;
17
import net.minecraft.world.World;
18
19
public class BlockQuartz extends Block
20
{
21
    public static final PropertyEnum<BlockQuartz.EnumType> VARIANT = PropertyEnum.<BlockQuartz.EnumType>create("variant", BlockQuartz.EnumType.class);
22
23
    public BlockQuartz()
24
    {
25
        super(Material.rock);
26
        this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockQuartz.EnumType.DEFAULT));
27
        this.setCreativeTab(CreativeTabs.tabBlock);
28
    }
29
30
    /**
31
     * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
32
     * IBlockstate
33
     */
34
    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
35
    {
36
        if (meta == BlockQuartz.EnumType.LINES_Y.getMetadata())
37
        {
38
            switch (facing.getAxis())
39
            {
40
                case Z:
41
                    return this.getDefaultState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_Z);
42
43
                case X:
44
                    return this.getDefaultState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_X);
45
46
                case Y:
47
                default:
48
                    return this.getDefaultState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_Y);
49
            }
50
        }
51
        else
52
        {
53
            return meta == BlockQuartz.EnumType.CHISELED.getMetadata() ? this.getDefaultState().withProperty(VARIANT, BlockQuartz.EnumType.CHISELED) : this.getDefaultState().withProperty(VARIANT, BlockQuartz.EnumType.DEFAULT);
54
        }
55
    }
56
57
    /**
58
     * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
59
     * returns the metadata of the dropped item based on the old metadata of the block.
60
     */
61
    public int damageDropped(IBlockState state)
62
    {
63
        BlockQuartz.EnumType blockquartz$enumtype = (BlockQuartz.EnumType)state.getValue(VARIANT);
64
        return blockquartz$enumtype != BlockQuartz.EnumType.LINES_X && blockquartz$enumtype != BlockQuartz.EnumType.LINES_Z ? blockquartz$enumtype.getMetadata() : BlockQuartz.EnumType.LINES_Y.getMetadata();
65
    }
66
67
    protected ItemStack createStackedBlock(IBlockState state)
68
    {
69
        BlockQuartz.EnumType blockquartz$enumtype = (BlockQuartz.EnumType)state.getValue(VARIANT);
70
        return blockquartz$enumtype != BlockQuartz.EnumType.LINES_X && blockquartz$enumtype != BlockQuartz.EnumType.LINES_Z ? super.createStackedBlock(state) : new ItemStack(Item.getItemFromBlock(this), 1, BlockQuartz.EnumType.LINES_Y.getMetadata());
71
    }
72
73
    /**
74
     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
75
     */
76
    public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
77
    {
78
        list.add(new ItemStack(itemIn, 1, BlockQuartz.EnumType.DEFAULT.getMetadata()));
79
        list.add(new ItemStack(itemIn, 1, BlockQuartz.EnumType.CHISELED.getMetadata()));
80
        list.add(new ItemStack(itemIn, 1, BlockQuartz.EnumType.LINES_Y.getMetadata()));
81
    }
82
83
    /**
84
     * Get the MapColor for this Block and the given BlockState
85
     */
86
    public MapColor getMapColor(IBlockState state)
87
    {
88
        return MapColor.quartzColor;
89
    }
90
91
    /**
92
     * Convert the given metadata into a BlockState for this Block
93
     */
94
    public IBlockState getStateFromMeta(int meta)
95
    {
96
        return this.getDefaultState().withProperty(VARIANT, BlockQuartz.EnumType.byMetadata(meta));
97
    }
98
99
    /**
100
     * Convert the BlockState into the correct metadata value
101
     */
102
    public int getMetaFromState(IBlockState state)
103
    {
104
        return ((BlockQuartz.EnumType)state.getValue(VARIANT)).getMetadata();
105
    }
106
107
    protected BlockState createBlockState()
108
    {
109
        return new BlockState(this, new IProperty[] {VARIANT});
110
    }
111
112
    public static enum EnumType implements IStringSerializable
113
    {
114
        DEFAULT(0, "default", "default"),
115
        CHISELED(1, "chiseled", "chiseled"),
116
        LINES_Y(2, "lines_y", "lines"),
117
        LINES_X(3, "lines_x", "lines"),
118
        LINES_Z(4, "lines_z", "lines");
119
120
        private static final BlockQuartz.EnumType[] META_LOOKUP = new BlockQuartz.EnumType[values().length];
121
        private final int meta;
122
        private final String field_176805_h;
123
        private final String unlocalizedName;
124
125
        private EnumType(int meta, String name, String unlocalizedName)
126
        {
127
            this.meta = meta;
128
            this.field_176805_h = name;
129
            this.unlocalizedName = unlocalizedName;
130
        }
131
132
        public int getMetadata()
133
        {
134
            return this.meta;
135
        }
136
137
        public String toString()
138
        {
139
            return this.unlocalizedName;
140
        }
141
142
        public static BlockQuartz.EnumType byMetadata(int meta)
143
        {
144
            if (meta < 0 || meta >= META_LOOKUP.length)
145
            {
146
                meta = 0;
147
            }
148
149
            return META_LOOKUP[meta];
150
        }
151
152
        public String getName()
153
        {
154
            return this.field_176805_h;
155
        }
156
157
        static {
158
            for (BlockQuartz.EnumType blockquartz$enumtype : values())
159
            {
160
                META_LOOKUP[blockquartz$enumtype.getMetadata()] = blockquartz$enumtype;
161
            }
162
        }
163
    }
164
}
165

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