          for (int i = 16384; i > 0; i >>= 1)
          {
              GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null);
-@@ -2431,6 +2380,7 @@
+@@ -2431,6 +2382,7 @@
  
              if (j != 0)
              {

 
         if (this.serverName != null)
         {
@@ -679,21 +688,28 @@
      */
     public void displayGuiScreen(GuiScreen par1GuiScreen)
     {
-        if (this.currentScreen != null)
+        this.statFileWriter.syncStats();
+
+        if (par1GuiScreen == null && this.theWorld == null)
+        {
+            par1GuiScreen = new GuiMainMenu();
+        }
+        else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0.0F)
+        {
+            par1GuiScreen = new GuiGameOver();
+        }
+
+        GuiScreen old = this.currentScreen;
+        GuiOpenEvent event = new GuiOpenEvent(par1GuiScreen);
+        boolean canceled = MinecraftForge.EVENT_BUS.post(event);
+        
+        if (old != null && old != this.currentScreen)
         {
             this.currentScreen.onGuiClosed();
         }
 
-        this.statFileWriter.syncStats();
-
-        if (par1GuiScreen == null && this.theWorld == null)
-        {
-            par1GuiScreen = new GuiMainMenu();
-        }
-        else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0.0F)
-        {
-            par1GuiScreen = new GuiGameOver();
-        }
+        if (canceled) return;
+        par1GuiScreen = event.gui;
 
         if (par1GuiScreen instanceof GuiMainMenu)
         {
@@ -1300,7 +1316,7 @@
 
                 if (this.thePlayer.isCurrentToolAdventureModeExempt(j, k, l))
                 {

 
             if (flag)
             {
@@ -2419,11 +2363,18 @@
         par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize()));
     }
 
