diff --git a/src/DedicatedServer.cpp b/src/DedicatedServer.cpp index 2e39106..c29df6a 100644 --- a/src/DedicatedServer.cpp +++ b/src/DedicatedServer.cpp @@ -104,12 +104,35 @@ namespace Feather template <> void DedicatedServer::HandlePacket(MinecraftClient& client, const Login::ServerboundStart& start) { - Login::ClientboundSuccess message = + //Login::ClientboundSuccess success = + //{ + // .uuid = { 4658857991808325907ull, 7518717155607718277ull }, + // .username = start.username + //}; + std::string uuid = "ecb99913-96a8-40a7-8529-a2ca6ad95768"; + Login::ClientboundSuccess success = { - .uuid = { 4658857991808325907ull, 7518717155607718277ull }, + .uuid = uuid, .username = start.username }; - client.SendMessage(message); + client.SendMessage(success); + client.GetContext().SetState(ProtocolState::Play); + + std::string type = "default"; + Play::ClientboundJoinGame join = + { + .entityId = 0, + .gamemode = 0, + .dimension = 0, + .seedHash = 0, + .maxPlayers = uint8_t(m_properties->maxPlayers.GetValue()), + .levelType = type, + .viewDistance = m_properties->viewDistance, + .reducedDebugInfo = false, + .enableRespawnScreen = true + }; + + client.SendMessage(join); } } diff --git a/src/ServerStatus.h b/src/ServerStatus.h index 9f50569..b0b2d83 100644 --- a/src/ServerStatus.h +++ b/src/ServerStatus.h @@ -15,8 +15,8 @@ namespace Feather public: // Version - string versionName = "1.16.1"; - int protocol = 736; + string versionName = "1.15.2";//"1.16.1"; + int protocol = 578;//736; // Players int maxPlayers; diff --git a/src/protocol/generate_protocol.py b/src/protocol/generate_protocol.py index de590c6..3b79ee9 100644 --- a/src/protocol/generate_protocol.py +++ b/src/protocol/generate_protocol.py @@ -53,7 +53,7 @@ def get_type_size(type): return 4 elif type == 'int16' or type == 'uint16': return 2 - elif type == 'int8' or type == 'uint8': + elif type == 'int8' or type == 'uint8' or type == 'bool': return 1 elif type == 'string': return count diff --git a/src/protocol/protocol.hjson b/src/protocol/protocol.hjson index 87eb01c..1f929bb 100644 --- a/src/protocol/protocol.hjson +++ b/src/protocol/protocol.hjson @@ -20,6 +20,7 @@ int16 : int16_t uint8 : uint8_t int8 : int8_t + bool : uint8_t } } @@ -53,26 +54,6 @@ status : { - serverbound : - { - Request : - { - id : 0 - vars : - { - } - } - - Ping : - { - id : 1 - vars : - { - timestamp : uint64 - } - } - } - clientbound : { Response : @@ -93,6 +74,26 @@ } } } + + serverbound : + { + Request : + { + id : 0 + vars : + { + } + } + + Ping : + { + id : 1 + vars : + { + timestamp : uint64 + } + } + } } login : @@ -104,7 +105,7 @@ id : 0 vars : { - username : string[32767] + reason : string[32767] } } @@ -113,7 +114,7 @@ id : 2 vars : { - uuid : uuid + uuid : string[32] username : string[16] } } @@ -131,5 +132,28 @@ } } } + + play : + { + clientbound : + { + JoinGame : + { + id : 38 + vars : + { + entityId : int32 + gamemode : uint8 + dimension : int32 + seedHash : uint64 + maxPlayers : uint8 + levelType : string[16] + viewDistance : varint + reducedDebugInfo : bool + enableRespawnScreen : bool + } + } + } + } } } \ No newline at end of file diff --git a/src/protocol/protocol_.hjson b/src/protocol/protocol_.hjson new file mode 100644 index 0000000..b4586bf --- /dev/null +++ b/src/protocol/protocol_.hjson @@ -0,0 +1,140 @@ +{ + types : + { + aliases : + { + ProtocolState : varint + } + + primitives : + { + varint : int32_t + string : std::string + uuid : MinecraftUUID + + uint64 : uint64_t + int64 : int64_t + uint32 : uint32_t + int32 : int32_t + uint16 : uint16_t + int16 : int16_t + uint8 : uint8_t + int8 : int8_t + bool : uint8_t + } + } + + states : + { + Handholding : -1 + Play : 0 + Status : 1 + Login : 2 + } + + messages : + { + handholding : + { + serverbound : + { + Handshake : + { + id : 0 + vars : + { + protocolVersion : varint + serverIP : string[255] + port : uint16 + intention : ProtocolState + } + } + } + } + + status : + { + clientbound : + { + Response : + { + id : 0 + vars : + { + jsonResponse : string[32767] + } + } + + Pong : + { + id : 1 + vars : + { + timestamp : uint64 + } + } + } + + serverbound : + { + Request : + { + id : 0 + vars : + { + } + } + + Ping : + { + id : 1 + vars : + { + timestamp : uint64 + } + } + } + } + + login : + { + clientbound : + { + Disconnect : + { + id : 0 + vars : + { + reason : string[32767] + } + } + + Success : + { + id : 2 + vars : + { + uuid : uuid + username : string[16] + } + } + } + + serverbound : + { + Start : + { + id : 0 + vars : + { + username : string[16] + } + } + } + } + + play : + { + } + } +} \ No newline at end of file