net.minecraft.client.gui.GuiDisconnected Java Examples

The following examples show how to use net.minecraft.client.gui.GuiDisconnected. 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: AutoReconnectMod.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onGuiOpened(GuiOpenEvent event) {
  if (!hasAutoLogged) {
    if (event.getGui() instanceof GuiDisconnected
        && !(event.getGui() instanceof GuiDisconnectedOverride)) {
      updateLastConnectedServer();
      GuiDisconnected disconnected = (GuiDisconnected) event.getGui();
      event.setGui(
          new GuiDisconnectedOverride(
              FastReflection.Fields.GuiDisconnected_parentScreen.get(disconnected),
              "connect.failed",
              FastReflection.Fields.GuiDisconnected_message.get(disconnected),
              FastReflection.Fields.GuiDisconnected_reason.get(disconnected),
              delay.get()));
    }
  }
}
 
Example #2
Source File: AutoReconnectMod.java    From ForgeHax with MIT License 6 votes vote down vote up
public GuiDisconnectedOverride(
    GuiScreen screen,
    String reasonLocalizationKey,
    ITextComponent chatComp,
    String reason,
    double delay) {
  super(screen, reasonLocalizationKey, chatComp);
  parent = screen;
  message = chatComp;
  reconnectTime = System.currentTimeMillis() + (long) (delay * 1000);
  // set variable 'reason' to the previous classes value
  try {
    ReflectionHelper.setPrivateValue(
        GuiDisconnected.class,
        this,
        reason,
        "reason",
        "field_146306_a",
        "a"); // TODO: Find obbed mapping name
  } catch (Exception e) {
    Helper.printStackTrace(e);
  }
  // parse server return text and find queue pos
}
 
Example #3
Source File: MatrixNotifications.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onGuiOpened(GuiOpenEvent event) {
  if (event.getGui() instanceof GuiDisconnected && joined) {
    joined = false;
    
    if (on_disconnected.get()) {
      String reason = Optional.ofNullable(GuiDisconnected_message.get(event.getGui()))
          .map(ITextComponent::getUnformattedText)
          .orElse("");
      if (reason.isEmpty()) {
        notify("Disconnected from %s", serverName);
      } else {
        notify("Disconnected from %s. Reason: %s", serverName, reason);
      }
    }
  }
}
 
Example #4
Source File: ReconnectModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void displayGui(EventDisplayGui event) {
    if (event.getScreen() != null) {
        if (event.getScreen() instanceof GuiDisconnected) {
            this.reconnect = true;
        }
    }
}
 
Example #5
Source File: MixinGuiConnecting.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
private void connect(final String ip, final int port) {
    logger.info("Connecting to " + ip + ", " + port);

    new Thread(() -> {
        InetAddress inetaddress = null;

        try {
            if(cancel) {
                return;
            }

            inetaddress = InetAddress.getByName(ip);
            networkManager = NetworkManager.createNetworkManagerAndConnect(inetaddress, port, mc.gameSettings.isUsingNativeTransport());
            networkManager.setNetHandler(new NetHandlerLoginClient(networkManager, mc, previousGuiScreen));
            networkManager.sendPacket(new C00Handshake(47, ip, port, EnumConnectionState.LOGIN));
            networkManager.sendPacket(new C00PacketLoginStart(MCLeaks.isAltActive() ? new GameProfile(null, MCLeaks.getSession().getUsername()) : mc.getSession().getProfile()));
        }catch(UnknownHostException unknownhostexception) {
            if(cancel)
                return;

            logger.error("Couldn\'t connect to server", unknownhostexception);
            mc.displayGuiScreen(new GuiDisconnected(previousGuiScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", "Unknown host")));
        }catch(Exception exception) {
            if(cancel) {
                return;
            }

            logger.error("Couldn\'t connect to server", exception);
            String s = exception.toString();

            if(inetaddress != null) {
                String s1 = inetaddress.toString() + ":" + port;
                s = s.replaceAll(s1, "");
            }

            mc.displayGuiScreen(new GuiDisconnected(previousGuiScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", s)));
        }
    }, "Server Connector #" + CONNECTION_ID.incrementAndGet()).start();
}
 
Example #6
Source File: MixinGuiConnecting.java    From LiquidBounce with GNU General Public License v3.0 1 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
private void connect(final String ip, final int port) {
    logger.info("Connecting to " + ip + ", " + port);

    new Thread(() -> {
        InetAddress inetaddress = null;

        try {
            if(cancel) {
                return;
            }

            inetaddress = InetAddress.getByName(ip);
            networkManager = NetworkManager.createNetworkManagerAndConnect(inetaddress, port, mc.gameSettings.isUsingNativeTransport());
            networkManager.setNetHandler(new NetHandlerLoginClient(networkManager, mc, previousGuiScreen));
            networkManager.sendPacket(new C00Handshake(47, ip, port, EnumConnectionState.LOGIN, true));
            networkManager.sendPacket(new C00PacketLoginStart(MCLeaks.isAltActive() ? new GameProfile(null, MCLeaks.getSession().getUsername()) : mc.getSession().getProfile()));
        }catch(UnknownHostException unknownhostexception) {
            if(cancel)
                return;

            logger.error("Couldn\'t connect to server", unknownhostexception);
            mc.displayGuiScreen(new GuiDisconnected(previousGuiScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", "Unknown host")));
        }catch(Exception exception) {
            if(cancel) {
                return;
            }

            logger.error("Couldn\'t connect to server", exception);
            String s = exception.toString();

            if(inetaddress != null) {
                String s1 = inetaddress.toString() + ":" + port;
                s = s.replaceAll(s1, "");
            }

            mc.displayGuiScreen(new GuiDisconnected(previousGuiScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", s)));
        }
    }, "Server Connector #" + CONNECTION_ID.incrementAndGet()).start();
}