    001package net.minecraft.client.renderer.tileentity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.client.model.ModelChest;
    006import net.minecraft.tileentity.TileEntity;
    007import net.minecraft.tileentity.TileEntityEnderChest;
    008import org.lwjgl.opengl.GL11;
    009import org.lwjgl.opengl.GL12;
    010
    011@SideOnly(Side.CLIENT)
    012public class TileEntityEnderChestRenderer extends TileEntitySpecialRenderer
    013{
    014    /** The Ender Chest Chest's model. */
    015    private ModelChest theEnderChestModel = new ModelChest();
    016
    017    /**
    018     * Helps to render Ender Chest.
    019     */
    020    public void renderEnderChest(TileEntityEnderChest par1TileEntityEnderChest, double par2, double par4, double par6, float par8)
    021    {
    022        int i = 0;
    023
    024        if (par1TileEntityEnderChest.func_70309_m())
    025        {
    026            i = par1TileEntityEnderChest.getBlockMetadata();
    027        }
    028
    029        this.bindTextureByName("/item/enderchest.png");
    030        GL11.glPushMatrix();
    031        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    032        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    033        GL11.glTranslatef((float)par2, (float)par4 + 1.0F, (float)par6 + 1.0F);
    034        GL11.glScalef(1.0F, -1.0F, -1.0F);
    035        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    036        short short1 = 0;
    037
    038        if (i == 2)
    039        {
    040            short1 = 180;
    041        }
    042
    043        if (i == 3)
    044        {
    045            short1 = 0;
    046        }
    047
    048        if (i == 4)
    049        {
    050            short1 = 90;
    051        }
    052
    053        if (i == 5)
    054        {
    055            short1 = -90;
    056        }
    057
    058        GL11.glRotatef((float)short1, 0.0F, 1.0F, 0.0F);
    059        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    060        float f1 = par1TileEntityEnderChest.prevLidAngle + (par1TileEntityEnderChest.lidAngle - par1TileEntityEnderChest.prevLidAngle) * par8;
    061        f1 = 1.0F - f1;
    062        f1 = 1.0F - f1 * f1 * f1;
    063        this.theEnderChestModel.chestLid.rotateAngleX = -(f1 * (float)Math.PI / 2.0F);
    064        this.theEnderChestModel.renderAll();
    065        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    066        GL11.glPopMatrix();
    067        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    068    }
    069
    070    public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
    071    {
    072        this.renderEnderChest((TileEntityEnderChest)par1TileEntity, par2, par4, par6, par8);
    073    }
    074}