GuiSleepMP .java

net.minecraft.client.gui.GuiSleepMP (class, 69 lines): members: keyTyped, actionPerformed, initGui. strings: "multiplayer.stopSleeping". imports: I18n.

net.minecraft.client.guiclass69 linesclientextends GuiChat2.1 KB

API Surface (3)

void initGui()
void keyTyped(char typedChar, int keyCode)
void actionPerformed(GuiButton button)

String literals (1)

"multiplayer.stopSleeping"

Code Graph: Dependencies (6)

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

Full Source

GuiSleepMP.java69 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui;
2
3
import java.io.IOException;
4
import net.minecraft.client.network.NetHandlerPlayClient;
5
import net.minecraft.client.resources.I18n;
6
import net.minecraft.network.play.client.C0BPacketEntityAction;
7
8
public class GuiSleepMP extends GuiChat
9
{
10
    /**
11
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
12
     * window resizes, the buttonList is cleared beforehand.
13
     */
14
    public void initGui()
15
    {
16
        super.initGui();
17
        this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height - 40, I18n.format("multiplayer.stopSleeping", new Object[0])));
18
    }
19
20
    /**
21
     * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
22
     * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
23
     */
24
    protected void keyTyped(char typedChar, int keyCode) throws IOException
25
    {
26
        if (keyCode == 1)
27
        {
28
            this.wakeFromSleep();
29
        }
30
        else if (keyCode != 28 && keyCode != 156)
31
        {
32
            super.keyTyped(typedChar, keyCode);
33
        }
34
        else
35
        {
36
            String s = this.inputField.getText().trim();
37
38
            if (!s.isEmpty())
39
            {
40
                this.mc.thePlayer.sendChatMessage(s);
41
            }
42
43
            this.inputField.setText("");
44
            this.mc.ingameGUI.getChatGUI().resetScroll();
45
        }
46
    }
47
48
    /**
49
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
50
     */
51
    protected void actionPerformed(GuiButton button) throws IOException
52
    {
53
        if (button.id == 1)
54
        {
55
            this.wakeFromSleep();
56
        }
57
        else
58
        {
59
            super.actionPerformed(button);
60
        }
61
    }
62
63
    private void wakeFromSleep()
64
    {
65
        NetHandlerPlayClient nethandlerplayclient = this.mc.thePlayer.sendQueue;
66
        nethandlerplayclient.addToSendQueue(new C0BPacketEntityAction(this.mc.thePlayer, C0BPacketEntityAction.Action.STOP_SLEEPING));
67
    }
68
}
69

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