Hello fellow modders,
What does the forge server expect for handshaking?
If I try to send the normal handshake with the adress: "localhost\0FML\0", which worked in 1.12.2, but now it just responds with the play packet 26: "SDisconnectPacket".
This results in the client throwing the error: Internal Exception: io.netty.handler.codec.DecoderException: java.IOException: BadPacket id 26.
Perhaps the handshake was changed in the forge rewrite?
My code for the handshake:
byte[] protocolVersionBytes = McPacketOutEncoder.encodeVarInt(490);
byte[] serverAdressBytes = McPacketOutEncoder.encodeString("localhost\0FML\0");
short port = 25565;
byte[] portBytes = new byte[2];
portBytes[0] = (byte) (port & 0b0000000011111111);
portBytes[1] = (byte) ((port & 0b1111111100000000) >>> 8);
byte[] nextStateBytes = McPacketOutEncoder.encodeVarInt(2);
byte[] newPacketData = new byte[protocolVersionBytes.length + serverAdressBytes.length + 2 + nextStateBytes.length];
System.arraycopy(protocolVersionBytes, 0, newPacketData, 0, protocolVersionBytes.length);
System.arraycopy(serverAdressBytes, 0, newPacketData, protocolVersionBytes.length, serverAdressBytes.length);
newPacketData[0 + protocolVersionBytes.length + serverAdressBytes.length] = portBytes[0];
newPacketData[1 + protocolVersionBytes.length + serverAdressBytes.length] = portBytes[1];
System.arraycopy(nextStateBytes, 0, newPacketData, protocolVersionBytes.length + serverAdressBytes.length + 2, nextStateBytes.length);
byte[] packetIDBytes = McPacketOutEncoder.encodeVarInt(0);
int packetLength = packetIDBytes.length + newPacketData.length;
byte[] packetLengthBytes = McPacketOutEncoder.encodeVarInt(packetLength);
byte[] handShakePacket = new byte[packetLength + packetLengthBytes.length];
System.arraycopy(packetLengthBytes, 0, handShakePacket, 0, packetLengthBytes.length);
System.arraycopy(packetIDBytes, 0, handShakePacket, packetLengthBytes.length, packetIDBytes.length);
System.arraycopy(newPacketData, 0, handShakePacket, packetLengthBytes.length + packetIDBytes.length, newPacketData.length);
sendPacketBack(handShakePacket);