/// <summary>
        /// Handle a player information packet.
        /// </summary>
        public override void HandlePlayerInfo(Packet201PlayerInfo par1Packet201PlayerInfo)
        {
            GuiPlayerInfo guiplayerinfo = PlayerInfoMap[par1Packet201PlayerInfo.PlayerName];

            if (guiplayerinfo == null && par1Packet201PlayerInfo.IsConnected)
            {
                guiplayerinfo = new GuiPlayerInfo(par1Packet201PlayerInfo.PlayerName);
                PlayerInfoMap[par1Packet201PlayerInfo.PlayerName] = guiplayerinfo;
                PlayerNames.Add(guiplayerinfo);
            }

            if (guiplayerinfo != null && !par1Packet201PlayerInfo.IsConnected)
            {
                PlayerInfoMap.Remove(par1Packet201PlayerInfo.PlayerName);
                PlayerNames.Remove(guiplayerinfo);
            }

            if (par1Packet201PlayerInfo.IsConnected && guiplayerinfo != null)
            {
                guiplayerinfo.ResponseTime = par1Packet201PlayerInfo.Ping;
            }
        }
        /// <summary>
        /// Autocompletes player name
        /// </summary>
        public virtual void CompletePlayerName()
        {
            if (Field_50060_d)
            {
                Field_50064_a.Func_50021_a(-1);

                if (Field_50067_h >= Field_50068_i.Count)
                {
                    Field_50067_h = 0;
                }
            }
            else
            {
                int i = Field_50064_a.Func_50028_c(-1);

                if (Field_50064_a.Func_50035_h() - i < 1)
                {
                    return;
                }

                Field_50068_i.Clear();
                Field_50061_e = Field_50064_a.GetText().Substring(i);
                Field_50059_f = Field_50061_e.ToLower();
                IEnumerator <GuiPlayerInfo> iterator = ((EntityClientPlayerMP)Mc.ThePlayer).SendQueue.PlayerNames.GetEnumerator();

                do
                {
                    if (!iterator.MoveNext())
                    {
                        break;
                    }

                    GuiPlayerInfo guiplayerinfo = iterator.Current;

                    if (guiplayerinfo.NameStartsWith(Field_50059_f))
                    {
                        Field_50068_i.Add(guiplayerinfo);
                    }
                }while (true);

                if (Field_50068_i.Count == 0)
                {
                    return;
                }

                Field_50060_d = true;
                Field_50067_h = 0;
                Field_50064_a.Func_50020_b(i - Field_50064_a.Func_50035_h());
            }

            if (Field_50068_i.Count > 1)
            {
                StringBuilder stringbuilder = new StringBuilder();
                GuiPlayerInfo guiplayerinfo1;

                for (IEnumerator <GuiPlayerInfo> iterator1 = Field_50068_i.GetEnumerator(); iterator1.MoveNext(); stringbuilder.Append(guiplayerinfo1.Name))
                {
                    guiplayerinfo1 = iterator1.Current;

                    if (stringbuilder.Length > 0)
                    {
                        stringbuilder.Append(", ");
                    }
                }

                Mc.IngameGUI.AddChatMessage(stringbuilder.ToString());
            }

            Field_50064_a.Func_50031_b(Field_50068_i[Field_50067_h++].Name);
        }
Esempio n. 3
0
        /// <summary>
        /// Render the ingame overlay with quick icon bar, ...
        /// </summary>
        public virtual void RenderGameOverlay(float par1, bool par2, int par3, int par4)
        {
            ScaledResolution scaledresolution = new ScaledResolution(mc.GameSettings, mc.DisplayWidth, mc.DisplayHeight);
            int          i            = scaledresolution.GetScaledWidth();
            int          j            = scaledresolution.GetScaledHeight();
            FontRenderer fontrenderer = mc.FontRenderer;

            mc.EntityRenderer.SetupOverlayRendering();
            //GL.Enable(EnableCap.Blend);

            if (Minecraft.IsFancyGraphicsEnabled())
            {
                RenderVignette(mc.ThePlayer.GetBrightness(par1), i, j);
            }
            else
            {
                //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            }

            ItemStack itemstack = mc.ThePlayer.Inventory.ArmorItemInSlot(3);

            if (mc.GameSettings.ThirdPersonView == 0 && itemstack != null && itemstack.ItemID == Block.Pumpkin.BlockID)
            {
                RenderPumpkinBlur(i, j);
            }

            if (!mc.ThePlayer.IsPotionActive(Potion.Confusion))
            {
                float f = mc.ThePlayer.PrevTimeInPortal + (mc.ThePlayer.TimeInPortal - mc.ThePlayer.PrevTimeInPortal) * par1;

                if (f > 0.0F)
                {
                    RenderPortalOverlay(f, i, j);
                }
            }

            if (!mc.PlayerController.Func_35643_e())
            {
                //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
                //GL.BindTexture(TextureTarget.Texture2D, mc.RenderEngineOld.GetTexture("/gui/gui.png"));
                InventoryPlayer inventoryplayer = mc.ThePlayer.Inventory;
                ZLevel = -90F;
                DrawTexturedModalRect(i / 2 - 91, j - 22, 0, 0, 182, 22);
                DrawTexturedModalRect((i / 2 - 91 - 1) + inventoryplayer.CurrentItem * 20, j - 22 - 1, 0, 22, 24, 22);
                //GL.BindTexture(TextureTarget.Texture2D, mc.RenderEngineOld.GetTexture("/gui/icons.png"));
                //GL.Enable(EnableCap.Blend);
                //GL.BlendFunc(BlendingFactorSrc.OneMinusDstColor, BlendingFactorDest.OneMinusSrcColor);
                DrawTexturedModalRect(i / 2 - 7, j / 2 - 7, 0, 0, 16, 16);
                //GL.Disable(EnableCap.Blend);
                bool flag = (mc.ThePlayer.HeartsLife / 3) % 2 == 1;

                if (mc.ThePlayer.HeartsLife < 10)
                {
                    flag = false;
                }

                int i1 = mc.ThePlayer.GetHealth();
                int i2 = mc.ThePlayer.PrevHealth;
                rand.SetSeed(updateCounter * 0x4c627);
                bool      flag2     = false;
                FoodStats foodstats = mc.ThePlayer.GetFoodStats();
                int       j4        = foodstats.GetFoodLevel();
                int       l4        = foodstats.GetPrevFoodLevel();
                RenderBossHealth();

                if (mc.PlayerController.ShouldDrawHUD())
                {
                    int j5 = i / 2 - 91;
                    int i6 = i / 2 + 91;
                    int l6 = mc.ThePlayer.XpBarCap();

                    if (l6 > 0)
                    {
                        int c  = 0xb6;
                        int j8 = (int)(mc.ThePlayer.Experience * (float)(c + 1));
                        int i9 = (j - 32) + 3;
                        DrawTexturedModalRect(j5, i9, 0, 64, c, 5);

                        if (j8 > 0)
                        {
                            DrawTexturedModalRect(j5, i9, 0, 69, j8, 5);
                        }
                    }

                    int k7  = j - 39;
                    int k8  = k7 - 10;
                    int j9  = mc.ThePlayer.GetTotalArmorValue();
                    int i10 = -1;

                    if (mc.ThePlayer.IsPotionActive(Potion.Regeneration))
                    {
                        i10 = updateCounter % 25;
                    }

                    for (int j10 = 0; j10 < 10; j10++)
                    {
                        if (j9 > 0)
                        {
                            int i11 = j5 + j10 * 8;

                            if (j10 * 2 + 1 < j9)
                            {
                                DrawTexturedModalRect(i11, k8, 34, 9, 9, 9);
                            }

                            if (j10 * 2 + 1 == j9)
                            {
                                DrawTexturedModalRect(i11, k8, 25, 9, 9, 9);
                            }

                            if (j10 * 2 + 1 > j9)
                            {
                                DrawTexturedModalRect(i11, k8, 16, 9, 9, 9);
                            }
                        }

                        int j11 = 16;

                        if (mc.ThePlayer.IsPotionActive(Potion.Poison))
                        {
                            j11 += 36;
                        }

                        int i12 = 0;

                        if (flag)
                        {
                            i12 = 1;
                        }

                        int l12 = j5 + j10 * 8;
                        int j13 = k7;

                        if (i1 <= 4)
                        {
                            j13 += rand.Next(2);
                        }

                        if (j10 == i10)
                        {
                            j13 -= 2;
                        }

                        byte byte3 = 0;

                        if (mc.TheWorld.GetWorldInfo().IsHardcoreModeEnabled())
                        {
                            byte3 = 5;
                        }

                        DrawTexturedModalRect(l12, j13, 16 + i12 * 9, 9 * byte3, 9, 9);

                        if (flag)
                        {
                            if (j10 * 2 + 1 < i2)
                            {
                                DrawTexturedModalRect(l12, j13, j11 + 54, 9 * byte3, 9, 9);
                            }

                            if (j10 * 2 + 1 == i2)
                            {
                                DrawTexturedModalRect(l12, j13, j11 + 63, 9 * byte3, 9, 9);
                            }
                        }

                        if (j10 * 2 + 1 < i1)
                        {
                            DrawTexturedModalRect(l12, j13, j11 + 36, 9 * byte3, 9, 9);
                        }

                        if (j10 * 2 + 1 == i1)
                        {
                            DrawTexturedModalRect(l12, j13, j11 + 45, 9 * byte3, 9, 9);
                        }
                    }

                    for (int k10 = 0; k10 < 10; k10++)
                    {
                        int  k11   = k7;
                        int  j12   = 16;
                        byte byte2 = 0;

                        if (mc.ThePlayer.IsPotionActive(Potion.Hunger))
                        {
                            j12  += 36;
                            byte2 = 13;
                        }

                        if (mc.ThePlayer.GetFoodStats().GetSaturationLevel() <= 0.0F && updateCounter % (j4 * 3 + 1) == 0)
                        {
                            k11 += rand.Next(3) - 1;
                        }

                        if (flag2)
                        {
                            byte2 = 1;
                        }

                        int k13 = i6 - k10 * 8 - 9;
                        DrawTexturedModalRect(k13, k11, 16 + byte2 * 9, 27, 9, 9);

                        if (flag2)
                        {
                            if (k10 * 2 + 1 < l4)
                            {
                                DrawTexturedModalRect(k13, k11, j12 + 54, 27, 9, 9);
                            }

                            if (k10 * 2 + 1 == l4)
                            {
                                DrawTexturedModalRect(k13, k11, j12 + 63, 27, 9, 9);
                            }
                        }

                        if (k10 * 2 + 1 < j4)
                        {
                            DrawTexturedModalRect(k13, k11, j12 + 36, 27, 9, 9);
                        }

                        if (k10 * 2 + 1 == j4)
                        {
                            DrawTexturedModalRect(k13, k11, j12 + 45, 27, 9, 9);
                        }
                    }

                    if (mc.ThePlayer.IsInsideOfMaterial(Material.Water))
                    {
                        int l10 = mc.ThePlayer.GetAir();
                        int l11 = (int)Math.Ceiling(((double)(l10 - 2) * 10D) / 300D);
                        int k12 = (int)Math.Ceiling(((double)l10 * 10D) / 300D) - l11;

                        for (int i13 = 0; i13 < l11 + k12; i13++)
                        {
                            if (i13 < l11)
                            {
                                DrawTexturedModalRect(i6 - i13 * 8 - 9, k8, 16, 18, 9, 9);
                            }
                            else
                            {
                                DrawTexturedModalRect(i6 - i13 * 8 - 9, k8, 25, 18, 9, 9);
                            }
                        }
                    }
                }

                //GL.Disable(EnableCap.Blend);
                //GL.Enable(EnableCap.RescaleNormal);
                RenderHelper.EnableGUIStandardItemLighting();

                for (int k5 = 0; k5 < 9; k5++)
                {
                    int j6 = (i / 2 - 90) + k5 * 20 + 2;
                    int i7 = j - 16 - 3;
                    RenderInventorySlot(k5, j6, i7, par1);
                }

                RenderHelper.DisableStandardItemLighting();
                //GL.Disable(EnableCap.RescaleNormal);
            }

            if (mc.ThePlayer.GetSleepTimer() > 0)
            {
                //GL.Disable(EnableCap.DepthTest);
                //GL.Disable(EnableCap.AlphaTest);
                int   k  = mc.ThePlayer.GetSleepTimer();
                float f1 = (float)k / 100F;

                if (f1 > 1.0F)
                {
                    f1 = 1.0F - (float)(k - 100) / 10F;
                }

                int j1 = (int)(220F * f1) << 24 | 0x101020;
                DrawRect(0, 0, i, j, j1);
                //GL.Enable(EnableCap.AlphaTest);
                //GL.Enable(EnableCap.DepthTest);
            }

            if (mc.PlayerController.Func_35642_f() && mc.ThePlayer.ExperienceLevel > 0)
            {
                bool   flag1 = false;
                int    k1    = flag1 ? 0xffffff : 0x80ff20;
                String s     = (new StringBuilder()).Append("").Append(mc.ThePlayer.ExperienceLevel).ToString();
                int    i3    = (i - fontrenderer.GetStringWidth(s)) / 2;
                int    k3    = j - 31 - 4;
                fontrenderer.DrawString(s, i3 + 1, k3, 0);
                fontrenderer.DrawString(s, i3 - 1, k3, 0);
                fontrenderer.DrawString(s, i3, k3 + 1, 0);
                fontrenderer.DrawString(s, i3, k3 - 1, 0);
                fontrenderer.DrawString(s, i3, k3, k1);
            }

            if (mc.GameSettings.ShowDebugInfo)
            {
                //GL.PushMatrix();

                if (Minecraft.HasPaidCheckTime > 0L)
                {
                    //GL.Translate(0.0F, 32F, 0.0F);
                }

                fontrenderer.DrawStringWithShadow((new StringBuilder()).Append("Minecraft 1.2.5 (").Append(mc.Debug).Append(")").ToString(), 2, 2, 0xffffff);
                fontrenderer.DrawStringWithShadow(mc.DebugInfoRenders(), 2, 12, 0xffffff);
                fontrenderer.DrawStringWithShadow(mc.GetEntityDebug(), 2, 22, 0xffffff);
                fontrenderer.DrawStringWithShadow(mc.DebugInfoEntities(), 2, 32, 0xffffff);
                fontrenderer.DrawStringWithShadow(mc.GetWorldProviderName(), 2, 42, 0xffffff);
                //long l = Runtime.getRuntime().maxMemory();
                long l2 = GC.GetTotalMemory(false);
                //long l3 = Runtime.getRuntime().freeMemory();
                //long l5 = l2 - l3;
                //string s1 = (new StringBuilder()).Append("Used memory: ").Append((l5 * 100L) / l).Append("% (").Append(l5 / 1024L / 1024L).Append("MB) of ").Append(l / 1024L / 1024L).Append("MB").ToString();
                //DrawString(fontrenderer, s1, i - fontrenderer.GetStringWidth(s1) - 2, 2, 0xe0e0e0);
                //s1 = (new StringBuilder()).Append("Allocated memory: ").Append((l2 * 100L) / l).Append("% (").Append(l2 / 1024L / 1024L).Append("MB)").ToString();
                //DrawString(fontrenderer, s1, i - fontrenderer.GetStringWidth(s1) - 2, 12, 0xe0e0e0);
                DrawString(fontrenderer, (new StringBuilder()).Append("x: ").Append(mc.ThePlayer.PosX).ToString(), 2, 64, 0xe0e0e0);
                DrawString(fontrenderer, (new StringBuilder()).Append("y: ").Append(mc.ThePlayer.PosY).ToString(), 2, 72, 0xe0e0e0);
                DrawString(fontrenderer, (new StringBuilder()).Append("z: ").Append(mc.ThePlayer.PosZ).ToString(), 2, 80, 0xe0e0e0);
                DrawString(fontrenderer, (new StringBuilder()).Append("f: ").Append((int)Math.Floor((double)((mc.ThePlayer.RotationYaw * 4F) / 360F) + 0.5D) & 3).ToString(), 2, 88, 0xe0e0e0);
                int l7 = (int)Math.Floor(mc.ThePlayer.PosX);
                int l8 = (int)Math.Floor(mc.ThePlayer.PosY);
                int k9 = (int)Math.Floor(mc.ThePlayer.PosZ);

                if (mc.TheWorld != null && mc.TheWorld.BlockExists(l7, l8, k9))
                {
                    Chunk chunk = mc.TheWorld.GetChunkFromBlockCoords(l7, k9);
                    DrawString(fontrenderer, (new StringBuilder()).Append("lc: ").Append(chunk.GetTopFilledSegment() + 15).Append(" b: ").Append(chunk.Func_48490_a(l7 & 0xf, k9 & 0xf, mc.TheWorld.GetWorldChunkManager()).BiomeName).Append(" bl: ").Append(chunk.GetSavedLightValue(SkyBlock.Block, l7 & 0xf, l8, k9 & 0xf)).Append(" sl: ").Append(chunk.GetSavedLightValue(SkyBlock.Sky, l7 & 0xf, l8, k9 & 0xf)).Append(" rl: ").Append(chunk.GetBlockLightValue(l7 & 0xf, l8, k9 & 0xf, 0)).ToString(), 2, 96, 0xe0e0e0);
                }

                if (!mc.TheWorld.IsRemote)
                {
                    DrawString(fontrenderer, (new StringBuilder()).Append("Seed: ").Append(mc.TheWorld.GetSeed()).ToString(), 2, 112, 0xe0e0e0);
                }

                //GL.PopMatrix();
            }

            if (recordPlayingUpFor > 0)
            {
                float f2 = (float)recordPlayingUpFor - par1;
                int   l1 = (int)((f2 * 256F) / 20F);

                if (l1 > 255)
                {
                    l1 = 255;
                }

                if (l1 > 0)
                {
                    //GL.PushMatrix();
                    //GL.Translate(i / 2, j - 48, 0.0F);
                    //GL.Enable(EnableCap.Blend);
                    //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                    int j2 = 0xffffff;

                    /*
                     * if (recordIsPlaying)
                     * {
                     *  j2 = Color.HSBtoRGB(f2 / 50F, 0.7F, 0.6F) & 0xffffff;
                     * }
                     */
                    fontrenderer.DrawString(recordPlaying, -(int)fontrenderer.GetStringWidth(recordPlaying) / 2, -4, j2 + (l1 << 24));
                    //GL.Disable(EnableCap.Blend);
                    //GL.PopMatrix();
                }
            }

            //GL.Enable(EnableCap.Blend);
            //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            //GL.Disable(EnableCap.AlphaTest);
            //GL.PushMatrix();
            //GL.Translate(0.0F, j - 48, 0.0F);
            Func_50010_a(fontrenderer);
            //GL.PopMatrix();

            if ((mc.ThePlayer is EntityClientPlayerMP) && mc.GameSettings.KeyBindPlayerList.Pressed)
            {
                NetClientHandler     netclienthandler = ((EntityClientPlayerMP)mc.ThePlayer).SendQueue;
                List <GuiPlayerInfo> list             = netclienthandler.PlayerNames;
                int k2 = netclienthandler.CurrentServerMaxPlayers;
                int j3 = k2;
                int i4 = 1;

                for (; j3 > 20; j3 = ((k2 + i4) - 1) / i4)
                {
                    i4++;
                }

                int k4 = 300 / i4;

                if (k4 > 150)
                {
                    k4 = 150;
                }

                int  i5    = (i - i4 * k4) / 2;
                byte byte0 = 10;
                DrawRect(i5 - 1, byte0 - 1, i5 + k4 * i4, byte0 + 9 * j3, 0x8000000);

                for (int k6 = 0; k6 < k2; k6++)
                {
                    int j7 = i5 + (k6 % i4) * k4;
                    int i8 = byte0 + (k6 / i4) * 9;
                    DrawRect(j7, i8, (j7 + k4) - 1, i8 + 8, 0x20ffffff);
                    //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
                    //GL.Enable(EnableCap.AlphaTest);

                    if (k6 >= list.Count)
                    {
                        continue;
                    }

                    GuiPlayerInfo guiplayerinfo = (GuiPlayerInfo)list[k6];
                    fontrenderer.DrawStringWithShadow(guiplayerinfo.Name, j7, i8, 0xffffff);
                    mc.RenderEngineOld.BindTexture(mc.RenderEngineOld.GetTexture("/gui/icons.png"));
                    int  l9    = 0;
                    byte byte1 = 0;

                    if (guiplayerinfo.ResponseTime < 0)
                    {
                        byte1 = 5;
                    }
                    else if (guiplayerinfo.ResponseTime < 150)
                    {
                        byte1 = 0;
                    }
                    else if (guiplayerinfo.ResponseTime < 300)
                    {
                        byte1 = 1;
                    }
                    else if (guiplayerinfo.ResponseTime < 600)
                    {
                        byte1 = 2;
                    }
                    else if (guiplayerinfo.ResponseTime < 1000)
                    {
                        byte1 = 3;
                    }
                    else
                    {
                        byte1 = 4;
                    }

                    ZLevel += 100F;
                    DrawTexturedModalRect((j7 + k4) - 12, i8, 0 + l9 * 10, 176 + byte1 * 8, 10, 8);
                    ZLevel -= 100F;
                }
            }

            //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
            //GL.Disable(EnableCap.Lighting);
            //GL.Enable(EnableCap.AlphaTest);
        }