GuiShareToLan .java

net.minecraft.client.gui.GuiShareToLan (class): members: field_146596_f, field_146597_g, field_146598_a, field_146599_h, field_146600_i, actionPerformed.

net.minecraft.client.guiclass117 linesclientextends GuiScreen4.4 KB

API Surface (3)

void initGui()
void actionPerformed(GuiButton button)
void drawScreen(int mouseX, int mouseY, float partialTicks)

Fields & Constants (5)

field_146598_a
field_146596_f
field_146597_g
field_146599_h
field_146600_i

String literals (15)

"survival"
"lanServer.start"
"gui.cancel"
"selectWorld.gameMode"
"selectWorld.allowCommands"
"selectWorld.gameMode."
"options.on"
"options.off"
"spectator"
"creative"
"adventure"
"commands.publish.started"
"commands.publish.failed"
"lanServer.title"
"lanServer.otherPlayers"

Code Graph: Dependencies (8)

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

Full Source

GuiShareToLan.java117 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui;
2
3
import java.io.IOException;
4
import net.minecraft.client.resources.I18n;
5
import net.minecraft.util.ChatComponentText;
6
import net.minecraft.util.ChatComponentTranslation;
7
import net.minecraft.util.IChatComponent;
8
import net.minecraft.world.WorldSettings;
9
10
public class GuiShareToLan extends GuiScreen
11
{
12
    private final GuiScreen field_146598_a;
13
    private GuiButton field_146596_f;
14
    private GuiButton field_146597_g;
15
    private String field_146599_h = "survival";
16
    private boolean field_146600_i;
17
18
    public GuiShareToLan(GuiScreen p_i1055_1_)
19
    {
20
        this.field_146598_a = p_i1055_1_;
21
    }
22
23
    /**
24
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
25
     * window resizes, the buttonList is cleared beforehand.
26
     */
27
    public void initGui()
28
    {
29
        this.buttonList.clear();
30
        this.buttonList.add(new GuiButton(101, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("lanServer.start", new Object[0])));
31
        this.buttonList.add(new GuiButton(102, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel", new Object[0])));
32
        this.buttonList.add(this.field_146597_g = new GuiButton(104, this.width / 2 - 155, 100, 150, 20, I18n.format("selectWorld.gameMode", new Object[0])));
33
        this.buttonList.add(this.field_146596_f = new GuiButton(103, this.width / 2 + 5, 100, 150, 20, I18n.format("selectWorld.allowCommands", new Object[0])));
34
        this.func_146595_g();
35
    }
36
37
    private void func_146595_g()
38
    {
39
        this.field_146597_g.displayString = I18n.format("selectWorld.gameMode", new Object[0]) + " " + I18n.format("selectWorld.gameMode." + this.field_146599_h, new Object[0]);
40
        this.field_146596_f.displayString = I18n.format("selectWorld.allowCommands", new Object[0]) + " ";
41
42
        if (this.field_146600_i)
43
        {
44
            this.field_146596_f.displayString = this.field_146596_f.displayString + I18n.format("options.on", new Object[0]);
45
        }
46
        else
47
        {
48
            this.field_146596_f.displayString = this.field_146596_f.displayString + I18n.format("options.off", new Object[0]);
49
        }
50
    }
51
52
    /**
53
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
54
     */
55
    protected void actionPerformed(GuiButton button) throws IOException
56
    {
57
        if (button.id == 102)
58
        {
59
            this.mc.displayGuiScreen(this.field_146598_a);
60
        }
61
        else if (button.id == 104)
62
        {
63
            if (this.field_146599_h.equals("spectator"))
64
            {
65
                this.field_146599_h = "creative";
66
            }
67
            else if (this.field_146599_h.equals("creative"))
68
            {
69
                this.field_146599_h = "adventure";
70
            }
71
            else if (this.field_146599_h.equals("adventure"))
72
            {
73
                this.field_146599_h = "survival";
74
            }
75
            else
76
            {
77
                this.field_146599_h = "spectator";
78
            }
79
80
            this.func_146595_g();
81
        }
82
        else if (button.id == 103)
83
        {
84
            this.field_146600_i = !this.field_146600_i;
85
            this.func_146595_g();
86
        }
87
        else if (button.id == 101)
88
        {
89
            this.mc.displayGuiScreen((GuiScreen)null);
90
            String s = this.mc.getIntegratedServer().shareToLAN(WorldSettings.GameType.getByName(this.field_146599_h), this.field_146600_i);
91
            IChatComponent ichatcomponent;
92
93
            if (s != null)
94
            {
95
                ichatcomponent = new ChatComponentTranslation("commands.publish.started", new Object[] {s});
96
            }
97
            else
98
            {
99
                ichatcomponent = new ChatComponentText("commands.publish.failed");
100
            }
101
102
            this.mc.ingameGUI.getChatGUI().printChatMessage(ichatcomponent);
103
        }
104
    }
105
106
    /**
107
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
108
     */
109
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
110
    {
111
        this.drawDefaultBackground();
112
        this.drawCenteredString(this.fontRendererObj, I18n.format("lanServer.title", new Object[0]), this.width / 2, 50, 16777215);
113
        this.drawCenteredString(this.fontRendererObj, I18n.format("lanServer.otherPlayers", new Object[0]), this.width / 2, 82, 16777215);
114
        super.drawScreen(mouseX, mouseY, partialTicks);
115
    }
116
}
117

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