    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.client.TextureFXManager;
    004    import cpw.mods.fml.common.Side;
    005    import cpw.mods.fml.common.asm.SideOnly;
    006    import net.minecraft.client.Minecraft;
    007    import org.lwjgl.opengl.GL11;
    008    import org.lwjgl.opengl.GL12;
    009
    010    import net.minecraftforge.client.ForgeHooksClient;
    011    import net.minecraftforge.client.IItemRenderer;
    012    import net.minecraftforge.client.MinecraftForgeClient;
    013    import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*;
    014    import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*;
    015
    016    @SideOnly(Side.CLIENT)
    017    public class ItemRenderer
    018    {
    019        /** A reference to the Minecraft object. */
    020        private Minecraft mc;
    021        private ItemStack itemToRender = null;
    022
    023        /**
    024         * How far the current item has been equipped (0 disequipped and 1 fully up)
    025         */
    026        private float equippedProgress = 0.0F;
    027        private float prevEquippedProgress = 0.0F;
    028
    029        /** Instance of RenderBlocks. */
    030        private RenderBlocks renderBlocksInstance = new RenderBlocks();
    031        public final MapItemRenderer mapItemRenderer;
    032
    033        /** The index of the currently held item (0-8, or -1 if not yet updated) */
    034        private int equippedItemSlot = -1;
    035
    036        public ItemRenderer(Minecraft par1Minecraft)
    037        {
    038            this.mc = par1Minecraft;
    039            this.mapItemRenderer = new MapItemRenderer(par1Minecraft.fontRenderer, par1Minecraft.gameSettings, par1Minecraft.renderEngine);
    040        }
    041
    042        /**
    043         * Renders the item stack for being in an entity's hand Args: itemStack
    044         */
    045        public void renderItem(EntityLiving par1EntityLiving, ItemStack par2ItemStack, int par3)
    046        {
    047            GL11.glPushMatrix();
    048            IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(par2ItemStack, EQUIPPED);
    049
    050            if (customRenderer != null)
    051            {
    052                GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture(par2ItemStack.getItem().getTextureFile()));
    053                ForgeHooksClient.renderEquippedItem(customRenderer, renderBlocksInstance, par1EntityLiving, par2ItemStack);
    054            }
    055            else if (par2ItemStack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.blocksList[par2ItemStack.itemID].getRenderType()))
    056            {
    057                GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture(par2ItemStack.getItem().getTextureFile()));
    058                this.renderBlocksInstance.renderBlockAsItem(Block.blocksList[par2ItemStack.itemID], par2ItemStack.getItemDamage(), 1.0F);
    059            }
    060            else
    061            {
    062                GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture(par2ItemStack.getItem().getTextureFile()));
    063
    064                Tessellator var5 = Tessellator.instance;
    065                int var6 = par1EntityLiving.getItemIcon(par2ItemStack, par3);
    066                float var7 = ((float)(var6 % 16 * 16) + 0.0F) / 256.0F;
    067                float var8 = ((float)(var6 % 16 * 16) + 15.99F) / 256.0F;
    068                float var9 = ((float)(var6 / 16 * 16) + 0.0F) / 256.0F;
    069                float var10 = ((float)(var6 / 16 * 16) + 15.99F) / 256.0F;
    070                float var11 = 0.0F;
    071                float var12 = 0.3F;
    072                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    073                GL11.glTranslatef(-var11, -var12, 0.0F);
    074                float var13 = 1.5F;
    075                GL11.glScalef(var13, var13, var13);
    076                GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
    077                GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
    078                GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
    079                this.renderItemIn2D(var5, var8, var9, var7, var10);
    080
    081                if (par2ItemStack != null && par2ItemStack.hasEffect() && par3 == 0)
    082                {
    083                    GL11.glDepthFunc(GL11.GL_EQUAL);
    084                    GL11.glDisable(GL11.GL_LIGHTING);
    085                    this.mc.renderEngine.bindTexture(this.mc.renderEngine.getTexture("%blur%/misc/glint.png"));
    086                    GL11.glEnable(GL11.GL_BLEND);
    087                    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    088                    float var14 = 0.76F;
    089                    GL11.glColor4f(0.5F * var14, 0.25F * var14, 0.8F * var14, 1.0F);
    090                    GL11.glMatrixMode(GL11.GL_TEXTURE);
    091                    GL11.glPushMatrix();
    092                    float var15 = 0.125F;
    093                    GL11.glScalef(var15, var15, var15);
    094                    float var16 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
    095                    GL11.glTranslatef(var16, 0.0F, 0.0F);
    096                    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    097                    this.renderItemIn2D(var5, 0.0F, 0.0F, 1.0F, 1.0F);
    098                    GL11.glPopMatrix();
    099                    GL11.glPushMatrix();
    100                    GL11.glScalef(var15, var15, var15);
    101                    var16 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
    102                    GL11.glTranslatef(-var16, 0.0F, 0.0F);
    103                    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
    104                    this.renderItemIn2D(var5, 0.0F, 0.0F, 1.0F, 1.0F);
    105                    GL11.glPopMatrix();
    106                    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    107                    GL11.glDisable(GL11.GL_BLEND);
    108                    GL11.glEnable(GL11.GL_LIGHTING);
    109                    GL11.glDepthFunc(GL11.GL_LEQUAL);
    110                }
    111
    112                GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    113            }
    114
    115            GL11.glPopMatrix();
    116        }
    117
    118        /**
    119         * Renders an item held in hand as a 2D texture with thickness
    120         */
    121        private void renderItemIn2D(Tessellator par1Tessellator, float par2, float par3, float par4, float par5)
    122        {
    123            float var6 = 1.0F;
    124            float var7 = 0.0625F;
    125            par1Tessellator.startDrawingQuads();
    126            par1Tessellator.setNormal(0.0F, 0.0F, 1.0F);
    127            par1Tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)par2, (double)par5);
    128            par1Tessellator.addVertexWithUV((double)var6, 0.0D, 0.0D, (double)par4, (double)par5);
    129            par1Tessellator.addVertexWithUV((double)var6, 1.0D, 0.0D, (double)par4, (double)par3);
    130            par1Tessellator.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)par2, (double)par3);
    131            par1Tessellator.draw();
    132            par1Tessellator.startDrawingQuads();
    133            par1Tessellator.setNormal(0.0F, 0.0F, -1.0F);
    134            par1Tessellator.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - var7), (double)par2, (double)par3);
    135            par1Tessellator.addVertexWithUV((double)var6, 1.0D, (double)(0.0F - var7), (double)par4, (double)par3);
    136            par1Tessellator.addVertexWithUV((double)var6, 0.0D, (double)(0.0F - var7), (double)par4, (double)par5);
    137            par1Tessellator.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - var7), (double)par2, (double)par5);
    138            par1Tessellator.draw();
    139            par1Tessellator.startDrawingQuads();
    140            par1Tessellator.setNormal(-1.0F, 0.0F, 0.0F);
    141            int var8;
    142            float var9;
    143            float var10;
    144            float var11;
    145
    146            /* Gets the width/16 of the currently bound texture, used
    147             * to fix the side rendering issues on textures != 16 */
    148            int tileSize = TextureFXManager.instance().getTextureDimensions(GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D)).width / 16;
    149
    150            float tx = 1.0f / (32 * tileSize);
    151            float tz = 1.0f /  tileSize;
    152
    153            for (var8 = 0; var8 < tileSize; ++var8)
    154            {
    155                var9 = (float)var8 / tileSize;
    156                var10 = par2 + (par4 - par2) * var9 - tx;
    157                var11 = var6 * var9;
    158                par1Tessellator.addVertexWithUV((double)var11, 0.0D, (double)(0.0F - var7), (double)var10, (double)par5);
    159                par1Tessellator.addVertexWithUV((double)var11, 0.0D, 0.0D, (double)var10, (double)par5);
    160                par1Tessellator.addVertexWithUV((double)var11, 1.0D, 0.0D, (double)var10, (double)par3);
    161                par1Tessellator.addVertexWithUV((double)var11, 1.0D, (double)(0.0F - var7), (double)var10, (double)par3);
    162            }
    163
    164            par1Tessellator.draw();
    165            par1Tessellator.startDrawingQuads();
    166            par1Tessellator.setNormal(1.0F, 0.0F, 0.0F);
    167
    168            for (var8 = 0; var8 < tileSize; ++var8)
    169            {
    170                var9 = (float)var8 / tileSize;
    171                var10 = par2 + (par4 - par2) * var9 - tx;
    172                var11 = var6 * var9 + tz;
    173                par1Tessellator.addVertexWithUV((double)var11, 1.0D, (double)(0.0F - var7), (double)var10, (double)par3);
    174                par1Tessellator.addVertexWithUV((double)var11, 1.0D, 0.0D, (double)var10, (double)par3);
    175                par1Tessellator.addVertexWithUV((double)var11, 0.0D, 0.0D, (double)var10, (double)par5);
    176                par1Tessellator.addVertexWithUV((double)var11, 0.0D, (double)(0.0F - var7), (double)var10, (double)par5);
    177            }
    178
    179            par1Tessellator.draw();
    180            par1Tessellator.startDrawingQuads();
    181            par1Tessellator.setNormal(0.0F, 1.0F, 0.0F);
    182
    183            for (var8 = 0; var8 < tileSize; ++var8)
    184            {
    185                var9 = (float)var8 / tileSize;
    186                var10 = par5 + (par3 - par5) * var9 - tx;
    187                var11 = var6 * var9 + tz;
    188                par1Tessellator.addVertexWithUV(0.0D, (double)var11, 0.0D, (double)par2, (double)var10);
    189                par1Tessellator.addVertexWithUV((double)var6, (double)var11, 0.0D, (double)par4, (double)var10);
    190                par1Tessellator.addVertexWithUV((double)var6, (double)var11, (double)(0.0F - var7), (double)par4, (double)var10);
    191                par1Tessellator.addVertexWithUV(0.0D, (double)var11, (double)(0.0F - var7), (double)par2, (double)var10);
    192            }
    193
    194            par1Tessellator.draw();
    195            par1Tessellator.startDrawingQuads();
    196            par1Tessellator.setNormal(0.0F, -1.0F, 0.0F);
    197
    198            for (var8 = 0; var8 < tileSize; ++var8)
    199            {
    200                var9 = (float)var8 / tileSize;
    201                var10 = par5 + (par3 - par5) * var9 - tx;
    202                var11 = var6 * var9;
    203                par1Tessellator.addVertexWithUV((double)var6, (double)var11, 0.0D, (double)par4, (double)var10);
    204                par1Tessellator.addVertexWithUV(0.0D, (double)var11, 0.0D, (double)par2, (double)var10);
    205                par1Tessellator.addVertexWithUV(0.0D, (double)var11, (double)(0.0F - var7), (double)par2, (double)var10);
    206                par1Tessellator.addVertexWithUV((double)var6, (double)var11, (double)(0.0F - var7), (double)par4, (double)var10);
    207            }
    208
    209            par1Tessellator.draw();
    210        }
    211
    212        /**
    213         * Renders the active item in the player's hand when in first person mode. Args: partialTickTime
    214         */
    215        public void renderItemInFirstPerson(float par1)
    216        {
    217            float var2 = this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * par1;
    218            EntityClientPlayerMP var3 = this.mc.thePlayer;
    219            float var4 = var3.prevRotationPitch + (var3.rotationPitch - var3.prevRotationPitch) * par1;
    220            GL11.glPushMatrix();
    221            GL11.glRotatef(var4, 1.0F, 0.0F, 0.0F);
    222            GL11.glRotatef(var3.prevRotationYaw + (var3.rotationYaw - var3.prevRotationYaw) * par1, 0.0F, 1.0F, 0.0F);
    223            RenderHelper.enableStandardItemLighting();
    224            GL11.glPopMatrix();
    225            float var6;
    226            float var7;
    227
    228            if (var3 instanceof EntityPlayerSP)
    229            {
    230                EntityPlayerSP var5 = (EntityPlayerSP)var3;
    231                var6 = var5.prevRenderArmPitch + (var5.renderArmPitch - var5.prevRenderArmPitch) * par1;
    232                var7 = var5.prevRenderArmYaw + (var5.renderArmYaw - var5.prevRenderArmYaw) * par1;
    233                GL11.glRotatef((var3.rotationPitch - var6) * 0.1F, 1.0F, 0.0F, 0.0F);
    234                GL11.glRotatef((var3.rotationYaw - var7) * 0.1F, 0.0F, 1.0F, 0.0F);
    235            }
    236
    237            ItemStack var17 = this.itemToRender;
    238            var6 = this.mc.theWorld.getLightBrightness(MathHelper.floor_double(var3.posX), MathHelper.floor_double(var3.posY), MathHelper.floor_double(var3.posZ));
    239            var6 = 1.0F;
    240            int var18 = this.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(var3.posX), MathHelper.floor_double(var3.posY), MathHelper.floor_double(var3.posZ), 0);
    241            int var8 = var18 % 65536;
    242            int var9 = var18 / 65536;
    243            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var8 / 1.0F, (float)var9 / 1.0F);
    244            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    245            float var10;
    246            float var21;
    247            float var20;
    248
    249            if (var17 != null)
    250            {
    251                var18 = Item.itemsList[var17.itemID].func_82790_a(var17, 0);
    252                var20 = (float)(var18 >> 16 & 255) / 255.0F;
    253                var21 = (float)(var18 >> 8 & 255) / 255.0F;
    254                var10 = (float)(var18 & 255) / 255.0F;
    255                GL11.glColor4f(var6 * var20, var6 * var21, var6 * var10, 1.0F);
    256            }
    257            else
    258            {
    259                GL11.glColor4f(var6, var6, var6, 1.0F);
    260            }
    261
    262            float var11;
    263            float var12;
    264            float var13;
    265            Render var24;
    266            RenderPlayer var26;
    267
    268            if (var17 != null && var17.getItem() instanceof ItemMap)
    269            {
    270                IItemRenderer custom = MinecraftForgeClient.getItemRenderer(var17, FIRST_PERSON_MAP);
    271                GL11.glPushMatrix();
    272                var7 = 0.8F;
    273                var20 = var3.getSwingProgress(par1);
    274                var21 = MathHelper.sin(var20 * (float)Math.PI);
    275                var10 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    276                GL11.glTranslatef(-var10 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI * 2.0F) * 0.2F, -var21 * 0.2F);
    277                var20 = 1.0F - var4 / 45.0F + 0.1F;
    278
    279                if (var20 < 0.0F)
    280                {
    281                    var20 = 0.0F;
    282                }
    283
    284                if (var20 > 1.0F)
    285                {
    286                    var20 = 1.0F;
    287                }
    288
    289                var20 = -MathHelper.cos(var20 * (float)Math.PI) * 0.5F + 0.5F;
    290                GL11.glTranslatef(0.0F, 0.0F * var7 - (1.0F - var2) * 1.2F - var20 * 0.5F + 0.04F, -0.9F * var7);
    291                GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
    292                GL11.glRotatef(var20 * -85.0F, 0.0F, 0.0F, 1.0F);
    293                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    294                GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTextureForDownloadableImage(this.mc.thePlayer.skinUrl, this.mc.thePlayer.getTexture()));
    295
    296                for (var9 = 0; var9 < 2; ++var9)
    297                {
    298                    int var22 = var9 * 2 - 1;
    299                    GL11.glPushMatrix();
    300                    GL11.glTranslatef(-0.0F, -0.6F, 1.1F * (float)var22);
    301                    GL11.glRotatef((float)(-45 * var22), 1.0F, 0.0F, 0.0F);
    302                    GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
    303                    GL11.glRotatef(59.0F, 0.0F, 0.0F, 1.0F);
    304                    GL11.glRotatef((float)(-65 * var22), 0.0F, 1.0F, 0.0F);
    305                    var24 = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer);
    306                    var26 = (RenderPlayer)var24;
    307                    var13 = 1.0F;
    308                    GL11.glScalef(var13, var13, var13);
    309                    var26.func_82441_a(this.mc.thePlayer);
    310                    GL11.glPopMatrix();
    311                }
    312
    313                var21 = var3.getSwingProgress(par1);
    314                var10 = MathHelper.sin(var21 * var21 * (float)Math.PI);
    315                var11 = MathHelper.sin(MathHelper.sqrt_float(var21) * (float)Math.PI);
    316                GL11.glRotatef(-var10 * 20.0F, 0.0F, 1.0F, 0.0F);
    317                GL11.glRotatef(-var11 * 20.0F, 0.0F, 0.0F, 1.0F);
    318                GL11.glRotatef(-var11 * 80.0F, 1.0F, 0.0F, 0.0F);
    319                var12 = 0.38F;
    320                GL11.glScalef(var12, var12, var12);
    321                GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
    322                GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
    323                GL11.glTranslatef(-1.0F, -1.0F, 0.0F);
    324                var13 = 0.015625F;
    325                GL11.glScalef(var13, var13, var13);
    326                this.mc.renderEngine.bindTexture(this.mc.renderEngine.getTexture("/misc/mapbg.png"));
    327                Tessellator var28 = Tessellator.instance;
    328                GL11.glNormal3f(0.0F, 0.0F, -1.0F);
    329                var28.startDrawingQuads();
    330                byte var27 = 7;
    331                var28.addVertexWithUV((double)(0 - var27), (double)(128 + var27), 0.0D, 0.0D, 1.0D);
    332                var28.addVertexWithUV((double)(128 + var27), (double)(128 + var27), 0.0D, 1.0D, 1.0D);
    333                var28.addVertexWithUV((double)(128 + var27), (double)(0 - var27), 0.0D, 1.0D, 0.0D);
    334                var28.addVertexWithUV((double)(0 - var27), (double)(0 - var27), 0.0D, 0.0D, 0.0D);
    335                var28.draw();
    336                MapData var16 = ((ItemMap)var17.getItem()).getMapData(var17, this.mc.theWorld);
    337                if (custom == null)
    338                {
    339                    if (var16 != null)
    340                    {
    341                        this.mapItemRenderer.renderMap(this.mc.thePlayer, this.mc.renderEngine, var16);
    342                    }
    343                }
    344                else
    345                {
    346                    custom.renderItem(FIRST_PERSON_MAP, var17, mc.thePlayer, mc.renderEngine, var16);
    347                }
    348
    349                GL11.glPopMatrix();
    350            }
    351            else if (var17 != null)
    352            {
    353                GL11.glPushMatrix();
    354                var7 = 0.8F;
    355
    356                if (var3.getItemInUseCount() > 0)
    357                {
    358                    EnumAction var19 = var17.getItemUseAction();
    359
    360                    if (var19 == EnumAction.eat || var19 == EnumAction.drink)
    361                    {
    362                        var21 = (float)var3.getItemInUseCount() - par1 + 1.0F;
    363                        var10 = 1.0F - var21 / (float)var17.getMaxItemUseDuration();
    364                        var11 = 1.0F - var10;
    365                        var11 = var11 * var11 * var11;
    366                        var11 = var11 * var11 * var11;
    367                        var11 = var11 * var11 * var11;
    368                        var12 = 1.0F - var11;
    369                        GL11.glTranslatef(0.0F, MathHelper.abs(MathHelper.cos(var21 / 4.0F * (float)Math.PI) * 0.1F) * (float)((double)var10 > 0.2D ? 1 : 0), 0.0F);
    370                        GL11.glTranslatef(var12 * 0.6F, -var12 * 0.5F, 0.0F);
    371                        GL11.glRotatef(var12 * 90.0F, 0.0F, 1.0F, 0.0F);
    372                        GL11.glRotatef(var12 * 10.0F, 1.0F, 0.0F, 0.0F);
    373                        GL11.glRotatef(var12 * 30.0F, 0.0F, 0.0F, 1.0F);
    374                    }
    375                }
    376                else
    377                {
    378                    var20 = var3.getSwingProgress(par1);
    379                    var21 = MathHelper.sin(var20 * (float)Math.PI);
    380                    var10 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    381                    GL11.glTranslatef(-var10 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI * 2.0F) * 0.2F, -var21 * 0.2F);
    382                }
    383
    384                GL11.glTranslatef(0.7F * var7, -0.65F * var7 - (1.0F - var2) * 0.6F, -0.9F * var7);
    385                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    386                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    387                var20 = var3.getSwingProgress(par1);
    388                var21 = MathHelper.sin(var20 * var20 * (float)Math.PI);
    389                var10 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    390                GL11.glRotatef(-var21 * 20.0F, 0.0F, 1.0F, 0.0F);
    391                GL11.glRotatef(-var10 * 20.0F, 0.0F, 0.0F, 1.0F);
    392                GL11.glRotatef(-var10 * 80.0F, 1.0F, 0.0F, 0.0F);
    393                var11 = 0.4F;
    394                GL11.glScalef(var11, var11, var11);
    395                float var14;
    396                float var15;
    397
    398                if (var3.getItemInUseCount() > 0)
    399                {
    400                    EnumAction var23 = var17.getItemUseAction();
    401
    402                    if (var23 == EnumAction.block)
    403                    {
    404                        GL11.glTranslatef(-0.5F, 0.2F, 0.0F);
    405                        GL11.glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
    406                        GL11.glRotatef(-80.0F, 1.0F, 0.0F, 0.0F);
    407                        GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F);
    408                    }
    409                    else if (var23 == EnumAction.bow)
    410                    {
    411                        GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F);
    412                        GL11.glRotatef(-12.0F, 0.0F, 1.0F, 0.0F);
    413                        GL11.glRotatef(-8.0F, 1.0F, 0.0F, 0.0F);
    414                        GL11.glTranslatef(-0.9F, 0.2F, 0.0F);
    415                        var13 = (float)var17.getMaxItemUseDuration() - ((float)var3.getItemInUseCount() - par1 + 1.0F);
    416                        var14 = var13 / 20.0F;
    417                        var14 = (var14 * var14 + var14 * 2.0F) / 3.0F;
    418
    419                        if (var14 > 1.0F)
    420                        {
    421                            var14 = 1.0F;
    422                        }
    423
    424                        if (var14 > 0.1F)
    425                        {
    426                            GL11.glTranslatef(0.0F, MathHelper.sin((var13 - 0.1F) * 1.3F) * 0.01F * (var14 - 0.1F), 0.0F);
    427                        }
    428
    429                        GL11.glTranslatef(0.0F, 0.0F, var14 * 0.1F);
    430                        GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F);
    431                        GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
    432                        GL11.glTranslatef(0.0F, 0.5F, 0.0F);
    433                        var15 = 1.0F + var14 * 0.2F;
    434                        GL11.glScalef(1.0F, 1.0F, var15);
    435                        GL11.glTranslatef(0.0F, -0.5F, 0.0F);
    436                        GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
    437                        GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
    438                    }
    439                }
    440
    441                if (var17.getItem().shouldRotateAroundWhenRendering())
    442                {
    443                    GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
    444                }
    445
    446                if (var17.getItem().requiresMultipleRenderPasses())
    447                {
    448                    this.renderItem(var3, var17, 0);
    449                    for (int x = 1; x < var17.getItem().getRenderPasses(var17.getItemDamage()); x++)
    450                    {
    451                        int var25 = Item.itemsList[var17.itemID].func_82790_a(var17, x);
    452                        var13 = (float)(var25 >> 16 & 255) / 255.0F;
    453                        var14 = (float)(var25 >> 8 & 255) / 255.0F;
    454                        var15 = (float)(var25 & 255) / 255.0F;
    455                        GL11.glColor4f(var6 * var13, var6 * var14, var6 * var15, 1.0F);
    456                        this.renderItem(var3, var17, x);
    457                    }
    458                }
    459                else
    460                {
    461                    this.renderItem(var3, var17, 0);
    462                }
    463
    464                GL11.glPopMatrix();
    465            }
    466            else if (!var3.func_82150_aj())
    467            {
    468                GL11.glPushMatrix();
    469                var7 = 0.8F;
    470                var20 = var3.getSwingProgress(par1);
    471                var21 = MathHelper.sin(var20 * (float)Math.PI);
    472                var10 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    473                GL11.glTranslatef(-var10 * 0.3F, MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI * 2.0F) * 0.4F, -var21 * 0.4F);
    474                GL11.glTranslatef(0.8F * var7, -0.75F * var7 - (1.0F - var2) * 0.6F, -0.9F * var7);
    475                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    476                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    477                var20 = var3.getSwingProgress(par1);
    478                var21 = MathHelper.sin(var20 * var20 * (float)Math.PI);
    479                var10 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    480                GL11.glRotatef(var10 * 70.0F, 0.0F, 1.0F, 0.0F);
    481                GL11.glRotatef(-var21 * 20.0F, 0.0F, 0.0F, 1.0F);
    482                GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTextureForDownloadableImage(this.mc.thePlayer.skinUrl, this.mc.thePlayer.getTexture()));
    483                GL11.glTranslatef(-1.0F, 3.6F, 3.5F);
    484                GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F);
    485                GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F);
    486                GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
    487                GL11.glScalef(1.0F, 1.0F, 1.0F);
    488                GL11.glTranslatef(5.6F, 0.0F, 0.0F);
    489                var24 = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer);
    490                var26 = (RenderPlayer)var24;
    491                var13 = 1.0F;
    492                GL11.glScalef(var13, var13, var13);
    493                var26.func_82441_a(this.mc.thePlayer);
    494                GL11.glPopMatrix();
    495            }
    496
    497            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    498            RenderHelper.disableStandardItemLighting();
    499        }
    500
    501        /**
    502         * Renders all the overlays that are in first person mode. Args: partialTickTime
    503         */
    504        public void renderOverlays(float par1)
    505        {
    506            GL11.glDisable(GL11.GL_ALPHA_TEST);
    507            int var2;
    508
    509            if (this.mc.thePlayer.isBurning())
    510            {
    511                var2 = this.mc.renderEngine.getTexture("/terrain.png");
    512                GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
    513                this.renderFireInFirstPerson(par1);
    514            }
    515
    516            if (this.mc.thePlayer.isEntityInsideOpaqueBlock())
    517            {
    518                var2 = MathHelper.floor_double(this.mc.thePlayer.posX);
    519                int var3 = MathHelper.floor_double(this.mc.thePlayer.posY);
    520                int var4 = MathHelper.floor_double(this.mc.thePlayer.posZ);
    521                int var5 = this.mc.renderEngine.getTexture("/terrain.png");
    522                GL11.glBindTexture(GL11.GL_TEXTURE_2D, var5);
    523                int var6 = this.mc.theWorld.getBlockId(var2, var3, var4);
    524
    525                if (this.mc.theWorld.isBlockNormalCube(var2, var3, var4))
    526                {
    527                    this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2));
    528                }
    529                else
    530                {
    531                    for (int var7 = 0; var7 < 8; ++var7)
    532                    {
    533                        float var8 = ((float)((var7 >> 0) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F;
    534                        float var9 = ((float)((var7 >> 1) % 2) - 0.5F) * this.mc.thePlayer.height * 0.2F;
    535                        float var10 = ((float)((var7 >> 2) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F;
    536                        int var11 = MathHelper.floor_float((float)var2 + var8);
    537                        int var12 = MathHelper.floor_float((float)var3 + var9);
    538                        int var13 = MathHelper.floor_float((float)var4 + var10);
    539
    540                        if (this.mc.theWorld.isBlockNormalCube(var11, var12, var13))
    541                        {
    542                            var6 = this.mc.theWorld.getBlockId(var11, var12, var13);
    543                        }
    544                    }
    545                }
    546
    547                if (Block.blocksList[var6] != null)
    548                {
    549                    this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2));
    550                }
    551            }
    552
    553            if (this.mc.thePlayer.isInsideOfMaterial(Material.water))
    554            {
    555                var2 = this.mc.renderEngine.getTexture("/misc/water.png");
    556                GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
    557                this.renderWarpedTextureOverlay(par1);
    558            }
    559
    560            GL11.glEnable(GL11.GL_ALPHA_TEST);
    561        }
    562
    563        /**
    564         * Renders the texture of the block the player is inside as an overlay. Args: partialTickTime, blockTextureIndex
    565         */
    566        private void renderInsideOfBlock(float par1, int par2)
    567        {
    568            Tessellator var3 = Tessellator.instance;
    569            this.mc.thePlayer.getBrightness(par1);
    570            float var4 = 0.1F;
    571            GL11.glColor4f(var4, var4, var4, 0.5F);
    572            GL11.glPushMatrix();
    573            float var5 = -1.0F;
    574            float var6 = 1.0F;
    575            float var7 = -1.0F;
    576            float var8 = 1.0F;
    577            float var9 = -0.5F;
    578            float var10 = 0.0078125F;
    579            float var11 = (float)(par2 % 16) / 256.0F - var10;
    580            float var12 = ((float)(par2 % 16) + 15.99F) / 256.0F + var10;
    581            float var13 = (float)(par2 / 16) / 256.0F - var10;
    582            float var14 = ((float)(par2 / 16) + 15.99F) / 256.0F + var10;
    583            var3.startDrawingQuads();
    584            var3.addVertexWithUV((double)var5, (double)var7, (double)var9, (double)var12, (double)var14);
    585            var3.addVertexWithUV((double)var6, (double)var7, (double)var9, (double)var11, (double)var14);
    586            var3.addVertexWithUV((double)var6, (double)var8, (double)var9, (double)var11, (double)var13);
    587            var3.addVertexWithUV((double)var5, (double)var8, (double)var9, (double)var12, (double)var13);
    588            var3.draw();
    589            GL11.glPopMatrix();
    590            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    591        }
    592
    593        /**
    594         * Renders a texture that warps around based on the direction the player is looking. Texture needs to be bound
    595         * before being called. Used for the water overlay. Args: parialTickTime
    596         */
    597        private void renderWarpedTextureOverlay(float par1)
    598        {
    599            Tessellator var2 = Tessellator.instance;
    600            float var3 = this.mc.thePlayer.getBrightness(par1);
    601            GL11.glColor4f(var3, var3, var3, 0.5F);
    602            GL11.glEnable(GL11.GL_BLEND);
    603            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    604            GL11.glPushMatrix();
    605            float var4 = 4.0F;
    606            float var5 = -1.0F;
    607            float var6 = 1.0F;
    608            float var7 = -1.0F;
    609            float var8 = 1.0F;
    610            float var9 = -0.5F;
    611            float var10 = -this.mc.thePlayer.rotationYaw / 64.0F;
    612            float var11 = this.mc.thePlayer.rotationPitch / 64.0F;
    613            var2.startDrawingQuads();
    614            var2.addVertexWithUV((double)var5, (double)var7, (double)var9, (double)(var4 + var10), (double)(var4 + var11));
    615            var2.addVertexWithUV((double)var6, (double)var7, (double)var9, (double)(0.0F + var10), (double)(var4 + var11));
    616            var2.addVertexWithUV((double)var6, (double)var8, (double)var9, (double)(0.0F + var10), (double)(0.0F + var11));
    617            var2.addVertexWithUV((double)var5, (double)var8, (double)var9, (double)(var4 + var10), (double)(0.0F + var11));
    618            var2.draw();
    619            GL11.glPopMatrix();
    620            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    621            GL11.glDisable(GL11.GL_BLEND);
    622        }
    623
    624        /**
    625         * Renders the fire on the screen for first person mode. Arg: partialTickTime
    626         */
    627        private void renderFireInFirstPerson(float par1)
    628        {
    629            Tessellator var2 = Tessellator.instance;
    630            GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F);
    631            GL11.glEnable(GL11.GL_BLEND);
    632            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    633            float var3 = 1.0F;
    634
    635            for (int var4 = 0; var4 < 2; ++var4)
    636            {
    637                GL11.glPushMatrix();
    638                int var5 = Block.fire.blockIndexInTexture + var4 * 16;
    639                int var6 = (var5 & 15) << 4;
    640                int var7 = var5 & 240;
    641                float var8 = (float)var6 / 256.0F;
    642                float var9 = ((float)var6 + 15.99F) / 256.0F;
    643                float var10 = (float)var7 / 256.0F;
    644                float var11 = ((float)var7 + 15.99F) / 256.0F;
    645                float var12 = (0.0F - var3) / 2.0F;
    646                float var13 = var12 + var3;
    647                float var14 = 0.0F - var3 / 2.0F;
    648                float var15 = var14 + var3;
    649                float var16 = -0.5F;
    650                GL11.glTranslatef((float)(-(var4 * 2 - 1)) * 0.24F, -0.3F, 0.0F);
    651                GL11.glRotatef((float)(var4 * 2 - 1) * 10.0F, 0.0F, 1.0F, 0.0F);
    652                var2.startDrawingQuads();
    653                var2.addVertexWithUV((double)var12, (double)var14, (double)var16, (double)var9, (double)var11);
    654                var2.addVertexWithUV((double)var13, (double)var14, (double)var16, (double)var8, (double)var11);
    655                var2.addVertexWithUV((double)var13, (double)var15, (double)var16, (double)var8, (double)var10);
    656                var2.addVertexWithUV((double)var12, (double)var15, (double)var16, (double)var9, (double)var10);
    657                var2.draw();
    658                GL11.glPopMatrix();
    659            }
    660
    661            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    662            GL11.glDisable(GL11.GL_BLEND);
    663        }
    664
    665        public void updateEquippedItem()
    666        {
    667            this.prevEquippedProgress = this.equippedProgress;
    668            EntityClientPlayerMP var1 = this.mc.thePlayer;
    669            ItemStack var2 = var1.inventory.getCurrentItem();
    670            boolean var3 = this.equippedItemSlot == var1.inventory.currentItem && var2 == this.itemToRender;
    671
    672            if (this.itemToRender == null && var2 == null)
    673            {
    674                var3 = true;
    675            }
    676
    677            if (var2 != null && this.itemToRender != null && var2 != this.itemToRender && var2.itemID == this.itemToRender.itemID && var2.getItemDamage() == this.itemToRender.getItemDamage())
    678            {
    679                this.itemToRender = var2;
    680                var3 = true;
    681            }
    682
    683            float var4 = 0.4F;
    684            float var5 = var3 ? 1.0F : 0.0F;
    685            float var6 = var5 - this.equippedProgress;
    686
    687            if (var6 < -var4)
    688            {
    689                var6 = -var4;
    690            }
    691
    692            if (var6 > var4)
    693            {
    694                var6 = var4;
    695            }
    696
    697            this.equippedProgress += var6;
    698
    699            if (this.equippedProgress < 0.1F)
    700            {
    701                this.itemToRender = var2;
    702                this.equippedItemSlot = var1.inventory.currentItem;
    703            }
    704        }
    705
    706        public void func_78444_b()
    707        {
    708            this.equippedProgress = 0.0F;
    709        }
    710
    711        public void func_78445_c()
    712        {
    713            this.equippedProgress = 0.0F;
    714        }
    715    }