public void displayGuiScreen(GuiScreen par1GuiScreen)
    {
        if (!(this.currentScreen instanceof GuiErrorScreen))
        {
            if (this.currentScreen != null)
            {
                this.currentScreen.onGuiClosed();
            }

            if (par1GuiScreen instanceof GuiMainMenu)
            {
                this.statFileWriter.func_27175_b();
            }

            this.statFileWriter.syncStats();

            if (par1GuiScreen == null && this.theWorld == null)
            {
                par1GuiScreen = new GuiMainMenu();
            }
            else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0)
            {
                par1GuiScreen = new GuiGameOver();
            }

            if (par1GuiScreen instanceof GuiMainMenu)
            {
                this.gameSettings.showDebugInfo = false;
                this.ingameGUI.clearChatMessages();
            }

            this.currentScreen = (GuiScreen)par1GuiScreen;

            if (par1GuiScreen != null)
            {
                this.setIngameNotInFocus();
                ScaledResolution var2 = new ScaledResolution(this.gameSettings, this.displayWidth, this.displayHeight);
                int var3 = var2.getScaledWidth();
                int var4 = var2.getScaledHeight();
                ((GuiScreen)par1GuiScreen).setWorldAndResolution(this, var3, var4);
                this.skipRenderWorld = false;
            }
            else
            {
                this.setIngameFocus();
            }
        }
    }