net.minecraft.client.network.NetHandlerLoginClient Java Examples

The following examples show how to use net.minecraft.client.network.NetHandlerLoginClient. 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: 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 #2
Source File: WrapperNetHandlerLoginClient.java    From ClientBase with MIT License 4 votes vote down vote up
public WrapperNetHandlerLoginClient(NetHandlerLoginClient var1) {
    this.real = var1;
}
 
Example #3
Source File: WrapperNetHandlerLoginClient.java    From ClientBase with MIT License 4 votes vote down vote up
public NetHandlerLoginClient unwrap() {
    return this.real;
}
 
Example #4
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();
}