From 9b1f1d9a506c769469f454818ef81e70467da984 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 14 Feb 2013 19:41:16 +1100 Subject: [PATCH] Forge support is now working - however an unidentified mod is breaking it due to the use of packet 80. All I can tell is this mod is present in FTB lite. --- .../java/net/md_5/bungee/InitialHandler.java | 6 ++++ .../net/md_5/bungee/ServerConnection.java | 28 +++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/InitialHandler.java index f8853531..1b0acc9d 100644 --- a/proxy/src/main/java/net/md_5/bungee/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/InitialHandler.java @@ -44,6 +44,10 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo private PacketFDEncryptionRequest request; private List loginMessages = new ArrayList<>(); private State thisState = State.HANDSHAKE; + private static final PacketFAPluginMessage forgeMods = new PacketFAPluginMessage( "FML", new byte[] + { + 0, 0, 0, 0, 0, 2 + } ); public InitialHandler(Socket socket, ListenerInfo info) throws IOException { @@ -106,6 +110,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo { Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" ); this.handshake = handshake; + stream.write( forgeMods ); request = EncryptionUtil.encryptRequest(); stream.write( request ); thisState = State.ENCRYPT; @@ -166,6 +171,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo { byte[] buf = stream.readPacket(); DefinedPacket packet = DefinedPacket.packet( buf ); + System.out.println( packet ); packet.handle( this ); } } catch ( Exception ex ) diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java index da3cd2d5..9c69902e 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java @@ -55,18 +55,30 @@ public class ServerConnection extends GenericConnection implements Server } stream.write( handshake ); - for ( PacketFAPluginMessage message : user.loginMessages ) - { - stream.write( message ); - } - stream.write( PacketCDClientStatus.CLIENT_LOGIN ); stream.readPacket(); - byte[] loginResponse = stream.readPacket(); - if ( Util.getId( loginResponse ) == 0xFF ) + byte[] loginResponse = null; + loop: + while ( true ) { - throw new KickException( "[Kicked] " + new PacketFFKick( loginResponse ).message ); + loginResponse = stream.readPacket(); + int id = Util.getId( loginResponse ); + switch ( id ) + { + case 0x01: + break loop; + case 0xFA: + for ( PacketFAPluginMessage message : user.loginMessages ) + { + stream.write( message ); + } + break; + case 0xFF: + throw new KickException( "[Kicked] " + new PacketFFKick( loginResponse ).message ); + default: + throw new IllegalArgumentException( "Unknown login packet " + Util.hex( id ) ); + } } Packet1Login login = new Packet1Login( loginResponse );