package net.minecraft.src;

import net.lax1dude.eaglercraft.DefaultSkinRenderer;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.EaglerProfile;
import net.lax1dude.eaglercraft.TextureLocation;
import net.lax1dude.eaglercraft.EaglerAdapter;

public class RenderPlayer extends RendererLivingEntity
{
    private static final TextureLocation steveTextures = new TextureLocation("textures/entity/steve.png");
    private ModelBiped modelBipedMain;
    private ModelBiped modelArmorChestplate;
    private ModelBiped modelArmor;

    private ModelBiped modelBipedMainNewSkin;
    private ModelBiped modelBipedMainNewSkinSlim;

    public RenderPlayer()
    {
        super(new ModelBiped(0.0F), 0.5F);
        this.modelBipedMain = (ModelBiped)this.mainModel;
        this.modelArmorChestplate = new ModelBiped(1.0F);
        this.modelArmor = new ModelBiped(0.5F);
    }

    /**
     * Set the specified armor model as the player model. Args: player, armorSlot, partialTick
     */
    protected int setArmorModel(EntityPlayer par1AbstractClientPlayer, int par2, float par3)
    {
        ItemStack var4 = par1AbstractClientPlayer.inventory.armorItemInSlot(3 - par2);

        if (var4 != null)
        {
            Item var5 = var4.getItem();

            if (var5 instanceof ItemArmor)
            {
                ItemArmor var6 = (ItemArmor)var5;
                this.bindTexture(RenderBiped.func_110857_a(var6, par2));
                ModelBiped var7 = par2 == 2 ? this.modelArmor : this.modelArmorChestplate;
                var7.bipedHead.showModel = par2 == 0;
                var7.bipedHeadwear.showModel = par2 == 0;
                var7.bipedBody.showModel = par2 == 1 || par2 == 2;
                var7.bipedRightArm.showModel = par2 == 1;
                var7.bipedLeftArm.showModel = par2 == 1;
                var7.bipedRightLeg.showModel = par2 == 2 || par2 == 3;
                var7.bipedLeftLeg.showModel = par2 == 2 || par2 == 3;
                this.setRenderPassModel(var7);
                var7.onGround = this.mainModel.onGround;
                var7.isRiding = this.mainModel.isRiding;
                var7.isChild = this.mainModel.isChild;
                float var8 = 1.0F;

                if (var6.getArmorMaterial() == EnumArmorMaterial.CLOTH)
                {
                    int var9 = var6.getColor(var4);
                    float var10 = (float)(var9 >> 16 & 255) / 255.0F;
                    float var11 = (float)(var9 >> 8 & 255) / 255.0F;
                    float var12 = (float)(var9 & 255) / 255.0F;
                    EaglerAdapter.glColor3f(var8 * var10, var8 * var11, var8 * var12);

                    if (var4.isItemEnchanted())
                    {
                        return 31;
                    }

                    return 16;
                }

                EaglerAdapter.glColor3f(var8, var8, var8);

                if (var4.isItemEnchanted())
                {
                    return 15;
                }

                return 1;
            }
        }

        return -1;
    }

    protected void func_130220_b(EntityPlayer par1AbstractClientPlayer, int par2, float par3)
    {
        ItemStack var4 = par1AbstractClientPlayer.inventory.armorItemInSlot(3 - par2);

        if (var4 != null)
        {
            Item var5 = var4.getItem();

            if (var5 instanceof ItemArmor)
            {
                this.bindTexture(RenderBiped.func_110858_a((ItemArmor)var5, par2, "overlay"));
                float var6 = 1.0F;
                EaglerAdapter.glColor3f(var6, var6, var6);
            }
        }
    }

    public void func_130009_a(EntityPlayer par1AbstractClientPlayer, double par2, double par4, double par6, float par8, float par9)
    {
        float var10 = 1.0F;
        EaglerAdapter.glColor3f(var10, var10, var10);
        ItemStack var11 = par1AbstractClientPlayer.inventory.getCurrentItem();
        this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = var11 != null ? 1 : 0;

        if (var11 != null && par1AbstractClientPlayer.getItemInUseCount() > 0)
        {
            EnumAction var12 = var11.getItemUseAction();

            if (var12 == EnumAction.block)
            {
                this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = 3;
            }
            else if (var12 == EnumAction.bow)
            {
                this.modelArmorChestplate.aimedBow = this.modelArmor.aimedBow = this.modelBipedMain.aimedBow = true;
            }
        }

        this.modelArmorChestplate.isSneak = this.modelArmor.isSneak = this.modelBipedMain.isSneak = par1AbstractClientPlayer.isSneaking();
        double var14 = par4 - (double)par1AbstractClientPlayer.yOffset;

        if (par1AbstractClientPlayer.isSneaking() && !(par1AbstractClientPlayer instanceof EntityPlayerSP))
        {
            var14 -= 0.125D;
        }

        super.doRenderLiving(par1AbstractClientPlayer, par2, var14, par6, par8, par9);
        this.modelArmorChestplate.aimedBow = this.modelArmor.aimedBow = this.modelBipedMain.aimedBow = false;
        this.modelArmorChestplate.isSneak = this.modelArmor.isSneak = this.modelBipedMain.isSneak = false;
        this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = 0;
    }

    protected TextureLocation func_110817_a(EntityPlayer par1AbstractClientPlayer)
    {
        return DefaultSkinRenderer.defaultVanillaSkins[EaglerProfile.presetSkinId];
    }

    /**
     * Method for adding special render rules
     */
    protected void renderSpecials(EntityPlayer par1EntityPlayer, float par2) {
        float var3 = 1.0F;
        EaglerAdapter.glColor3f(var3, var3, var3);
        super.renderEquippedItems(par1EntityPlayer, par2);
        super.renderArrowsStuckInEntity(par1EntityPlayer, par2);
        ItemStack var4 = par1EntityPlayer.inventory.armorItemInSlot(3);

        boolean isNew = DefaultSkinRenderer.isPlayerNewSkin(par1EntityPlayer);
        boolean isSlim = DefaultSkinRenderer.isPlayerNewSkinSlim(par1EntityPlayer);
        int renderType = DefaultSkinRenderer.getPlayerRenderer(par1EntityPlayer);
        boolean allowFNAW = Minecraft.getMinecraft().gameSettings.allowFNAWSkins;

        if(!allowFNAW || !DefaultSkinRenderer.isHighPoly(renderType)) {
            if (var4 != null) {
                EaglerAdapter.glPushMatrix();
                (isNew ? (isSlim ? this.modelBipedMainNewSkinSlim : this.modelBipedMainNewSkin) : this.modelBipedMain).bipedHead.postRender(0.0625F);
                float var5;

                if (var4.getItem().itemID < 256) {
                    if (RenderBlocks.renderItemIn3d(Block.blocksList[var4.itemID].getRenderType())) {
                        var5 = 0.625F;
                        EaglerAdapter.glTranslatef(0.0F, -0.25F, 0.0F);
                        EaglerAdapter.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
                        EaglerAdapter.glScalef(var5, -var5, -var5);
                    }

                    this.renderManager.itemRenderer.renderItem(par1EntityPlayer, var4, 0);
                } else if (var4.getItem().itemID == Item.skull.itemID) {
                    var5 = 1.0625F;
                    EaglerAdapter.glScalef(var5, -var5, -var5);
                    String var6 = "";

                    if (var4.hasTagCompound() && var4.getTagCompound().hasKey("SkullOwner")) {
                        var6 = var4.getTagCompound().getString("SkullOwner");
                    }

                    TileEntitySkullRenderer.skullRenderer.func_82393_a(-0.5F, 0.0F, -0.5F, 1, 180.0F, var4.getItemDamage(), var6);
                }

                EaglerAdapter.glPopMatrix();
            }

            float var7;
            float var8;

			/*
			if (par1EntityPlayer.username.equals("deadmau5") && this.loadDownloadableImageTexture(par1EntityPlayer.skinUrl, (String) null)) {
				for (int var20 = 0; var20 < 2; ++var20) {
					float var23 = par1EntityPlayer.prevRotationYaw + (par1EntityPlayer.rotationYaw - par1EntityPlayer.prevRotationYaw) * par2
							- (par1EntityPlayer.prevRenderYawOffset + (par1EntityPlayer.renderYawOffset - par1EntityPlayer.prevRenderYawOffset) * par2);
					var7 = par1EntityPlayer.prevRotationPitch + (par1EntityPlayer.rotationPitch - par1EntityPlayer.prevRotationPitch) * par2;
					EaglerAdapter.glPushMatrix();
					EaglerAdapter.glRotatef(var23, 0.0F, 1.0F, 0.0F);
					EaglerAdapter.glRotatef(var7, 1.0F, 0.0F, 0.0F);
					EaglerAdapter.glTranslatef(0.375F * (float) (var20 * 2 - 1), 0.0F, 0.0F);
					EaglerAdapter.glTranslatef(0.0F, -0.375F, 0.0F);
					EaglerAdapter.glRotatef(-var7, 1.0F, 0.0F, 0.0F);
					EaglerAdapter.glRotatef(-var23, 0.0F, 1.0F, 0.0F);
					var8 = 1.3333334F;
					EaglerAdapter.glScalef(var8, var8, var8);
					this.modelBipedMain.renderEars(0.0625F);
					EaglerAdapter.glPopMatrix();
				}
			}
			*/

            float var11;

            if(DefaultSkinRenderer.isStandardModel(renderType) || DefaultSkinRenderer.isZombieModel(renderType) || (!allowFNAW && DefaultSkinRenderer.isHighPoly(renderType))) {
                if(!par1EntityPlayer.isInvisible() && !par1EntityPlayer.getHideCape()) {
                    if(DefaultSkinRenderer.bindSyncedCape(par1EntityPlayer)) {
                        EaglerAdapter.glPushMatrix();
                        EaglerAdapter.glTranslatef(0.0F, 0.0F, 0.125F);
                        double var21 = par1EntityPlayer.field_71091_bM + (par1EntityPlayer.field_71094_bP - par1EntityPlayer.field_71091_bM) * (double) par2
                                - (par1EntityPlayer.prevPosX + (par1EntityPlayer.posX - par1EntityPlayer.prevPosX) * (double) par2);
                        double var24 = par1EntityPlayer.field_71096_bN + (par1EntityPlayer.field_71095_bQ - par1EntityPlayer.field_71096_bN) * (double) par2
                                - (par1EntityPlayer.prevPosY + (par1EntityPlayer.posY - par1EntityPlayer.prevPosY) * (double) par2);
                        double var9 = par1EntityPlayer.field_71097_bO + (par1EntityPlayer.field_71085_bR - par1EntityPlayer.field_71097_bO) * (double) par2
                                - (par1EntityPlayer.prevPosZ + (par1EntityPlayer.posZ - par1EntityPlayer.prevPosZ) * (double) par2);
                        var11 = par1EntityPlayer.prevRenderYawOffset + (par1EntityPlayer.renderYawOffset - par1EntityPlayer.prevRenderYawOffset) * par2;
                        double var12 = (double) MathHelper.sin(var11 * (float) Math.PI / 180.0F);
                        double var14 = (double) (-MathHelper.cos(var11 * (float) Math.PI / 180.0F));
                        float var16 = (float) var24 * 10.0F;

                        if (var16 < -6.0F) {
                            var16 = -6.0F;
                        }

                        if (var16 > 32.0F) {
                            var16 = 32.0F;
                        }

                        float var17 = (float) (var21 * var12 + var9 * var14) * 100.0F;
                        float var18 = (float) (var21 * var14 - var9 * var12) * 100.0F;

                        if (var17 < 0.0F) {
                            var17 = 0.0F;
                        }

                        float var19 = par1EntityPlayer.prevCameraYaw + (par1EntityPlayer.cameraYaw - par1EntityPlayer.prevCameraYaw) * par2;
                        var16 += MathHelper.sin((par1EntityPlayer.prevDistanceWalkedModified + (par1EntityPlayer.distanceWalkedModified - par1EntityPlayer.prevDistanceWalkedModified) * par2) * 6.0F) * 32.0F * var19;

                        if (par1EntityPlayer.isSneaking()) {
                            var16 += 25.0F;
                        }

                        EaglerAdapter.glRotatef(6.0F + var17 / 2.0F + var16, 1.0F, 0.0F, 0.0F);
                        EaglerAdapter.glRotatef(var18 / 2.0F, 0.0F, 0.0F, 1.0F);
                        EaglerAdapter.glRotatef(-var18 / 2.0F, 0.0F, 1.0F, 0.0F);
                        EaglerAdapter.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
                        this.modelBipedMain.renderCloak(0.0625F);
                        EaglerAdapter.glPopMatrix();
                    }
                    EaglerAdapter.glMatrixMode(EaglerAdapter.GL_TEXTURE);
                    EaglerAdapter.glPopMatrix();
                    EaglerAdapter.glMatrixMode(EaglerAdapter.GL_MODELVIEW);
                }
            }
        }

        ItemStack var22 = par1EntityPlayer.inventory.getCurrentItem();

        if (var22 != null) {
            EaglerAdapter.glPushMatrix();

            if(!allowFNAW || !DefaultSkinRenderer.isHighPoly(renderType)) {
                if(DefaultSkinRenderer.isZombieModel(renderType) || renderType == 20) {
                    ((ModelBiped)this.mainModel).bipedRightArm.postRender(0.0625F);
                }else {
                    (isNew ? (isSlim ? this.modelBipedMainNewSkinSlim : this.modelBipedMainNewSkin) : this.modelBipedMain).bipedRightArm.postRender(0.0625F);
                }
            }

            EaglerAdapter.glTranslatef(-0.0625F, 0.4375F, 0.0625F);

            if (par1EntityPlayer.fishEntity != null) {
                var22 = new ItemStack(Item.stick);
            }

            EnumAction var25 = null;

            if (par1EntityPlayer.getItemInUseCount() > 0) {
                var25 = var22.getItemUseAction();
            }

            float var7 = 0.0f;
            float var8 = 0.0f;
            float var11 = 0.0f;
            if (var22.itemID < 256 && RenderBlocks.renderItemIn3d(Block.blocksList[var22.itemID].getRenderType())) {
                var7 = 0.5F;
                EaglerAdapter.glTranslatef(0.0F, 0.1875F, -0.3125F);
                var7 *= 0.75F;
                EaglerAdapter.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
                EaglerAdapter.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
                EaglerAdapter.glScalef(-var7, -var7, var7);
            } else if (var22.itemID == Item.bow.itemID) {
                var7 = 0.625F;
                EaglerAdapter.glTranslatef(0.0F, 0.125F, 0.3125F);
                EaglerAdapter.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
                EaglerAdapter.glScalef(var7, -var7, var7);
                EaglerAdapter.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
                EaglerAdapter.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
            } else if (Item.itemsList[var22.itemID].isFull3D()) {
                var7 = 0.625F;

                if (Item.itemsList[var22.itemID].shouldRotateAroundWhenRendering()) {
                    EaglerAdapter.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
                    EaglerAdapter.glTranslatef(0.0F, -0.125F, 0.0F);
                }

                if (par1EntityPlayer.getItemInUseCount() > 0 && var25 == EnumAction.block) {
                    EaglerAdapter.glTranslatef(0.05F, 0.0F, -0.1F);
                    EaglerAdapter.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
                    EaglerAdapter.glRotatef(-10.0F, 1.0F, 0.0F, 0.0F);
                    EaglerAdapter.glRotatef(-60.0F, 0.0F, 0.0F, 1.0F);
                }

                EaglerAdapter.glTranslatef(0.0F, 0.1875F, 0.0F);
                EaglerAdapter.glScalef(var7, -var7, var7);
                EaglerAdapter.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
                EaglerAdapter.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
            } else {
                var7 = 0.375F;
                EaglerAdapter.glTranslatef(0.25F, 0.1875F, -0.1875F);
                EaglerAdapter.glScalef(var7, var7, var7);
                EaglerAdapter.glRotatef(60.0F, 0.0F, 0.0F, 1.0F);
                EaglerAdapter.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
                EaglerAdapter.glRotatef(20.0F, 0.0F, 0.0F, 1.0F);
            }

            float var10;
            int var27;
            float var28;

            if (var22.getItem().requiresMultipleRenderPasses()) {
                for (var27 = 0; var27 <= 1; ++var27) {
                    int var26 = var22.getItem().getColorFromItemStack(var22, var27);
                    var28 = (float) (var26 >> 16 & 255) / 255.0F;
                    var10 = (float) (var26 >> 8 & 255) / 255.0F;
                    var11 = (float) (var26 & 255) / 255.0F;
                    EaglerAdapter.glColor4f(var28, var10, var11, 1.0F);
                    this.renderManager.itemRenderer.renderItem(par1EntityPlayer, var22, var27);
                }
            } else {
                var27 = var22.getItem().getColorFromItemStack(var22, 0);
                var8 = (float) (var27 >> 16 & 255) / 255.0F;
                var28 = (float) (var27 >> 8 & 255) / 255.0F;
                var10 = (float) (var27 & 255) / 255.0F;
                EaglerAdapter.glColor4f(var8, var28, var10, 1.0F);
                this.renderManager.itemRenderer.renderItem(par1EntityPlayer, var22, 0);
            }

            EaglerAdapter.glPopMatrix();
        }
    }

    protected void renderPlayerScale(EntityPlayer par1AbstractClientPlayer, float par2)
    {
        float var3 = 0.9375F;
        EaglerAdapter.glScalef(var3, var3, var3);
    }

    protected void func_96450_a(EntityPlayer par1AbstractClientPlayer, double par2, double par4, double par6, String par8Str, float par9, double par10)
    {
        if (par10 < 100.0D)
        {
            Scoreboard var12 = par1AbstractClientPlayer.getWorldScoreboard();
            ScoreObjective var13 = var12.func_96539_a(2);

            if (var13 != null)
            {
                Score var14 = var12.func_96529_a(par1AbstractClientPlayer.getEntityName(), var13);

                if (par1AbstractClientPlayer.isPlayerSleeping())
                {
                    this.renderLivingLabel(par1AbstractClientPlayer, var14.getScorePoints() + " " + var13.getDisplayName(), par2, par4 - 1.5D, par6, 64);
                }
                else
                {
                    this.renderLivingLabel(par1AbstractClientPlayer, var14.getScorePoints() + " " + var13.getDisplayName(), par2, par4, par6, 64);
                }

                par4 += (double)((float)this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * par9);
            }
        }

        super.func_96449_a(par1AbstractClientPlayer, par2, par4, par6, par8Str, par9, par10);
    }

    public void renderFirstPersonArm(EntityPlayer par1EntityPlayer)
    {
        float var2 = 1.0F;
        EaglerAdapter.glColor3f(var2, var2, var2);
        this.modelBipedMain.onGround = 0.0F;
        this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer);
        this.modelBipedMain.bipedRightArm.render(0.0625F);
    }

    /**
     * Renders player with sleeping offset if sleeping
     */
    protected void renderPlayerSleep(EntityPlayer par1AbstractClientPlayer, double par2, double par4, double par6)
    {
        if (par1AbstractClientPlayer.isEntityAlive() && par1AbstractClientPlayer.isPlayerSleeping())
        {
            super.renderLivingAt(par1AbstractClientPlayer, par2 + (double)par1AbstractClientPlayer.field_71079_bU, par4 + (double)par1AbstractClientPlayer.field_71082_cx, par6 + (double)par1AbstractClientPlayer.field_71089_bV);
        }
        else
        {
            super.renderLivingAt(par1AbstractClientPlayer, par2, par4, par6);
        }
    }

    /**
     * Rotates the player if the player is sleeping. This method is called in rotateCorpse.
     */
    protected void rotatePlayer(EntityPlayer par1AbstractClientPlayer, float par2, float par3, float par4)
    {
        if (par1AbstractClientPlayer.isEntityAlive() && par1AbstractClientPlayer.isPlayerSleeping())
        {
            EaglerAdapter.glRotatef(par1AbstractClientPlayer.getBedOrientationInDegrees(), 0.0F, 1.0F, 0.0F);
            EaglerAdapter.glRotatef(this.getDeathMaxRotation(par1AbstractClientPlayer), 0.0F, 0.0F, 1.0F);
            EaglerAdapter.glRotatef(270.0F, 0.0F, 1.0F, 0.0F);
        }
        else
        {
            super.rotateCorpse(par1AbstractClientPlayer, par2, par3, par4);
        }
    }

    protected void func_96449_a(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, String par8Str, float par9, double par10)
    {
        this.func_96450_a((EntityPlayer)par1EntityLivingBase, par2, par4, par6, par8Str, par9, par10);
    }

    /**
     * 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)
    {
        this.renderPlayerScale((EntityPlayer)par1EntityLivingBase, par2);
    }

    protected void func_82408_c(EntityLivingBase par1EntityLivingBase, int par2, float par3)
    {
        this.func_130220_b((EntityPlayer)par1EntityLivingBase, par2, par3);
    }

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

    protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2)
    {
        this.renderSpecials((EntityPlayer) par1EntityLivingBase, par2);
    }

    protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4)
    {
        this.rotatePlayer((EntityPlayer) par1EntityLivingBase, par2, par3, par4);
    }

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

    public void doRenderLiving(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, float par8, float par9)
    {
        this.func_130009_a((EntityPlayer)par1EntityLivingBase, par2, par4, par6, par8, par9);
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected TextureLocation getEntityTexture(Entity par1Entity)
    {
        return this.func_110817_a((EntityPlayer)par1Entity);
    }

    /**
     * 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.func_130009_a((EntityPlayer)par1Entity, par2, par4, par6, par8, par9);
    }

    private static final TextureLocation entityTexture = new TextureLocation("/mob/char.png");

    @Override
    protected void bindTexture(EntityLivingBase par1EntityLiving) {
        if(par1EntityLiving instanceof EntityClientPlayerMP) {
            if(EaglerProfile.presetSkinId < 0) {
                Minecraft.getMinecraft().renderEngine.bindTexture(EaglerProfile.skins.get(EaglerProfile.customSkinId).glTex);
            }else {
                TextureLocation tx = null;
                if(DefaultSkinRenderer.defaultVanillaSkins[EaglerProfile.presetSkinId] == null) {
                    if(DefaultSkinRenderer.defaultHighPoly[EaglerProfile.presetSkinId] == null) {
                        tx = entityTexture;
                    }else {
                        if(Minecraft.getMinecraft().gameSettings.allowFNAWSkins) {
                            tx = DefaultSkinRenderer.defaultHighPoly[EaglerProfile.presetSkinId].texture;
                        }else {
                            tx = DefaultSkinRenderer.defaultHighPoly[EaglerProfile.presetSkinId].fallbackTexture;
                        }
                    }
                }else {
                    tx = DefaultSkinRenderer.defaultVanillaSkins[EaglerProfile.presetSkinId];
                }
                tx.bindTexture();
            }
        }else if(par1EntityLiving instanceof EntityOtherPlayerMP) {
            if(!DefaultSkinRenderer.bindSyncedSkin((EntityOtherPlayerMP)par1EntityLiving)) {
                entityTexture.bindTexture();
            }
        }else {
            entityTexture.bindTexture();
        }
    }
}
