    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 theIcon;
    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
    085    /**
    086     * When this method is called, your block should register all the icons it needs with the given IconRegister. This
    087     * is the only chance you get to register icons.
    088     */
    089    public void registerIcons(IconRegister par1IconRegister)
    090    {
    091        super.registerIcons(par1IconRegister);
    092        this.theIcon = par1IconRegister.registerIcon("beacon");
    093    }
    094
    095    /**
    096     * Called when the block is placed in the world.
    097     */
    098    public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack)
    099    {
    100        super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLiving, par6ItemStack);
    101
    102        if (par6ItemStack.hasDisplayName())
    103        {
    104            ((TileEntityBeacon)par1World.getBlockTileEntity(par2, par3, par4)).func_94047_a(par6ItemStack.getDisplayName());
    105        }
    106    }
    107
    108    @SideOnly(Side.CLIENT)
    109    public Icon func_94446_i()
    110    {
    111        return this.theIcon;
    112    }
    113}