001package net.minecraft.block; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import java.util.List; 006import java.util.Random; 007import net.minecraft.block.material.Material; 008import net.minecraft.client.renderer.texture.IconRegister; 009import net.minecraft.creativetab.CreativeTabs; 010import net.minecraft.item.ItemStack; 011import net.minecraft.util.Icon; 012 013public class BlockStep extends BlockHalfSlab 014{ 015 /** The list of the types of step blocks. */ 016 public static final String[] blockStepTypes = new String[] {"stone", "sand", "wood", "cobble", "brick", "smoothStoneBrick", "netherBrick", "quartz"}; 017 @SideOnly(Side.CLIENT) 018 private Icon field_94433_b; 019 020 public BlockStep(int par1, boolean par2) 021 { 022 super(par1, par2, Material.rock); 023 this.setCreativeTab(CreativeTabs.tabBlock); 024 } 025 026 @SideOnly(Side.CLIENT) 027 028 /** 029 * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata 030 */ 031 public Icon getBlockTextureFromSideAndMetadata(int par1, int par2) 032 { 033 int k = par2 & 7; 034 035 if (this.isDoubleSlab && (par2 & 8) != 0) 036 { 037 par1 = 1; 038 } 039 040 return k == 0 ? (par1 != 1 && par1 != 0 ? this.field_94433_b : this.field_94336_cN) : (k == 1 ? Block.sandStone.getBlockTextureFromSide(par1) : (k == 2 ? Block.planks.getBlockTextureFromSide(par1) : (k == 3 ? Block.cobblestone.getBlockTextureFromSide(par1) : (k == 4 ? Block.brick.getBlockTextureFromSide(par1) : (k == 5 ? Block.stoneBrick.getBlockTextureFromSideAndMetadata(par1, 0) : (k == 6 ? Block.netherBrick.getBlockTextureFromSide(1) : (k == 7 ? Block.field_94339_ct.getBlockTextureFromSide(par1) : this.field_94336_cN))))))); 041 } 042 043 @SideOnly(Side.CLIENT) 044 public void func_94332_a(IconRegister par1IconRegister) 045 { 046 this.field_94336_cN = par1IconRegister.func_94245_a("stoneslab_top"); 047 this.field_94433_b = par1IconRegister.func_94245_a("stoneslab_side"); 048 } 049 050 /** 051 * Returns the ID of the items to drop on destruction. 052 */ 053 public int idDropped(int par1, Random par2Random, int par3) 054 { 055 return Block.stoneSingleSlab.blockID; 056 } 057 058 /** 059 * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage 060 * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. 061 */ 062 protected ItemStack createStackedBlock(int par1) 063 { 064 return new ItemStack(Block.stoneSingleSlab.blockID, 2, par1 & 7); 065 } 066 067 /** 068 * Returns the slab block name with step type. 069 */ 070 public String getFullSlabName(int par1) 071 { 072 if (par1 < 0 || par1 >= blockStepTypes.length) 073 { 074 par1 = 0; 075 } 076 077 return super.getUnlocalizedName() + "." + blockStepTypes[par1]; 078 } 079 080 @SideOnly(Side.CLIENT) 081 082 /** 083 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) 084 */ 085 public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) 086 { 087 if (par1 != Block.stoneDoubleSlab.blockID) 088 { 089 for (int j = 0; j <= 7; ++j) 090 { 091 if (j != 2) 092 { 093 par3List.add(new ItemStack(par1, 1, j)); 094 } 095 } 096 } 097 } 098}