001 package net.minecraft.block;
002
003 import cpw.mods.fml.relauncher.Side;
004 import cpw.mods.fml.relauncher.SideOnly;
005 import java.util.List;
006 import java.util.Random;
007 import net.minecraft.block.material.Material;
008 import net.minecraft.creativetab.CreativeTabs;
009 import net.minecraft.item.ItemStack;
010
011 public class BlockWoodSlab extends BlockHalfSlab
012 {
013 /** The type of tree this slab came from. */
014 public static final String[] woodType = new String[] {"oak", "spruce", "birch", "jungle"};
015
016 public BlockWoodSlab(int par1, boolean par2)
017 {
018 super(par1, par2, Material.wood);
019 this.setCreativeTab(CreativeTabs.tabBlock);
020 }
021
022 /**
023 * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
024 */
025 public int getBlockTextureFromSideAndMetadata(int par1, int par2)
026 {
027 switch (par2 & 7)
028 {
029 case 1:
030 return 198;
031 case 2:
032 return 214;
033 case 3:
034 return 199;
035 default:
036 return 4;
037 }
038 }
039
040 /**
041 * Returns the block texture based on the side being looked at. Args: side
042 */
043 public int getBlockTextureFromSide(int par1)
044 {
045 return this.getBlockTextureFromSideAndMetadata(par1, 0);
046 }
047
048 /**
049 * Returns the ID of the items to drop on destruction.
050 */
051 public int idDropped(int par1, Random par2Random, int par3)
052 {
053 return Block.woodSingleSlab.blockID;
054 }
055
056 /**
057 * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
058 * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
059 */
060 protected ItemStack createStackedBlock(int par1)
061 {
062 return new ItemStack(Block.woodSingleSlab.blockID, 2, par1 & 7);
063 }
064
065 /**
066 * Returns the slab block name with step type.
067 */
068 public String getFullSlabName(int par1)
069 {
070 if (par1 < 0 || par1 >= woodType.length)
071 {
072 par1 = 0;
073 }
074
075 return super.getBlockName() + "." + woodType[par1];
076 }
077
078 @SideOnly(Side.CLIENT)
079
080 /**
081 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
082 */
083 public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
084 {
085 if (par1 != Block.woodDoubleSlab.blockID)
086 {
087 for (int var4 = 0; var4 < 4; ++var4)
088 {
089 par3List.add(new ItemStack(par1, 1, var4));
090 }
091 }
092 }
093 }