    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.EntityLiving;
    009import net.minecraft.entity.player.EntityPlayer;
    010import net.minecraft.item.ItemStack;
    011import net.minecraft.tileentity.TileEntity;
    012import net.minecraft.tileentity.TileEntityBeacon;
    013import net.minecraft.util.Icon;
    014import net.minecraft.world.World;
    015
    016public class BlockBeacon extends BlockContainer
    017{
    018    @SideOnly(Side.CLIENT)
    019    private Icon field_94447_a;
    020
    021    public BlockBeacon(int par1)
    022    {
    023        super(par1, Material.glass);
    024        this.setHardness(3.0F);
    025        this.setCreativeTab(CreativeTabs.tabMisc);
    026    }
    027
    028    /**
    029     * Returns a new instance of a block's tile entity class. Called on placing the block.
    030     */
    031    public TileEntity createNewTileEntity(World par1World)
    032    {
    033        return new TileEntityBeacon();
    034    }
    035
    036    /**
    037     * Called upon block activation (right click on the block.)
    038     */
    039    public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    040    {
    041        if (par1World.isRemote)
    042        {
    043            return true;
    044        }
    045        else
    046        {
    047            TileEntityBeacon tileentitybeacon = (TileEntityBeacon)par1World.getBlockTileEntity(par2, par3, par4);
    048
    049            if (tileentitybeacon != null)
    050            {
    051                par5EntityPlayer.displayGUIBeacon(tileentitybeacon);
    052            }
    053
    054            return true;
    055        }
    056    }
    057
    058    /**
    059     * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
    060     * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
    061     */
    062    public boolean isOpaqueCube()
    063    {
    064        return false;
    065    }
    066
    067    /**
    068     * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
    069     */
    070    public boolean renderAsNormalBlock()
    071    {
    072        return false;
    073    }
    074
    075    /**
    076     * The type of render function that is called for this block
    077     */
    078    public int getRenderType()
    079    {
    080        return 34;
    081    }
    082
    083    @SideOnly(Side.CLIENT)
    084    public void func_94332_a(IconRegister par1IconRegister)
    085    {
    086        super.func_94332_a(par1IconRegister);
    087        this.field_94447_a = par1IconRegister.func_94245_a("beacon");
    088    }
    089
    090    /**
    091     * Called when the block is placed in the world.
    092     */
    093    public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack)
    094    {
    095        super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLiving, par6ItemStack);
    096
    097        if (par6ItemStack.hasDisplayName())
    098        {
    099            ((TileEntityBeacon)par1World.getBlockTileEntity(par2, par3, par4)).func_94047_a(par6ItemStack.getDisplayName());
    100        }
    101    }
    102
    103    @SideOnly(Side.CLIENT)
    104    public Icon func_94446_i()
    105    {
    106        return this.field_94447_a;
    107    }
    108}