Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Actually fix ViaFabric incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed Aug 25, 2020
1 parent 0039446 commit fbd6207
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public class ConnectionHandler {

private static final Logger LOGGER = LogManager.getLogger("multiconnect");

public static boolean preConnect(String ip, int port) throws UnknownHostException {
public static boolean preConnect(InetAddress addr, int port) throws UnknownHostException {
String address;
if (port == 25565) {
address = ip;
address = addr.getHostName();
} else {
address = ip + ":" + port;
address = addr.getHostName() + ":" + port;
}

// Hypixel has their own closed-source connection proxy and closed-source anti-cheat.
Expand Down Expand Up @@ -66,12 +66,12 @@ public static boolean preConnect(String ip, int port) throws UnknownHostExceptio
return true;
IConnectScreen connectScreen = (IConnectScreen) screen;

ClientConnection connection = ClientConnection.connect(InetAddress.getByName(ip), port, false);
ClientConnection connection = ClientConnection.connect(addr, port, false);
connectScreen.multiconnect_setVersionRequestConnection(connection);
GetProtocolPacketListener listener = new GetProtocolPacketListener(connection);
connection.setPacketListener(listener);

HandshakeC2SPacket handshake = new HandshakeC2SPacket(ip, port, NetworkState.STATUS);
HandshakeC2SPacket handshake = new HandshakeC2SPacket(addr.getHostName(), port, NetworkState.STATUS);
//noinspection ConstantConditions
((HandshakePacketAccessor) handshake).setProtocolVersion(-1);
connection.send(handshake);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MixinConnectScreen1 {

@Inject(method = "run()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetAddress;IZ)Lnet/minecraft/network/ClientConnection;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
public void beforeConnect(CallbackInfo ci, InetAddress address) throws UnknownHostException {
if (!ConnectionHandler.preConnect(address.getHostName(), field_2415)) {
if (!ConnectionHandler.preConnect(address, field_2415)) {
ci.cancel();
}
}
Expand Down

0 comments on commit fbd6207

Please sign in to comment.