Hi,
I wanna ask, how I can connect to a server by a gui-button?
For Example:
I have the Main-Menu and I wanna make a button wich connect to "hypixel.com" server by click the button.
I use the recomended Version of 1.8.9 Forge.
Thank you very much for helping and sorry for my english...
Here is my Code:
package oect.lwaltens.luckyblockhero.guis;
imports...
public class gui_start extends GuiScreen{
public static final ResourceLocation LOGO = new ResourceLocation("luckyblockhero:textures/gui/gui_logo.png");
private gui_start start;
private float updateCounter;
private GameSettings options;
private GuiMainMenu menu;
private GuiMultiplayer multiplayer;
public gui_start(GuiMainMenu menu) {this.menu = menu;}
public gui_start(GuiMultiplayer multiplayer) {this.multiplayer = multiplayer;}
@Override
public void initGui() { this.buttonList.add(new GuiButton(0, width/2-50, height/2-40, 100, 20, "Server"));
this.buttonList.add(new GuiButton(1, width/2-50, height/2-20, 100, 20, "Info"));
this.buttonList.add(new GuiButton(2, width/2-50, height/2+10, 100, 20, "Quit"));
super.initGui();
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawDefaultBackground();
drawRect(width/2, height/2, width/2+100, height/2+100, 0xfffff);
fontRendererObj.drawString(EnumChatFormatting.BOLD+"Willkommen bei Minecraft Lucky Block Heroes", width / 2 - 100, height / 2 -100, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
protected void actionPerformed(GuiButton button) throws IOException {
switch(button.id) {
case 0: this.mc.displayGuiScreen(new GuiConnecting(this, mc, "hypixel.com", 25565));
case 1: this.mc.displayGuiScreen(new gui_info(menu)); break;
case 2: this.mc.shutdown(); break;
}
}
}