001package net.minecraft.block;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005import net.minecraft.block.material.Material;
006import net.minecraft.client.renderer.texture.IconRegister;
007import net.minecraft.creativetab.CreativeTabs;
008import net.minecraft.entity.player.EntityPlayer;
009import net.minecraft.util.Icon;
010import net.minecraft.world.World;
011
012public class BlockWorkbench extends Block
013{
014    @SideOnly(Side.CLIENT)
015    private Icon field_94385_a;
016    @SideOnly(Side.CLIENT)
017    private Icon field_94384_b;
018
019    protected BlockWorkbench(int par1)
020    {
021        super(par1, Material.wood);
022        this.setCreativeTab(CreativeTabs.tabDecorations);
023    }
024
025    @SideOnly(Side.CLIENT)
026
027    /**
028     * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
029     */
030    public Icon getIcon(int par1, int par2)
031    {
032        return par1 == 1 ? this.field_94385_a : (par1 == 0 ? Block.planks.getBlockTextureFromSide(par1) : (par1 != 2 && par1 != 4 ? this.blockIcon : this.field_94384_b));
033    }
034
035    @SideOnly(Side.CLIENT)
036
037    /**
038     * When this method is called, your block should register all the icons it needs with the given IconRegister. This
039     * is the only chance you get to register icons.
040     */
041    public void registerIcons(IconRegister par1IconRegister)
042    {
043        this.blockIcon = par1IconRegister.registerIcon("workbench_side");
044        this.field_94385_a = par1IconRegister.registerIcon("workbench_top");
045        this.field_94384_b = par1IconRegister.registerIcon("workbench_front");
046    }
047
048    /**
049     * Called upon block activation (right click on the block.)
050     */
051    public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
052    {
053        if (par1World.isRemote)
054        {
055            return true;
056        }
057        else
058        {
059            par5EntityPlayer.displayGUIWorkbench(par2, par3, par4);
060            return true;
061        }
062    }
063}