diff --git a/src/PacketTypes.h b/src/PacketTypes.h index 1e4f131..3203524 100644 --- a/src/PacketTypes.h +++ b/src/PacketTypes.h @@ -26,5 +26,14 @@ namespace Feather LoginPluginResponse = 2 }; + enum class ClientboundLoginPacketId : int32_t + { + Disconnect = 0, + EncryptionRequest = 1, + LoginSuccess = 2, + SetCompression = 3, + LoginPluginRequest = 4 + }; + constexpr uint8_t LegacyServerListPing = 0xFE; } diff --git a/src/Protocol.cpp b/src/Protocol.cpp index 35debf6..4c79313 100644 --- a/src/Protocol.cpp +++ b/src/Protocol.cpp @@ -91,8 +91,37 @@ namespace Feather case ProtocolState::Login: { - int id = packet.ReadVarInt(); - Log_Info("Login packet ID %d", id); + auto id = packet.ReadVarInt(); + + switch (id) + { + case ServerboundLoginPacketId::LoginStart: + { + std::string username = packet.ReadString(); + std::string uuid = "ecb99913-96a8-40a7-8529-a2ca6ad95768"; + + uuid.resize(36); + username.resize(16); + + NetworkMessage msg(VARINT_MAX_SIZE * 3 + uuid.length() + username.length()); + + msg.WriteVarInt(ClientboundLoginPacketId::LoginSuccess); + // UUID 1.16.1 + msg.Write(4658857991808325907LL); + msg.Write(7518717155607718277LL); + + // UUID 1.15.2 + //msg.WriteString(uuid.c_str(), uuid.length()); + + msg.WriteString(username.c_str(), username.length()); + msg.Finalize(); + + client.SendMessage(msg); + + break; + } + } + break; } }