package net.minecraft.src;

import net.lax1dude.eaglercraft.EaglercraftRandom;

import net.lax1dude.eaglercraft.TextureLocation;
import net.lax1dude.eaglercraft.adapter.Tessellator;
import net.lax1dude.eaglercraft.EaglerAdapter;

public abstract class RendererLivingEntity extends Render
{
    private static final TextureLocation RES_ITEM_GLINT = new TextureLocation("textures/misc/enchanted_item_glint.png");
    protected ModelBase mainModel;

    /** The model to be used during the render passes. */
    protected ModelBase renderPassModel;

    public RendererLivingEntity(ModelBase par1ModelBase, float par2)
    {
        this.mainModel = par1ModelBase;
        this.shadowSize = par2;
    }

    /**
     * Sets the model to be used in the current render pass (the first render pass is done after the primary model is
     * rendered) Args: model
     */
    public void setRenderPassModel(ModelBase par1ModelBase)
    {
        this.renderPassModel = par1ModelBase;
    }

    /**
     * Returns a rotation angle that is inbetween two other rotation angles. par1 and par2 are the angles between which
     * to interpolate, par3 is probably a float between 0.0 and 1.0 that tells us where "between" the two angles we are.
     * Example: par1 = 30, par2 = 50, par3 = 0.5, then return = 40
     */
    private float interpolateRotation(float par1, float par2, float par3)
    {
        float var4;

        for (var4 = par2 - par1; var4 < -180.0F; var4 += 360.0F)
        {
            ;
        }

        while (var4 >= 180.0F)
        {
            var4 -= 360.0F;
        }

        return par1 + par3 * var4;
    }

    public void doRenderLiving(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, float par8, float par9)
    {
        EaglerAdapter.glPushMatrix();
        EaglerAdapter.glDisable(EaglerAdapter.GL_CULL_FACE);
        this.mainModel.onGround = this.renderSwingProgress(par1EntityLivingBase, par9);

        if (this.renderPassModel != null)
        {
            this.renderPassModel.onGround = this.mainModel.onGround;
        }

        this.mainModel.isRiding = par1EntityLivingBase.isRiding();

        if (this.renderPassModel != null)
        {
            this.renderPassModel.isRiding = this.mainModel.isRiding;
        }

        this.mainModel.isChild = par1EntityLivingBase.isChild();

        if (this.renderPassModel != null)
        {
            this.renderPassModel.isChild = this.mainModel.isChild;
        }

        try
        {
            float var10 = this.interpolateRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par9);
            float var11 = this.interpolateRotation(par1EntityLivingBase.prevRotationYawHead, par1EntityLivingBase.rotationYawHead, par9);
            float var13;

            if (par1EntityLivingBase.isRiding() && par1EntityLivingBase.ridingEntity instanceof EntityLivingBase)
            {
                EntityLivingBase var12 = (EntityLivingBase)par1EntityLivingBase.ridingEntity;
                var10 = this.interpolateRotation(var12.prevRenderYawOffset, var12.renderYawOffset, par9);
                var13 = MathHelper.wrapAngleTo180_float(var11 - var10);

                if (var13 < -85.0F)
                {
                    var13 = -85.0F;
                }

                if (var13 >= 85.0F)
                {
                    var13 = 85.0F;
                }

                var10 = var11 - var13;

                if (var13 * var13 > 2500.0F)
                {
                    var10 += var13 * 0.2F;
                }
            }

            float var26 = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9;
            this.renderLivingAt(par1EntityLivingBase, par2, par4, par6);
            var13 = this.handleRotationFloat(par1EntityLivingBase, par9);
            this.rotateCorpse(par1EntityLivingBase, var13, var10, par9);
            float var14 = 0.0625F;
            EaglerAdapter.glEnable(EaglerAdapter.GL_RESCALE_NORMAL);
            EaglerAdapter.glScalef(-1.0F, -1.0F, 1.0F);
            this.preRenderCallback(par1EntityLivingBase, par9);
            EaglerAdapter.glTranslatef(0.0F, -24.0F * var14 - 0.0078125F, 0.0F);
            float var15 = par1EntityLivingBase.prevLimbSwingAmount + (par1EntityLivingBase.limbSwingAmount - par1EntityLivingBase.prevLimbSwingAmount) * par9;
            float var16 = par1EntityLivingBase.limbSwing - par1EntityLivingBase.limbSwingAmount * (1.0F - par9);

            if (par1EntityLivingBase.isChild())
            {
                var16 *= 3.0F;
            }

            if (var15 > 1.0F)
            {
                var15 = 1.0F;
            }

            EaglerAdapter.glEnable(EaglerAdapter.GL_ALPHA_TEST);
            this.mainModel.setLivingAnimations(par1EntityLivingBase, var16, var15, par9);
            this.renderModel(par1EntityLivingBase, var16, var15, var13, var11 - var10, var26, var14);
            int var18;
            float var19;
            float var20;
            float var22;

            for (int var17 = 0; var17 < 4; ++var17)
            {
                var18 = this.shouldRenderPass(par1EntityLivingBase, var17, par9);

                if (var18 > 0)
                {
                    this.renderPassModel.setLivingAnimations(par1EntityLivingBase, var16, var15, par9);
                    this.renderPassModel.render(par1EntityLivingBase, var16, var15, var13, var11 - var10, var26, var14);

                    if ((var18 & 240) == 16)
                    {
                        this.func_82408_c(par1EntityLivingBase, var17, par9);
                        this.renderPassModel.render(par1EntityLivingBase, var16, var15, var13, var11 - var10, var26, var14);
                    }

                    if ((var18 & 15) == 15)
                    {
                        var19 = (float)par1EntityLivingBase.ticksExisted + par9;
                        this.bindTexture(RES_ITEM_GLINT);
                        EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
                        var20 = 0.5F;
                        EaglerAdapter.glColor4f(var20, var20, var20, 1.0F);
                        EaglerAdapter.glDepthFunc(EaglerAdapter.GL_EQUAL);
                        EaglerAdapter.glDepthMask(false);

                        for (int var21 = 0; var21 < 2; ++var21)
                        {
                            EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING);
                            var22 = 0.76F;
                            EaglerAdapter.glColor4f(0.5F * var22, 0.25F * var22, 0.8F * var22, 1.0F);
                            EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_COLOR, EaglerAdapter.GL_ONE);
                            EaglerAdapter.glMatrixMode(EaglerAdapter.GL_TEXTURE);
                            EaglerAdapter.glLoadIdentity();
                            float var23 = var19 * (0.001F + (float)var21 * 0.003F) * 20.0F;
                            float var24 = 0.33333334F;
                            EaglerAdapter.glScalef(var24, var24, var24);
                            EaglerAdapter.glRotatef(30.0F - (float)var21 * 60.0F, 0.0F, 0.0F, 1.0F);
                            EaglerAdapter.glTranslatef(0.0F, var23, 0.0F);
                            EaglerAdapter.glMatrixMode(EaglerAdapter.GL_MODELVIEW);
                            this.renderPassModel.render(par1EntityLivingBase, var16, var15, var13, var11 - var10, var26, var14);
                        }

                        EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                        EaglerAdapter.glMatrixMode(EaglerAdapter.GL_TEXTURE);
                        EaglerAdapter.glDepthMask(true);
                        EaglerAdapter.glLoadIdentity();
                        EaglerAdapter.glMatrixMode(EaglerAdapter.GL_MODELVIEW);
                        EaglerAdapter.glEnable(EaglerAdapter.GL_LIGHTING);
                        EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
                        EaglerAdapter.glDepthFunc(EaglerAdapter.GL_LEQUAL);
                    }

                    EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
                    EaglerAdapter.glEnable(EaglerAdapter.GL_ALPHA_TEST);
                }
            }

            EaglerAdapter.glDepthMask(true);
            this.renderEquippedItems(par1EntityLivingBase, par9);
            float var27 = par1EntityLivingBase.getBrightness(par9);
            var18 = this.getColorMultiplier(par1EntityLivingBase, var27, par9);
            OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
            EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
            OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);

            if ((var18 >> 24 & 255) > 0 || par1EntityLivingBase.hurtTime > 0 || par1EntityLivingBase.deathTime > 0)
            {
                EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
                EaglerAdapter.glDisable(EaglerAdapter.GL_ALPHA_TEST);
                EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
                EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
                EaglerAdapter.glDepthFunc(EaglerAdapter.GL_EQUAL);

                if (par1EntityLivingBase.hurtTime > 0 || par1EntityLivingBase.deathTime > 0)
                {
                    EaglerAdapter.glColor4f(var27, 0.0F, 0.0F, 0.4F);
                    this.mainModel.render(par1EntityLivingBase, var16, var15, var13, var11 - var10, var26, var14);

                    for (int var28 = 0; var28 < 4; ++var28)
                    {
                        if (this.inheritRenderPass(par1EntityLivingBase, var28, par9) >= 0)
                        {
                            EaglerAdapter.glColor4f(var27, 0.0F, 0.0F, 0.4F);
                            this.renderPassModel.render(par1EntityLivingBase, var16, var15, var13, var11 - var10, var26, var14);
                        }
                    }
                }

                if ((var18 >> 24 & 255) > 0)
                {
                    var19 = (float)(var18 >> 16 & 255) / 255.0F;
                    var20 = (float)(var18 >> 8 & 255) / 255.0F;
                    float var29 = (float)(var18 & 255) / 255.0F;
                    var22 = (float)(var18 >> 24 & 255) / 255.0F;
                    EaglerAdapter.glColor4f(var19, var20, var29, var22);
                    this.mainModel.render(par1EntityLivingBase, var16, var15, var13, var11 - var10, var26, var14);

                    for (int var30 = 0; var30 < 4; ++var30)
                    {
                        if (this.inheritRenderPass(par1EntityLivingBase, var30, par9) >= 0)
                        {
                            EaglerAdapter.glColor4f(var19, var20, var29, var22);
                            this.renderPassModel.render(par1EntityLivingBase, var16, var15, var13, var11 - var10, var26, var14);
                        }
                    }
                }

                EaglerAdapter.glDepthFunc(EaglerAdapter.GL_LEQUAL);
                EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
                EaglerAdapter.glEnable(EaglerAdapter.GL_ALPHA_TEST);
                EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D);
            }

            EaglerAdapter.glDisable(EaglerAdapter.GL_RESCALE_NORMAL);
        }
        catch (Exception var25)
        {
            var25.printStackTrace();
        }

        OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
        EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D);
        OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
        EaglerAdapter.glEnable(EaglerAdapter.GL_CULL_FACE);
        EaglerAdapter.glPopMatrix();
        this.passSpecialRender(par1EntityLivingBase, par2, par4, par6);
    }

    /**
     * Renders the model in RenderLiving
     */
    protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7)
    {
        if(par1EntityLivingBase instanceof EntityPlayer){
            this.bindTexture(par1EntityLivingBase);
        }
        else {
            this.bindEntityTexture(par1EntityLivingBase);
        }

        if (!par1EntityLivingBase.isInvisible())
        {
            this.mainModel.render(par1EntityLivingBase, par2, par3, par4, par5, par6, par7);
        }
        else if (!par1EntityLivingBase.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
        {
            EaglerAdapter.glPushMatrix();
            EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 0.15F);
            EaglerAdapter.glDepthMask(false);
            EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
            EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
            EaglerAdapter.glAlphaFunc(EaglerAdapter.GL_GREATER, 0.003921569F);
            this.mainModel.render(par1EntityLivingBase, par2, par3, par4, par5, par6, par7);
            EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
            EaglerAdapter.glAlphaFunc(EaglerAdapter.GL_GREATER, 0.1F);
            EaglerAdapter.glPopMatrix();
            EaglerAdapter.glDepthMask(true);
        }
        else
        {
            this.mainModel.setRotationAngles(par2, par3, par4, par5, par6, par7, par1EntityLivingBase);
        }
    }

    protected abstract void bindTexture(EntityLivingBase par1EntityLiving);

    /**
     * Sets a simple glTranslate on a LivingEntity.
     */
    protected void renderLivingAt(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6)
    {
        EaglerAdapter.glTranslatef((float)par2, (float)par4, (float)par6);
    }

    protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4)
    {
        EaglerAdapter.glRotatef(180.0F - par3, 0.0F, 1.0F, 0.0F);

        if (par1EntityLivingBase.deathTime > 0)
        {
            float var5 = ((float)par1EntityLivingBase.deathTime + par4 - 1.0F) / 20.0F * 1.6F;
            var5 = MathHelper.sqrt_float(var5);

            if (var5 > 1.0F)
            {
                var5 = 1.0F;
            }

            EaglerAdapter.glRotatef(var5 * this.getDeathMaxRotation(par1EntityLivingBase), 0.0F, 0.0F, 1.0F);
        }

    }

    protected float renderSwingProgress(EntityLivingBase par1EntityLivingBase, float par2)
    {
        return par1EntityLivingBase.getSwingProgress(par2);
    }

    /**
     * Defines what float the third param in setRotationAngles of ModelBase is
     */
    protected float handleRotationFloat(EntityLivingBase par1EntityLivingBase, float par2)
    {
        return (float)par1EntityLivingBase.ticksExisted + par2;
    }

    protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) {}

    /**
     * renders arrows the Entity has been attacked with, attached to it
     */
    protected void renderArrowsStuckInEntity(EntityLivingBase par1EntityLivingBase, float par2)
    {
        int var3 = par1EntityLivingBase.getArrowCountInEntity();

        if (var3 > 0)
        {
            EntityArrow var4 = new EntityArrow(par1EntityLivingBase.worldObj, par1EntityLivingBase.posX, par1EntityLivingBase.posY, par1EntityLivingBase.posZ);
            EaglercraftRandom var5 = new EaglercraftRandom((long)par1EntityLivingBase.entityId);
            RenderHelper.disableStandardItemLighting();

            for (int var6 = 0; var6 < var3; ++var6)
            {
                EaglerAdapter.glPushMatrix();
                ModelRenderer var7 = this.mainModel.getRandomModelBox(var5);
                ModelBox var8 = (ModelBox)var7.cubeList.get(var5.nextInt(var7.cubeList.size()));
                var7.postRender(0.0625F);
                float var9 = var5.nextFloat();
                float var10 = var5.nextFloat();
                float var11 = var5.nextFloat();
                float var12 = (var8.posX1 + (var8.posX2 - var8.posX1) * var9) / 16.0F;
                float var13 = (var8.posY1 + (var8.posY2 - var8.posY1) * var10) / 16.0F;
                float var14 = (var8.posZ1 + (var8.posZ2 - var8.posZ1) * var11) / 16.0F;
                EaglerAdapter.glTranslatef(var12, var13, var14);
                var9 = var9 * 2.0F - 1.0F;
                var10 = var10 * 2.0F - 1.0F;
                var11 = var11 * 2.0F - 1.0F;
                var9 *= -1.0F;
                var10 *= -1.0F;
                var11 *= -1.0F;
                float var15 = MathHelper.sqrt_float(var9 * var9 + var11 * var11);
                var4.prevRotationYaw = var4.rotationYaw = (float)(Math.atan2((double)var9, (double)var11) * 180.0D / Math.PI);
                var4.prevRotationPitch = var4.rotationPitch = (float)(Math.atan2((double)var10, (double)var15) * 180.0D / Math.PI);
                double var16 = 0.0D;
                double var18 = 0.0D;
                double var20 = 0.0D;
                float var22 = 0.0F;
                this.renderManager.renderEntityWithPosYaw(var4, var16, var18, var20, var22, par2);
                EaglerAdapter.glPopMatrix();
            }

            RenderHelper.enableStandardItemLighting();
        }
    }

    protected int inheritRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3)
    {
        return this.shouldRenderPass(par1EntityLivingBase, par2, par3);
    }

    /**
     * Queries whether should render the specified pass or not.
     */
    protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3)
    {
        return -1;
    }

    protected void func_82408_c(EntityLivingBase par1EntityLivingBase, int par2, float par3) {}

    protected float getDeathMaxRotation(EntityLivingBase par1EntityLivingBase)
    {
        return 90.0F;
    }

    /**
     * Returns an ARGB int color back. Args: entityLiving, lightBrightness, partialTickTime
     */
    protected int getColorMultiplier(EntityLivingBase par1EntityLivingBase, float par2, float par3)
    {
        return 0;
    }

    /**
     * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
     * entityLiving, partialTickTime
     */
    protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) {}

    /**
     * Passes the specialRender and renders it
     */
    protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6)
    {
        if (this.func_110813_b(par1EntityLivingBase))
        {
            float var8 = 1.6F;
            float var9 = 0.016666668F * var8;
            double var10 = par1EntityLivingBase.getDistanceSqToEntity(this.renderManager.livingPlayer);
            float var12 = par1EntityLivingBase.isSneaking() ? 32.0F : 64.0F;

            if (var10 < (double)(var12 * var12))
            {
                String var13 = par1EntityLivingBase.getTranslatedEntityName();

                if (par1EntityLivingBase.isSneaking())
                {
                    FontRenderer var14 = this.getFontRendererFromRenderManager();
                    EaglerAdapter.glPushMatrix();
                    EaglerAdapter.glTranslatef((float)par2 + 0.0F, (float)par4 + par1EntityLivingBase.height + 0.5F, (float)par6);
                    EaglerAdapter.glNormal3f(0.0F, 1.0F, 0.0F);
                    EaglerAdapter.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
                    EaglerAdapter.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
                    EaglerAdapter.glScalef(-var9, -var9, var9);
                    EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING);
                    EaglerAdapter.glTranslatef(0.0F, 0.25F / var9, 0.0F);
                    EaglerAdapter.glDepthMask(false);
                    EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
                    EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
                    Tessellator var15 = Tessellator.instance;
                    EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
                    var15.startDrawingQuads();
                    int var16 = var14.getStringWidth(var13) / 2;
                    var15.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
                    var15.addVertex((double)(-var16 - 1), -1.0D, 0.0D);
                    var15.addVertex((double)(-var16 - 1), 8.0D, 0.0D);
                    var15.addVertex((double)(var16 + 1), 8.0D, 0.0D);
                    var15.addVertex((double)(var16 + 1), -1.0D, 0.0D);
                    var15.draw();
                    EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D);
                    EaglerAdapter.glDepthMask(true);
                    var14.drawString(var13, -var14.getStringWidth(var13) / 2, 0, 553648127);
                    EaglerAdapter.glEnable(EaglerAdapter.GL_LIGHTING);
                    EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
                    EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                    EaglerAdapter.glPopMatrix();
                }
                else
                {
                    this.func_96449_a(par1EntityLivingBase, par2, par4, par6, var13, var9, var10);
                }
            }
        }
    }

    protected boolean func_110813_b(EntityLivingBase par1EntityLivingBase)
    {
        return Minecraft.isGuiEnabled() && par1EntityLivingBase != this.renderManager.livingPlayer && !par1EntityLivingBase.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer) && par1EntityLivingBase.riddenByEntity == null;
    }

    protected void func_96449_a(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, String par8Str, float par9, double par10)
    {
        if (par1EntityLivingBase.isPlayerSleeping())
        {
            this.renderLivingLabel(par1EntityLivingBase, par8Str, par2, par4 - 1.5D, par6, 64);
        }
        else
        {
            this.renderLivingLabel(par1EntityLivingBase, par8Str, par2, par4, par6, 64);
        }
    }

    /**
     * Draws the debug or playername text above a living
     */
    protected void renderLivingLabel(EntityLivingBase par1EntityLivingBase, String par2Str, double par3, double par5, double par7, int par9)
    {
        double var10 = par1EntityLivingBase.getDistanceSqToEntity(this.renderManager.livingPlayer);

        if (var10 <= (double)(par9 * par9))
        {
            FontRenderer var12 = this.getFontRendererFromRenderManager();
            float var13 = 1.6F;
            float var14 = 0.016666668F * var13;
            EaglerAdapter.glPushMatrix();
            EaglerAdapter.glTranslatef((float)par3 + 0.0F, (float)par5 + par1EntityLivingBase.height + 0.5F, (float)par7);
            EaglerAdapter.glNormal3f(0.0F, 1.0F, 0.0F);
            EaglerAdapter.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
            EaglerAdapter.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
            EaglerAdapter.glScalef(-var14, -var14, var14);
            EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING);
            EaglerAdapter.glDepthMask(false);
            EaglerAdapter.glDisable(EaglerAdapter.GL_DEPTH_TEST);
            EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
            EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
            Tessellator var15 = Tessellator.instance;
            byte var16 = 0;

            if (par2Str.equals("deadmau5"))
            {
                var16 = -10;
            }

            EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
            var15.startDrawingQuads();
            int var17 = var12.getStringWidth(par2Str) / 2;
            var15.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
            var15.addVertex((double)(-var17 - 1), (double)(-1 + var16), 0.0D);
            var15.addVertex((double)(-var17 - 1), (double)(8 + var16), 0.0D);
            var15.addVertex((double)(var17 + 1), (double)(8 + var16), 0.0D);
            var15.addVertex((double)(var17 + 1), (double)(-1 + var16), 0.0D);
            var15.draw();
            EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D);
            var12.drawString(par2Str, -var12.getStringWidth(par2Str) / 2, var16, 553648127);
            EaglerAdapter.glEnable(EaglerAdapter.GL_DEPTH_TEST);
            EaglerAdapter.glDepthMask(true);
            var12.drawString(par2Str, -var12.getStringWidth(par2Str) / 2, var16, -1);
            EaglerAdapter.glEnable(EaglerAdapter.GL_LIGHTING);
            EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
            EaglerAdapter.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            EaglerAdapter.glPopMatrix();
        }
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        this.doRenderLiving((EntityLivingBase)par1Entity, par2, par4, par6, par8, par9);
    }
}
