    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        private 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].getColorFromDamage(var17.getItemDamage(), 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.drawFirstPersonHand();
    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                    this.mapItemRenderer.renderMap(this.mc.thePlayer, this.mc.renderEngine, var16);
    340                }
    341                else
    342                {
    343                    custom.renderItem(FIRST_PERSON_MAP, var17, mc.thePlayer, mc.renderEngine, var16);
    344                }
    345                GL11.glPopMatrix();
    346            }
    347            else if (var17 != null)
    348            {
    349                GL11.glPushMatrix();
    350                var7 = 0.8F;
    351
    352                if (var3.getItemInUseCount() > 0)
    353                {
    354                    EnumAction var19 = var17.getItemUseAction();
    355
    356                    if (var19 == EnumAction.eat || var19 == EnumAction.drink)
    357                    {
    358                        var21 = (float)var3.getItemInUseCount() - par1 + 1.0F;
    359                        var10 = 1.0F - var21 / (float)var17.getMaxItemUseDuration();
    360                        var11 = 1.0F - var10;
    361                        var11 = var11 * var11 * var11;
    362                        var11 = var11 * var11 * var11;
    363                        var11 = var11 * var11 * var11;
    364                        var12 = 1.0F - var11;
    365                        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);
    366                        GL11.glTranslatef(var12 * 0.6F, -var12 * 0.5F, 0.0F);
    367                        GL11.glRotatef(var12 * 90.0F, 0.0F, 1.0F, 0.0F);
    368                        GL11.glRotatef(var12 * 10.0F, 1.0F, 0.0F, 0.0F);
    369                        GL11.glRotatef(var12 * 30.0F, 0.0F, 0.0F, 1.0F);
    370                    }
    371                }
    372                else
    373                {
    374                    var20 = var3.getSwingProgress(par1);
    375                    var21 = MathHelper.sin(var20 * (float)Math.PI);
    376                    var10 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    377                    GL11.glTranslatef(-var10 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI * 2.0F) * 0.2F, -var21 * 0.2F);
    378                }
    379
    380                GL11.glTranslatef(0.7F * var7, -0.65F * var7 - (1.0F - var2) * 0.6F, -0.9F * var7);
    381                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    382                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    383                var20 = var3.getSwingProgress(par1);
    384                var21 = MathHelper.sin(var20 * var20 * (float)Math.PI);
    385                var10 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    386                GL11.glRotatef(-var21 * 20.0F, 0.0F, 1.0F, 0.0F);
    387                GL11.glRotatef(-var10 * 20.0F, 0.0F, 0.0F, 1.0F);
    388                GL11.glRotatef(-var10 * 80.0F, 1.0F, 0.0F, 0.0F);
    389                var11 = 0.4F;
    390                GL11.glScalef(var11, var11, var11);
    391                float var14;
    392                float var15;
    393
    394                if (var3.getItemInUseCount() > 0)
    395                {
    396                    EnumAction var23 = var17.getItemUseAction();
    397
    398                    if (var23 == EnumAction.block)
    399                    {
    400                        GL11.glTranslatef(-0.5F, 0.2F, 0.0F);
    401                        GL11.glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
    402                        GL11.glRotatef(-80.0F, 1.0F, 0.0F, 0.0F);
    403                        GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F);
    404                    }
    405                    else if (var23 == EnumAction.bow)
    406                    {
    407                        GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F);
    408                        GL11.glRotatef(-12.0F, 0.0F, 1.0F, 0.0F);
    409                        GL11.glRotatef(-8.0F, 1.0F, 0.0F, 0.0F);
    410                        GL11.glTranslatef(-0.9F, 0.2F, 0.0F);
    411                        var13 = (float)var17.getMaxItemUseDuration() - ((float)var3.getItemInUseCount() - par1 + 1.0F);
    412                        var14 = var13 / 20.0F;
    413                        var14 = (var14 * var14 + var14 * 2.0F) / 3.0F;
    414
    415                        if (var14 > 1.0F)
    416                        {
    417                            var14 = 1.0F;
    418                        }
    419
    420                        if (var14 > 0.1F)
    421                        {
    422                            GL11.glTranslatef(0.0F, MathHelper.sin((var13 - 0.1F) * 1.3F) * 0.01F * (var14 - 0.1F), 0.0F);
    423                        }
    424
    425                        GL11.glTranslatef(0.0F, 0.0F, var14 * 0.1F);
    426                        GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F);
    427                        GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
    428                        GL11.glTranslatef(0.0F, 0.5F, 0.0F);
    429                        var15 = 1.0F + var14 * 0.2F;
    430                        GL11.glScalef(1.0F, 1.0F, var15);
    431                        GL11.glTranslatef(0.0F, -0.5F, 0.0F);
    432                        GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
    433                        GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
    434                    }
    435                }
    436
    437                if (var17.getItem().shouldRotateAroundWhenRendering())
    438                {
    439                    GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
    440                }
    441
    442                if (var17.getItem().requiresMultipleRenderPasses())
    443                {
    444                    this.renderItem(var3, var17, 0);
    445                    for (int x = 1; x < var17.getItem().getRenderPasses(var17.getItemDamage()); x++)
    446                    {
    447                        int var25 = Item.itemsList[var17.itemID].getColorFromDamage(var17.getItemDamage(), x);
    448                        var13 = (float)(var25 >> 16 & 255) / 255.0F;
    449                        var14 = (float)(var25 >> 8 & 255) / 255.0F;
    450                        var15 = (float)(var25 & 255) / 255.0F;
    451                        GL11.glColor4f(var6 * var13, var6 * var14, var6 * var15, 1.0F);
    452                        this.renderItem(var3, var17, x);
    453                    }
    454                }
    455                else
    456                {
    457                    this.renderItem(var3, var17, 0);
    458                }
    459
    460                GL11.glPopMatrix();
    461            }
    462            else
    463            {
    464                GL11.glPushMatrix();
    465                var7 = 0.8F;
    466                var20 = var3.getSwingProgress(par1);
    467                var21 = MathHelper.sin(var20 * (float)Math.PI);
    468                var10 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    469                GL11.glTranslatef(-var10 * 0.3F, MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI * 2.0F) * 0.4F, -var21 * 0.4F);
    470                GL11.glTranslatef(0.8F * var7, -0.75F * var7 - (1.0F - var2) * 0.6F, -0.9F * var7);
    471                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    472                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    473                var20 = var3.getSwingProgress(par1);
    474                var21 = MathHelper.sin(var20 * var20 * (float)Math.PI);
    475                var10 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    476                GL11.glRotatef(var10 * 70.0F, 0.0F, 1.0F, 0.0F);
    477                GL11.glRotatef(-var21 * 20.0F, 0.0F, 0.0F, 1.0F);
    478                GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTextureForDownloadableImage(this.mc.thePlayer.skinUrl, this.mc.thePlayer.getTexture()));
    479                GL11.glTranslatef(-1.0F, 3.6F, 3.5F);
    480                GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F);
    481                GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F);
    482                GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
    483                GL11.glScalef(1.0F, 1.0F, 1.0F);
    484                GL11.glTranslatef(5.6F, 0.0F, 0.0F);
    485                var24 = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer);
    486                var26 = (RenderPlayer)var24;
    487                var13 = 1.0F;
    488                GL11.glScalef(var13, var13, var13);
    489                var26.drawFirstPersonHand();
    490                GL11.glPopMatrix();
    491            }
    492
    493            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    494            RenderHelper.disableStandardItemLighting();
    495        }
    496
    497        /**
    498         * Renders all the overlays that are in first person mode. Args: partialTickTime
    499         */
    500        public void renderOverlays(float par1)
    501        {
    502            GL11.glDisable(GL11.GL_ALPHA_TEST);
    503            int var2;
    504
    505            if (this.mc.thePlayer.isBurning())
    506            {
    507                var2 = this.mc.renderEngine.getTexture("/terrain.png");
    508                GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
    509                this.renderFireInFirstPerson(par1);
    510            }
    511
    512            if (this.mc.thePlayer.isEntityInsideOpaqueBlock())
    513            {
    514                var2 = MathHelper.floor_double(this.mc.thePlayer.posX);
    515                int var3 = MathHelper.floor_double(this.mc.thePlayer.posY);
    516                int var4 = MathHelper.floor_double(this.mc.thePlayer.posZ);
    517                int var5 = this.mc.renderEngine.getTexture("/terrain.png");
    518                GL11.glBindTexture(GL11.GL_TEXTURE_2D, var5);
    519                int var6 = this.mc.theWorld.getBlockId(var2, var3, var4);
    520
    521                if (this.mc.theWorld.isBlockNormalCube(var2, var3, var4))
    522                {
    523                    this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2));
    524                }
    525                else
    526                {
    527                    for (int var7 = 0; var7 < 8; ++var7)
    528                    {
    529                        float var8 = ((float)((var7 >> 0) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F;
    530                        float var9 = ((float)((var7 >> 1) % 2) - 0.5F) * this.mc.thePlayer.height * 0.2F;
    531                        float var10 = ((float)((var7 >> 2) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F;
    532                        int var11 = MathHelper.floor_float((float)var2 + var8);
    533                        int var12 = MathHelper.floor_float((float)var3 + var9);
    534                        int var13 = MathHelper.floor_float((float)var4 + var10);
    535
    536                        if (this.mc.theWorld.isBlockNormalCube(var11, var12, var13))
    537                        {
    538                            var6 = this.mc.theWorld.getBlockId(var11, var12, var13);
    539                        }
    540                    }
    541                }
    542
    543                if (Block.blocksList[var6] != null)
    544                {
    545                    this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2));
    546                }
    547            }
    548
    549            if (this.mc.thePlayer.isInsideOfMaterial(Material.water))
    550            {
    551                var2 = this.mc.renderEngine.getTexture("/misc/water.png");
    552                GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2);
    553                this.renderWarpedTextureOverlay(par1);
    554            }
    555
    556            GL11.glEnable(GL11.GL_ALPHA_TEST);
    557        }
    558
    559        /**
    560         * Renders the texture of the block the player is inside as an overlay. Args: partialTickTime, blockTextureIndex
    561         */
    562        private void renderInsideOfBlock(float par1, int par2)
    563        {
    564            Tessellator var3 = Tessellator.instance;
    565            this.mc.thePlayer.getBrightness(par1);
    566            float var4 = 0.1F;
    567            GL11.glColor4f(var4, var4, var4, 0.5F);
    568            GL11.glPushMatrix();
    569            float var5 = -1.0F;
    570            float var6 = 1.0F;
    571            float var7 = -1.0F;
    572            float var8 = 1.0F;
    573            float var9 = -0.5F;
    574            float var10 = 0.0078125F;
    575            float var11 = (float)(par2 % 16) / 256.0F - var10;
    576            float var12 = ((float)(par2 % 16) + 15.99F) / 256.0F + var10;
    577            float var13 = (float)(par2 / 16) / 256.0F - var10;
    578            float var14 = ((float)(par2 / 16) + 15.99F) / 256.0F + var10;
    579            var3.startDrawingQuads();
    580            var3.addVertexWithUV((double)var5, (double)var7, (double)var9, (double)var12, (double)var14);
    581            var3.addVertexWithUV((double)var6, (double)var7, (double)var9, (double)var11, (double)var14);
    582            var3.addVertexWithUV((double)var6, (double)var8, (double)var9, (double)var11, (double)var13);
    583            var3.addVertexWithUV((double)var5, (double)var8, (double)var9, (double)var12, (double)var13);
    584            var3.draw();
    585            GL11.glPopMatrix();
    586            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    587        }
    588
    589        /**
    590         * Renders a texture that warps around based on the direction the player is looking. Texture needs to be bound
    591         * before being called. Used for the water overlay. Args: parialTickTime
    592         */
    593        private void renderWarpedTextureOverlay(float par1)
    594        {
    595            Tessellator var2 = Tessellator.instance;
    596            float var3 = this.mc.thePlayer.getBrightness(par1);
    597            GL11.glColor4f(var3, var3, var3, 0.5F);
    598            GL11.glEnable(GL11.GL_BLEND);
    599            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    600            GL11.glPushMatrix();
    601            float var4 = 4.0F;
    602            float var5 = -1.0F;
    603            float var6 = 1.0F;
    604            float var7 = -1.0F;
    605            float var8 = 1.0F;
    606            float var9 = -0.5F;
    607            float var10 = -this.mc.thePlayer.rotationYaw / 64.0F;
    608            float var11 = this.mc.thePlayer.rotationPitch / 64.0F;
    609            var2.startDrawingQuads();
    610            var2.addVertexWithUV((double)var5, (double)var7, (double)var9, (double)(var4 + var10), (double)(var4 + var11));
    611            var2.addVertexWithUV((double)var6, (double)var7, (double)var9, (double)(0.0F + var10), (double)(var4 + var11));
    612            var2.addVertexWithUV((double)var6, (double)var8, (double)var9, (double)(0.0F + var10), (double)(0.0F + var11));
    613            var2.addVertexWithUV((double)var5, (double)var8, (double)var9, (double)(var4 + var10), (double)(0.0F + var11));
    614            var2.draw();
    615            GL11.glPopMatrix();
    616            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    617            GL11.glDisable(GL11.GL_BLEND);
    618        }
    619
    620        /**
    621         * Renders the fire on the screen for first person mode. Arg: partialTickTime
    622         */
    623        private void renderFireInFirstPerson(float par1)
    624        {
    625            Tessellator var2 = Tessellator.instance;
    626            GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F);
    627            GL11.glEnable(GL11.GL_BLEND);
    628            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    629            float var3 = 1.0F;
    630
    631            for (int var4 = 0; var4 < 2; ++var4)
    632            {
    633                GL11.glPushMatrix();
    634                int var5 = Block.fire.blockIndexInTexture + var4 * 16;
    635                int var6 = (var5 & 15) << 4;
    636                int var7 = var5 & 240;
    637                float var8 = (float)var6 / 256.0F;
    638                float var9 = ((float)var6 + 15.99F) / 256.0F;
    639                float var10 = (float)var7 / 256.0F;
    640                float var11 = ((float)var7 + 15.99F) / 256.0F;
    641                float var12 = (0.0F - var3) / 2.0F;
    642                float var13 = var12 + var3;
    643                float var14 = 0.0F - var3 / 2.0F;
    644                float var15 = var14 + var3;
    645                float var16 = -0.5F;
    646                GL11.glTranslatef((float)(-(var4 * 2 - 1)) * 0.24F, -0.3F, 0.0F);
    647                GL11.glRotatef((float)(var4 * 2 - 1) * 10.0F, 0.0F, 1.0F, 0.0F);
    648                var2.startDrawingQuads();
    649                var2.addVertexWithUV((double)var12, (double)var14, (double)var16, (double)var9, (double)var11);
    650                var2.addVertexWithUV((double)var13, (double)var14, (double)var16, (double)var8, (double)var11);
    651                var2.addVertexWithUV((double)var13, (double)var15, (double)var16, (double)var8, (double)var10);
    652                var2.addVertexWithUV((double)var12, (double)var15, (double)var16, (double)var9, (double)var10);
    653                var2.draw();
    654                GL11.glPopMatrix();
    655            }
    656
    657            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    658            GL11.glDisable(GL11.GL_BLEND);
    659        }
    660
    661        public void updateEquippedItem()
    662        {
    663            this.prevEquippedProgress = this.equippedProgress;
    664            EntityClientPlayerMP var1 = this.mc.thePlayer;
    665            ItemStack var2 = var1.inventory.getCurrentItem();
    666            boolean var3 = this.equippedItemSlot == var1.inventory.currentItem && var2 == this.itemToRender;
    667
    668            if (this.itemToRender == null && var2 == null)
    669            {
    670                var3 = true;
    671            }
    672
    673            if (var2 != null && this.itemToRender != null && var2 != this.itemToRender && var2.itemID == this.itemToRender.itemID && var2.getItemDamage() == this.itemToRender.getItemDamage())
    674            {
    675                this.itemToRender = var2;
    676                var3 = true;
    677            }
    678
    679            float var4 = 0.4F;
    680            float var5 = var3 ? 1.0F : 0.0F;
    681            float var6 = var5 - this.equippedProgress;
    682
    683            if (var6 < -var4)
    684            {
    685                var6 = -var4;
    686            }
    687
    688            if (var6 > var4)
    689            {
    690                var6 = var4;
    691            }
    692
    693            this.equippedProgress += var6;
    694
    695            if (this.equippedProgress < 0.1F)
    696            {
    697                this.itemToRender = var2;
    698                this.equippedItemSlot = var1.inventory.currentItem;
    699            }
    700        }
    701
    702        public void func_78444_b()
    703        {
    704            this.equippedProgress = 0.0F;
    705        }
    706
    707        public void func_78445_c()
    708        {
    709            this.equippedProgress = 0.0F;
    710        }
    711    }