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.entity.Entity;
010import net.minecraft.entity.EntityLiving;
011import net.minecraft.item.ItemStack;
012import net.minecraft.util.AxisAlignedBB;
013import net.minecraft.util.Icon;
014import net.minecraft.util.MathHelper;
015import net.minecraft.world.World;
016
017public class BlockEndPortalFrame extends Block
018{
019    @SideOnly(Side.CLIENT)
020    private Icon field_94400_a;
021    @SideOnly(Side.CLIENT)
022    private Icon field_94399_b;
023
024    public BlockEndPortalFrame(int par1)
025    {
026        super(par1, Material.rock);
027    }
028
029    @SideOnly(Side.CLIENT)
030
031    /**
032     * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
033     */
034    public Icon getIcon(int par1, int par2)
035    {
036        return par1 == 1 ? this.field_94400_a : (par1 == 0 ? Block.whiteStone.getBlockTextureFromSide(par1) : this.blockIcon);
037    }
038
039    @SideOnly(Side.CLIENT)
040
041    /**
042     * When this method is called, your block should register all the icons it needs with the given IconRegister. This
043     * is the only chance you get to register icons.
044     */
045    public void registerIcons(IconRegister par1IconRegister)
046    {
047        this.blockIcon = par1IconRegister.registerIcon("endframe_side");
048        this.field_94400_a = par1IconRegister.registerIcon("endframe_top");
049        this.field_94399_b = par1IconRegister.registerIcon("endframe_eye");
050    }
051
052    @SideOnly(Side.CLIENT)
053    public Icon func_94398_p()
054    {
055        return this.field_94399_b;
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     * The type of render function that is called for this block
069     */
070    public int getRenderType()
071    {
072        return 26;
073    }
074
075    /**
076     * Sets the block's bounds for rendering it as an item
077     */
078    public void setBlockBoundsForItemRender()
079    {
080        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F);
081    }
082
083    /**
084     * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the
085     * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
086     */
087    public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
088    {
089        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F);
090        super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
091        int l = par1World.getBlockMetadata(par2, par3, par4);
092
093        if (isEnderEyeInserted(l))
094        {
095            this.setBlockBounds(0.3125F, 0.8125F, 0.3125F, 0.6875F, 1.0F, 0.6875F);
096            super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
097        }
098
099        this.setBlockBoundsForItemRender();
100    }
101
102    /**
103     * checks if an ender eye has been inserted into the frame block. parameters: metadata
104     */
105    public static boolean isEnderEyeInserted(int par0)
106    {
107        return (par0 & 4) != 0;
108    }
109
110    /**
111     * Returns the ID of the items to drop on destruction.
112     */
113    public int idDropped(int par1, Random par2Random, int par3)
114    {
115        return 0;
116    }
117
118    /**
119     * Called when the block is placed in the world.
120     */
121    public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack)
122    {
123        int l = ((MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4;
124        par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);
125    }
126}