| 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 BlockSandStone extends Block
|
| 16 | {
|
| 17 | public static final PropertyEnum<BlockSandStone.EnumType> TYPE = PropertyEnum.<BlockSandStone.EnumType>create("type", BlockSandStone.EnumType.class);
|
| 18 |
|
| 19 | public BlockSandStone()
|
| 20 | {
|
| 21 | super(Material.rock);
|
| 22 | this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, BlockSandStone.EnumType.DEFAULT));
|
| 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 ((BlockSandStone.EnumType)state.getValue(TYPE)).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 (BlockSandStone.EnumType blocksandstone$enumtype : BlockSandStone.EnumType.values())
|
| 41 | {
|
| 42 | list.add(new ItemStack(itemIn, 1, blocksandstone$enumtype.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 MapColor.sandColor;
|
| 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(TYPE, BlockSandStone.EnumType.byMetadata(meta));
|
| 60 | }
|
| 61 |
|
| 62 | /**
|
| 63 | * Convert the BlockState into the correct metadata value
|
| 64 | */
|
| 65 | public int getMetaFromState(IBlockState state)
|
| 66 | {
|
| 67 | return ((BlockSandStone.EnumType)state.getValue(TYPE)).getMetadata();
|
| 68 | }
|
| 69 |
|
| 70 | protected BlockState createBlockState()
|
| 71 | {
|
| 72 | return new BlockState(this, new IProperty[] {TYPE});
|
| 73 | }
|
| 74 |
|
| 75 | public static enum EnumType implements IStringSerializable
|
| 76 | {
|
| 77 | DEFAULT(0, "sandstone", "default"),
|
| 78 | CHISELED(1, "chiseled_sandstone", "chiseled"),
|
| 79 | SMOOTH(2, "smooth_sandstone", "smooth");
|
| 80 |
|
| 81 | private static final BlockSandStone.EnumType[] META_LOOKUP = new BlockSandStone.EnumType[values().length];
|
| 82 | private final int metadata;
|
| 83 | private final String name;
|
| 84 | private final String unlocalizedName;
|
| 85 |
|
| 86 | private EnumType(int meta, String name, String unlocalizedName)
|
| 87 | {
|
| 88 | this.metadata = meta;
|
| 89 | this.name = name;
|
| 90 | this.unlocalizedName = unlocalizedName;
|
| 91 | }
|
| 92 |
|
| 93 | public int getMetadata()
|
| 94 | {
|
| 95 | return this.metadata;
|
| 96 | }
|
| 97 |
|
| 98 | public String toString()
|
| 99 | {
|
| 100 | return this.name;
|
| 101 | }
|
| 102 |
|
| 103 | public static BlockSandStone.EnumType byMetadata(int meta)
|
| 104 | {
|
| 105 | if (meta < 0 || meta >= META_LOOKUP.length)
|
| 106 | {
|
| 107 | meta = 0;
|
| 108 | }
|
| 109 |
|
| 110 | return META_LOOKUP[meta];
|
| 111 | }
|
| 112 |
|
| 113 | public String getName()
|
| 114 | {
|
| 115 | return this.name;
|
| 116 | }
|
| 117 |
|
| 118 | public String getUnlocalizedName()
|
| 119 | {
|
| 120 | return this.unlocalizedName;
|
| 121 | }
|
| 122 |
|
| 123 | static {
|
| 124 | for (BlockSandStone.EnumType blocksandstone$enumtype : values())
|
| 125 | {
|
| 126 | META_LOOKUP[blocksandstone$enumtype.getMetadata()] = blocksandstone$enumtype;
|
| 127 | }
|
| 128 | }
|
| 129 | }
|
| 130 | }
|
| 131 |
|