GuiGameOver .java

net.minecraft.client.gui.GuiGameOver (class): members: enableButtonsTimer, field_146346_f, confirmClicked, doesGuiPauseGame, updateScreen, keyTyped.

net.minecraft.client.guiclass149 linesclientextends GuiScreen5.2 KB

Implements

API Surface (7)

void initGui()
void keyTyped(char typedChar, int keyCode)
void actionPerformed(GuiButton button)
void confirmClicked(boolean result, int id)
void drawScreen(int mouseX, int mouseY, float partialTicks)
boolean doesGuiPauseGame()
void updateScreen()

Fields & Constants (2)

enableButtonsTimer
field_146346_f

String literals (9)

"deathScreen.deleteWorld"
"deathScreen.leaveServer"
"deathScreen.respawn"
"deathScreen.titleScreen"
"deathScreen.quit.confirm"
"deathScreen.title.hardcore"
"deathScreen.title"
"deathScreen.hardcoreInfo"
"deathScreen.score"

Code Graph: Dependencies (9)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

GuiGameOver.java149 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui;
2
3
import java.io.IOException;
4
import net.minecraft.client.multiplayer.WorldClient;
5
import net.minecraft.client.renderer.GlStateManager;
6
import net.minecraft.client.resources.I18n;
7
import net.minecraft.util.EnumChatFormatting;
8
9
public class GuiGameOver extends GuiScreen implements GuiYesNoCallback
10
{
11
    /**
12
     * The integer value containing the number of ticks that have passed since the player's death
13
     */
14
    private int enableButtonsTimer;
15
    private boolean field_146346_f = false;
16
17
    /**
18
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
19
     * window resizes, the buttonList is cleared beforehand.
20
     */
21
    public void initGui()
22
    {
23
        this.buttonList.clear();
24
25
        if (this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled())
26
        {
27
            if (this.mc.isIntegratedServerRunning())
28
            {
29
                this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, I18n.format("deathScreen.deleteWorld", new Object[0])));
30
            }
31
            else
32
            {
33
                this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, I18n.format("deathScreen.leaveServer", new Object[0])));
34
            }
35
        }
36
        else
37
        {
38
            this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 72, I18n.format("deathScreen.respawn", new Object[0])));
39
            this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, I18n.format("deathScreen.titleScreen", new Object[0])));
40
41
            if (this.mc.getSession() == null)
42
            {
43
                ((GuiButton)this.buttonList.get(1)).enabled = false;
44
            }
45
        }
46
47
        for (GuiButton guibutton : this.buttonList)
48
        {
49
            guibutton.enabled = false;
50
        }
51
    }
52
53
    /**
54
     * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
55
     * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
56
     */
57
    protected void keyTyped(char typedChar, int keyCode) throws IOException
58
    {
59
    }
60
61
    /**
62
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
63
     */
64
    protected void actionPerformed(GuiButton button) throws IOException
65
    {
66
        switch (button.id)
67
        {
68
            case 0:
69
                this.mc.thePlayer.respawnPlayer();
70
                this.mc.displayGuiScreen((GuiScreen)null);
71
                break;
72
73
            case 1:
74
                if (this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled())
75
                {
76
                    this.mc.displayGuiScreen(new GuiMainMenu());
77
                }
78
                else
79
                {
80
                    GuiYesNo guiyesno = new GuiYesNo(this, I18n.format("deathScreen.quit.confirm", new Object[0]), "", I18n.format("deathScreen.titleScreen", new Object[0]), I18n.format("deathScreen.respawn", new Object[0]), 0);
81
                    this.mc.displayGuiScreen(guiyesno);
82
                    guiyesno.setButtonDelay(20);
83
                }
84
        }
85
    }
86
87
    public void confirmClicked(boolean result, int id)
88
    {
89
        if (result)
90
        {
91
            this.mc.theWorld.sendQuittingDisconnectingPacket();
92
            this.mc.loadWorld((WorldClient)null);
93
            this.mc.displayGuiScreen(new GuiMainMenu());
94
        }
95
        else
96
        {
97
            this.mc.thePlayer.respawnPlayer();
98
            this.mc.displayGuiScreen((GuiScreen)null);
99
        }
100
    }
101
102
    /**
103
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
104
     */
105
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
106
    {
107
        this.drawGradientRect(0, 0, this.width, this.height, 1615855616, -1602211792);
108
        GlStateManager.pushMatrix();
109
        GlStateManager.scale(2.0F, 2.0F, 2.0F);
110
        boolean flag = this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled();
111
        String s = flag ? I18n.format("deathScreen.title.hardcore", new Object[0]) : I18n.format("deathScreen.title", new Object[0]);
112
        this.drawCenteredString(this.fontRendererObj, s, this.width / 2 / 2, 30, 16777215);
113
        GlStateManager.popMatrix();
114
115
        if (flag)
116
        {
117
            this.drawCenteredString(this.fontRendererObj, I18n.format("deathScreen.hardcoreInfo", new Object[0]), this.width / 2, 144, 16777215);
118
        }
119
120
        this.drawCenteredString(this.fontRendererObj, I18n.format("deathScreen.score", new Object[0]) + ": " + EnumChatFormatting.YELLOW + this.mc.thePlayer.getScore(), this.width / 2, 100, 16777215);
121
        super.drawScreen(mouseX, mouseY, partialTicks);
122
    }
123
124
    /**
125
     * Returns true if this GUI should pause the game when it is displayed in single-player
126
     */
127
    public boolean doesGuiPauseGame()
128
    {
129
        return false;
130
    }
131
132
    /**
133
     * Called from the main game loop to update the screen.
134
     */
135
    public void updateScreen()
136
    {
137
        super.updateScreen();
138
        ++this.enableButtonsTimer;
139
140
        if (this.enableButtonsTimer == 20)
141
        {
142
            for (GuiButton guibutton : this.buttonList)
143
            {
144
                guibutton.enabled = true;
145
            }
146
        }
147
    }
148
}
149

Deobfuscated MCP 1.8.9 source of GuiGameOver from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/gui/GuiGameOver.java), stored verbatim.