    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 theIcon;
    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 getIcon(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.theIcon : this.blockIcon) : (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.getIcon(par1, 0) : (k == 6 ? Block.netherBrick.getBlockTextureFromSide(1) : (k == 7 ? Block.blockNetherQuartz.getBlockTextureFromSide(par1) : this.blockIcon)))))));
    041    }
    042
    043    @SideOnly(Side.CLIENT)
    044
    045    /**
    046     * When this method is called, your block should register all the icons it needs with the given IconRegister. This
    047     * is the only chance you get to register icons.
    048     */
    049    public void registerIcons(IconRegister par1IconRegister)
    050    {
    051        this.blockIcon = par1IconRegister.registerIcon("stoneslab_top");
    052        this.theIcon = par1IconRegister.registerIcon("stoneslab_side");
    053    }
    054
    055    /**
    056     * Returns the ID of the items to drop on destruction.
    057     */
    058    public int idDropped(int par1, Random par2Random, int par3)
    059    {
    060        return Block.stoneSingleSlab.blockID;
    061    }
    062
    063    /**
    064     * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
    065     * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
    066     */
    067    protected ItemStack createStackedBlock(int par1)
    068    {
    069        return new ItemStack(Block.stoneSingleSlab.blockID, 2, par1 & 7);
    070    }
    071
    072    /**
    073     * Returns the slab block name with step type.
    074     */
    075    public String getFullSlabName(int par1)
    076    {
    077        if (par1 < 0 || par1 >= blockStepTypes.length)
    078        {
    079            par1 = 0;
    080        }
    081
    082        return super.getUnlocalizedName() + "." + blockStepTypes[par1];
    083    }
    084
    085    @SideOnly(Side.CLIENT)
    086
    087    /**
    088     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
    089     */
    090    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
    091    {
    092        if (par1 != Block.stoneDoubleSlab.blockID)
    093        {
    094            for (int j = 0; j <= 7; ++j)
    095            {
    096                if (j != 2)
    097                {
    098                    par3List.add(new ItemStack(par1, 1, j));
    099                }
    100            }
    101        }
    102    }
    103}