use of net.minecraft.network.login.client.CPacketLoginStart 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();
}
use of net.minecraft.network.login.client.CPacketLoginStart 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();
}
use of net.minecraft.network.login.client.CPacketLoginStart in project clientcommands by Earthcomputer.
the class ServerConnectorCVW method connect.
@Override
public void connect() {
Minecraft mc = Minecraft.getMinecraft();
mc.loadWorld(null);
System.gc();
YggdrasilAuthenticationService authService = new YggdrasilAuthenticationService(mc.getProxy(), UUID.randomUUID().toString());
MinecraftSessionService sessionService = authService.createMinecraftSessionService();
GameProfileRepository profileRepo = authService.createProfileRepository();
PlayerProfileCache profileCache = new PlayerProfileCache(profileRepo, new File(mc.mcDataDir, MinecraftServer.USER_CACHE_FILE.getName()));
TileEntitySkull.setProfileCache(profileCache);
TileEntitySkull.setSessionService(sessionService);
PlayerProfileCache.setOnlineMode(false);
mc.integratedServer = new ClientVirtualServer(mc, dimensionId, gameType, previousServer, chunks, playerTag, authService, sessionService, profileRepo, profileCache);
mc.getIntegratedServer().startServerThread();
mc.integratedServerIsRunning = true;
mc.loadingScreen.displaySavingString(I18n.format("menu.loadingLevel"));
while (!mc.getIntegratedServer().serverIsInRunLoop()) {
if (!StartupQuery.check()) {
mc.loadWorld(null);
mc.displayGuiScreen(null);
return;
}
String message = mc.getIntegratedServer().getUserMessage();
if (message != null) {
mc.loadingScreen.displayLoadingString(I18n.format(message));
} else {
mc.loadingScreen.displayLoadingString("");
}
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// ignore
}
}
mc.displayGuiScreen(new GuiScreenWorking());
SocketAddress socketAddress = mc.getIntegratedServer().getNetworkSystem().addLocalEndpoint();
NetworkManager netManager = NetworkManager.provideLocalClient(socketAddress);
netManager.setNetHandler(new NetHandlerLoginClient(netManager, mc, null));
netManager.sendPacket(new C00Handshake(socketAddress.toString(), 0, EnumConnectionState.LOGIN, true));
GameProfile gameProfile = mc.getSession().getProfile();
if (!mc.getSession().hasCachedProperties()) {
gameProfile = mc.getSessionService().fillProfileProperties(gameProfile, true);
mc.getSession().setProperties(gameProfile.getProperties());
}
netManager.sendPacket(new CPacketLoginStart(gameProfile));
mc.myNetworkManager = netManager;
}
Aggregations