001    package net.minecraft.client.gui;
002    
003    import cpw.mods.fml.relauncher.Side;
004    import cpw.mods.fml.relauncher.SideOnly;
005    import net.minecraft.util.StringTranslate;
006    
007    @SideOnly(Side.CLIENT)
008    public class GuiMemoryErrorScreen extends GuiScreen
009    {
010        /**
011         * Adds the buttons (and other controls) to the screen in question.
012         */
013        public void initGui()
014        {
015            StringTranslate var1 = StringTranslate.getInstance();
016            this.controlList.clear();
017            this.controlList.add(new GuiSmallButton(0, this.width / 2 - 155, this.height / 4 + 120 + 12, var1.translateKey("gui.toMenu")));
018            this.controlList.add(new GuiSmallButton(1, this.width / 2 - 155 + 160, this.height / 4 + 120 + 12, var1.translateKey("menu.quit")));
019        }
020    
021        /**
022         * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
023         */
024        protected void actionPerformed(GuiButton par1GuiButton)
025        {
026            if (par1GuiButton.id == 0)
027            {
028                this.mc.displayGuiScreen(new GuiMainMenu());
029            }
030            else if (par1GuiButton.id == 1)
031            {
032                this.mc.shutdown();
033            }
034        }
035    
036        /**
037         * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
038         */
039        protected void keyTyped(char par1, int par2) {}
040    
041        /**
042         * Draws the screen and all the components in it.
043         */
044        public void drawScreen(int par1, int par2, float par3)
045        {
046            this.drawDefaultBackground();
047            this.drawCenteredString(this.fontRenderer, "Out of memory!", this.width / 2, this.height / 4 - 60 + 20, 16777215);
048            this.drawString(this.fontRenderer, "Minecraft has run out of memory.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 0, 10526880);
049            this.drawString(this.fontRenderer, "This could be caused by a bug in the game or by the", this.width / 2 - 140, this.height / 4 - 60 + 60 + 18, 10526880);
050            this.drawString(this.fontRenderer, "Java Virtual Machine not being allocated enough", this.width / 2 - 140, this.height / 4 - 60 + 60 + 27, 10526880);
051            this.drawString(this.fontRenderer, "memory. If you are playing in a web browser, try", this.width / 2 - 140, this.height / 4 - 60 + 60 + 36, 10526880);
052            this.drawString(this.fontRenderer, "downloading the game and playing it offline.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 45, 10526880);
053            this.drawString(this.fontRenderer, "To prevent level corruption, the current game has quit.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 63, 10526880);
054            this.drawString(this.fontRenderer, "We\'ve tried to free up enough memory to let you go back to", this.width / 2 - 140, this.height / 4 - 60 + 60 + 81, 10526880);
055            this.drawString(this.fontRenderer, "the main menu and back to playing, but this may not have worked.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 90, 10526880);
056            this.drawString(this.fontRenderer, "Please restart the game if you see this message again.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 99, 10526880);
057            super.drawScreen(par1, par2, par3);
058        }
059    }