net.minecraft.client.multiplayer.GuiConnecting Java Examples

The following examples show how to use net.minecraft.client.multiplayer.GuiConnecting. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstantMessage.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onPacketIn(PacketEvent.Incoming.Pre event) {
  if (event.getPacket() instanceof SPacketLoginSuccess) {
    
    if (MC.currentScreen instanceof GuiConnecting) {
      
      ServerData serverData = MC.getCurrentServerData();
      String serverName = serverData != null ? serverData.serverName : "Unknown";
      String serverIP = serverData != null ? serverData.serverIP : "";
      
      GuiConnecting_networkManager.get(MC.currentScreen)
          .sendPacket(
              new CPacketChatMessage(
                  message
                      .get()
                      .replace("{SRVNAME}", serverName)
                      .replace("{IP}", serverIP)
                      .replace("{NAME}", MC.getSession().getUsername())));
    } else {
      getLog().warn("Did not send message as current screen is not GuiConnecting");
    }
  }
}
 
Example #2
Source File: ReconnectModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void runTick(EventRunTick event) {
    if (event.getStage() == EventStageable.EventStage.POST) {
        if (this.lastIp != null && this.lastPort > 0 && this.reconnect) {
            if (this.timer.passed(this.delay.getValue())) {
                Minecraft.getMinecraft().displayGuiScreen(new GuiConnecting(null, Minecraft.getMinecraft(), this.lastIp, this.lastPort));
                this.timer.reset();
                this.reconnect = false;
            }
        }
    }
}
 
Example #3
Source File: ConnectCommand.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void exec(String input) {
    if (!this.clamp(input, 2, 2)) {
        this.printUsage();
        return;
    }

    final String[] split = input.split(" ");

    final String[] host = split[1].split(":");

    int port = 25565;

    if (host.length > 1) {
        if (StringUtil.isInt(host[1])) {
            port = Integer.parseInt(host[1]);
        }else{
            Seppuku.INSTANCE.errorChat("Invalid port \"" + host[1] + "\"");
        }
    }

    if(Minecraft.getMinecraft().player.connection.getNetworkManager().channel().isOpen()) {
        Minecraft.getMinecraft().player.connection.getNetworkManager().closeChannel(null);
    }

    Minecraft.getMinecraft().displayGuiScreen(new GuiConnecting(null, Minecraft.getMinecraft(), host[0], port));
}
 
Example #4
Source File: ConnectCommand.java    From ClientBase with MIT License 5 votes vote down vote up
@Override
public void run(String alias, @NotNull String[] args) {
    if (args.length != 1) {
        throw new CommandException("Usage: ." + alias + " <server-address>");
    }

    // See https://github.com/Wurst-Imperium/Wurst-MC-1.12/blob/master/shared-src/net/wurstclient/bot/commands/JoinCmd.java
    Minecraft.getMinecraft().addScheduledTask(() -> Minecraft.getMinecraft().displayGuiScreen(new GuiConnecting(new GuiMainMenu(), Minecraft.getMinecraft(),
            new ServerData("", args[0], false))));
}
 
Example #5
Source File: ServerUtils.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
public static void connectToLastServer() {
    if(serverData == null)
        return;

    mc.displayGuiScreen(new GuiConnecting(new GuiMultiplayer(new GuiMainMenu()), mc, serverData));
}
 
Example #6
Source File: AutoReconnectMod.java    From ForgeHax with MIT License 4 votes vote down vote up
private void reconnect() {
  ServerData data = getLastConnectedServerData();
  if (data != null) {
    FMLClientHandler.instance().showGuiScreen(new GuiConnecting(parent, MC, data));
  }
}