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.tileentity.TileEntity;
011import net.minecraft.tileentity.TileEntityEndPortal;
012import net.minecraft.util.AxisAlignedBB;
013import net.minecraft.world.IBlockAccess;
014import net.minecraft.world.World;
015
016public class BlockEndPortal extends BlockContainer
017{
018    /**
019     * true if the enderdragon has been killed - allows end portal blocks to be created in the end
020     */
021    public static boolean bossDefeated = false;
022
023    protected BlockEndPortal(int par1, Material par2Material)
024    {
025        super(par1, par2Material);
026        this.setLightValue(1.0F);
027    }
028
029    /**
030     * Returns a new instance of a block's tile entity class. Called on placing the block.
031     */
032    public TileEntity createNewTileEntity(World par1World)
033    {
034        return new TileEntityEndPortal();
035    }
036
037    /**
038     * Updates the blocks bounds based on its current state. Args: world, x, y, z
039     */
040    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
041    {
042        float f = 0.0625F;
043        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
044    }
045
046    @SideOnly(Side.CLIENT)
047
048    /**
049     * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
050     * coordinates.  Args: blockAccess, x, y, z, side
051     */
052    public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
053    {
054        return par5 != 0 ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
055    }
056
057    /**
058     * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the
059     * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
060     */
061    public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {}
062
063    /**
064     * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
065     * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
066     */
067    public boolean isOpaqueCube()
068    {
069        return false;
070    }
071
072    /**
073     * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
074     */
075    public boolean renderAsNormalBlock()
076    {
077        return false;
078    }
079
080    /**
081     * Returns the quantity of items to drop on block destruction.
082     */
083    public int quantityDropped(Random par1Random)
084    {
085        return 0;
086    }
087
088    /**
089     * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
090     */
091    public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
092    {
093        if (par5Entity.ridingEntity == null && par5Entity.riddenByEntity == null && !par1World.isRemote)
094        {
095            par5Entity.travelToDimension(1);
096        }
097    }
098
099    @SideOnly(Side.CLIENT)
100
101    /**
102     * A randomly called display update to be able to add particles or other items for display
103     */
104    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
105    {
106        double d0 = (double)((float)par2 + par5Random.nextFloat());
107        double d1 = (double)((float)par3 + 0.8F);
108        double d2 = (double)((float)par4 + par5Random.nextFloat());
109        double d3 = 0.0D;
110        double d4 = 0.0D;
111        double d5 = 0.0D;
112        par1World.spawnParticle("smoke", d0, d1, d2, d3, d4, d5);
113    }
114
115    /**
116     * The type of render function that is called for this block
117     */
118    public int getRenderType()
119    {
120        return -1;
121    }
122
123    /**
124     * Called whenever the block is added into the world. Args: world, x, y, z
125     */
126    public void onBlockAdded(World par1World, int par2, int par3, int par4)
127    {
128        if (!bossDefeated)
129        {
130            if (par1World.provider.dimensionId != 0)
131            {
132                par1World.func_94571_i(par2, par3, par4);
133            }
134        }
135    }
136
137    @SideOnly(Side.CLIENT)
138
139    /**
140     * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
141     */
142    public int idPicked(World par1World, int par2, int par3, int par4)
143    {
144        return 0;
145    }
146
147    @SideOnly(Side.CLIENT)
148    public void func_94332_a(IconRegister par1IconRegister)
149    {
150        this.field_94336_cN = par1IconRegister.func_94245_a("portal");
151    }
152}