Search in sources :

Example 1 with C00Handshake

use of net.minecraft.network.handshake.client.C00Handshake in project 3arthh4ck by 3arthqu4ke.

the class GuiConnectingPingBypass method connect.

/**
 * Connects to the given server via PingBypass.
 *
 * @param proxyIP the pingbypass ip.
 * @param proxyPort the pingbypass port.
 * @param actualIP ip of the server we want to connect to.
 * @param actualPort port of the server we want to connect to.
 */
private void connect(final String proxyIP, final int proxyPort, final String actualIP, final int actualPort) {
    LOGGER.info("Connecting to PingBypass: {}, {}", proxyIP, proxyPort);
    (new Thread("Server Connector #" + CONNECTION_ID.incrementAndGet()) {

        public void run() {
            InetAddress inetaddress = null;
            try {
                if (cancel) {
                    return;
                }
                inetaddress = InetAddress.getByName(proxyIP);
                networkManager = NetworkManager.createNetworkManagerAndConnect(inetaddress, proxyPort, mc.gameSettings.isUsingNativeTransport());
                networkManager.setNetHandler(new NetHandlerLoginClient(networkManager, mc, previousGuiScreen));
                networkManager.sendPacket(new C00Handshake(actualIP, actualPort, EnumConnectionState.LOGIN, true));
                networkManager.sendPacket(new CPacketLoginStart(mc.getSession().getProfile()));
            } catch (UnknownHostException e) {
                if (cancel) {
                    return;
                }
                LOGGER.error("Couldn't connect to PingBypass", e);
                mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiDisconnected(previousGuiScreen, "connect.failed", new TextComponentTranslation("disconnect.genericReason", "Unknown host"))));
            } catch (Exception exception) {
                if (cancel) {
                    return;
                }
                LOGGER.error("Couldn't connect to PingBypass", exception);
                String s = exception.toString();
                if (inetaddress != null) {
                    String s1 = inetaddress + ":" + proxyPort;
                    s = s.replace(s1, "");
                }
                String finalS = s;
                mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiDisconnected(previousGuiScreen, "connect.failed", new TextComponentTranslation("disconnect.genericReason", finalS))));
            }
        }
    }).start();
}
Also used : NetHandlerLoginClient(net.minecraft.client.network.NetHandlerLoginClient) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) UnknownHostException(java.net.UnknownHostException) C00Handshake(net.minecraft.network.handshake.client.C00Handshake) TextComponentString(net.minecraft.util.text.TextComponentString) GuiDisconnected(net.minecraft.client.gui.GuiDisconnected) InetAddress(java.net.InetAddress) UnknownHostException(java.net.UnknownHostException) CPacketLoginStart(net.minecraft.network.login.client.CPacketLoginStart)

Example 2 with C00Handshake

use of net.minecraft.network.handshake.client.C00Handshake in project Almura by AlmuraDev.

the class ConnectingGui method connect.

private void connect(final String ip, final int port) {
    LOGGER.info("Connecting to {}, {}", ip, Integer.valueOf(port));
    (new Thread("Server Connector #" + CONNECTION_ID.incrementAndGet()) {

        public void run() {
            InetAddress inetaddress = null;
            try {
                if (ConnectingGui.this.cancel) {
                    return;
                }
                inetaddress = InetAddress.getByName(ip);
                if (Almura.networkManager != null) {
                    Almura.networkManager = null;
                }
                Almura.networkManager = NetworkManager.createNetworkManagerAndConnect(inetaddress, port, ConnectingGui.this.mc.gameSettings.isUsingNativeTransport());
                Almura.networkManager.setNetHandler(new NetHandlerLoginClient(Almura.networkManager, ConnectingGui.this.mc, ConnectingGui.this.previousGuiScreen));
                Almura.networkManager.sendPacket(new C00Handshake(ip, port, EnumConnectionState.LOGIN));
                Almura.networkManager.sendPacket(new CPacketLoginStart(ConnectingGui.this.mc.getSession().getProfile()));
            } catch (UnknownHostException unknownhostexception) {
                if (ConnectingGui.this.cancel) {
                    return;
                }
                ConnectingGui.LOGGER.error("Couldn't connect to server", (Throwable) unknownhostexception);
                new DisconnectedGui("Could not connect to server.").display();
            } catch (Exception exception) {
                if (ConnectingGui.this.cancel) {
                    return;
                }
                ConnectingGui.LOGGER.error("Couldn't connect to server", (Throwable) exception);
                String s = exception.toString();
                if (inetaddress != null) {
                    String s1 = inetaddress + ":" + port;
                    s = s.replaceAll(s1, "");
                }
                new DisconnectedGui("Exception encountered.  Could not connect to server.").display();
            }
        }
    }).start();
}
Also used : NetHandlerLoginClient(net.minecraft.client.network.NetHandlerLoginClient) UnknownHostException(java.net.UnknownHostException) C00Handshake(net.minecraft.network.handshake.client.C00Handshake) TextComponentString(net.minecraft.util.text.TextComponentString) InetAddress(java.net.InetAddress) UnknownHostException(java.net.UnknownHostException) CPacketLoginStart(net.minecraft.network.login.client.CPacketLoginStart)

Example 3 with C00Handshake

use of net.minecraft.network.handshake.client.C00Handshake in project LiquidBouncePlus by WYSI-Foundation.

the class BungeeCordSpoof method onPacket.

@EventTarget
public void onPacket(PacketEvent event) {
    final Packet<?> packet = event.getPacket();
    if (packet instanceof C00Handshake && enabled && ((C00Handshake) packet).getRequestedState() == EnumConnectionState.LOGIN) {
        final C00Handshake handshake = (C00Handshake) packet;
        handshake.ip = handshake.ip + "\000" + MessageFormat.format("{0}.{1}.{2}.{3}", getRandomIpPart(), getRandomIpPart(), getRandomIpPart(), getRandomIpPart()) + "\000" + mc.getSession().getPlayerID().replace("-", "");
    }
}
Also used : C00Handshake(net.minecraft.network.handshake.client.C00Handshake) EventTarget(net.ccbluex.liquidbounce.event.EventTarget)

Example 4 with C00Handshake

use of net.minecraft.network.handshake.client.C00Handshake in project LiquidBouncePlus by WYSI-Foundation.

the class MixinGuiConnecting method connect.

/*
    @Inject(method = "connect", at = @At(value = "NEW", target = "net/minecraft/network/login/client/C00PacketLoginStart"), cancellable = true)
    private void mcLeaks(CallbackInfo callbackInfo) {
        if(MCLeaks.isAltActive()) {
            networkManager.sendPacket(new C00PacketLoginStart(new GameProfile(null, MCLeaks.getSession().getUsername())));
            callbackInfo.cancel();
        }
    }
*/
/**
 * @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(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();
}
Also used : NetHandlerLoginClient(net.minecraft.client.network.NetHandlerLoginClient) UnknownHostException(java.net.UnknownHostException) C00PacketLoginStart(net.minecraft.network.login.client.C00PacketLoginStart) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) C00Handshake(net.minecraft.network.handshake.client.C00Handshake) GuiDisconnected(net.minecraft.client.gui.GuiDisconnected) InetAddress(java.net.InetAddress) UnknownHostException(java.net.UnknownHostException) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 5 with C00Handshake

use of net.minecraft.network.handshake.client.C00Handshake in project UtilityClient2 by Utility-Client.

the class GuiConnecting method connect.

private void connect(final String ip, final int port) {
    logger.info("Connecting to " + ip + ", " + port);
    (new Thread("Server Connector #" + CONNECTION_ID.incrementAndGet()) {

        public void run() {
            InetAddress inetaddress = null;
            try {
                if (GuiConnecting.this.cancel) {
                    return;
                }
                inetaddress = InetAddress.getByName(ip);
                GuiConnecting.this.networkManager = NetworkManager.func_181124_a(inetaddress, port, GuiConnecting.this.mc.gameSettings.func_181148_f());
                GuiConnecting.this.networkManager.setNetHandler(new NetHandlerLoginClient(GuiConnecting.this.networkManager, GuiConnecting.this.mc, GuiConnecting.this.previousGuiScreen));
                GuiConnecting.this.networkManager.sendPacket(new C00Handshake(47, ip, port, EnumConnectionState.LOGIN));
                GuiConnecting.this.networkManager.sendPacket(new C00PacketLoginStart(GuiConnecting.this.mc.getSession().getProfile()));
            } catch (UnknownHostException unknownhostexception) {
                if (GuiConnecting.this.cancel) {
                    return;
                }
                GuiConnecting.logger.error((String) "Couldn\'t connect to server", (Throwable) unknownhostexception);
                GuiConnecting.this.mc.displayGuiScreen(new GuiDisconnected(GuiConnecting.this.previousGuiScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] { "Unknown host" })));
            } catch (Exception exception) {
                if (GuiConnecting.this.cancel) {
                    return;
                }
                GuiConnecting.logger.error((String) "Couldn\'t connect to server", (Throwable) exception);
                String s = exception.toString();
                if (inetaddress != null) {
                    String s1 = inetaddress.toString() + ":" + port;
                    s = s.replaceAll(s1, "");
                }
                GuiConnecting.this.mc.displayGuiScreen(new GuiDisconnected(GuiConnecting.this.previousGuiScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] { s })));
            }
        }
    }).start();
}
Also used : NetHandlerLoginClient(net.minecraft.client.network.NetHandlerLoginClient) UnknownHostException(java.net.UnknownHostException) C00PacketLoginStart(net.minecraft.network.login.client.C00PacketLoginStart) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) C00Handshake(net.minecraft.network.handshake.client.C00Handshake) GuiDisconnected(net.minecraft.client.gui.GuiDisconnected) InetAddress(java.net.InetAddress) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

C00Handshake (net.minecraft.network.handshake.client.C00Handshake)11 UnknownHostException (java.net.UnknownHostException)6 NetHandlerLoginClient (net.minecraft.client.network.NetHandlerLoginClient)6 InetAddress (java.net.InetAddress)5 NetworkManager (net.minecraft.network.NetworkManager)5 C00PacketServerQuery (net.minecraft.network.status.client.C00PacketServerQuery)4 ChatComponentText (net.minecraft.util.ChatComponentText)4 GameProfile (com.mojang.authlib.GameProfile)3 GuiDisconnected (net.minecraft.client.gui.GuiDisconnected)3 ServerAddress (net.minecraft.client.multiplayer.ServerAddress)3 C00PacketLoginStart (net.minecraft.network.login.client.C00PacketLoginStart)3 CPacketLoginStart (net.minecraft.network.login.client.CPacketLoginStart)3 INetHandlerStatusClient (net.minecraft.network.status.INetHandlerStatusClient)3 C01PacketPing (net.minecraft.network.status.client.C01PacketPing)3 S00PacketServerInfo (net.minecraft.network.status.server.S00PacketServerInfo)3 S01PacketPong (net.minecraft.network.status.server.S01PacketPong)3 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)3 IChatComponent (net.minecraft.util.IChatComponent)3 ServerStatusResponse (net.minecraft.network.ServerStatusResponse)2 TextComponentString (net.minecraft.util.text.TextComponentString)2