diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-11-28 00:45:30 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-11-28 00:45:30 +0100 |
commit | c89f25f59aa493d95bcac8e75ca5cdd57a0403e7 (patch) | |
tree | e1eb14f3b27ab8bcce68551424fe49a4f7d376af /packets/login_server_login_packet.gd |
initial commit
Diffstat (limited to 'packets/login_server_login_packet.gd')
-rw-r--r-- | packets/login_server_login_packet.gd | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/packets/login_server_login_packet.gd b/packets/login_server_login_packet.gd new file mode 100644 index 0000000..29f23cd --- /dev/null +++ b/packets/login_server_login_packet.gd @@ -0,0 +1,34 @@ +class_name LoginServerLoginPacket +extends Packet + + +## Byte Length: 4 +var version: int = 0 + +## Byte Length: 24 +var username: String + +## Byte Length: 24 +var password: String + +## Byte Length: 1 +var client_type: int = 0 + + +func to_bytes(): + var header = PackedByteArray([100, 0]) + + var username_bytes = username.to_utf8_buffer() + username_bytes.resize(24) + + var password_bytes = password.to_utf8_buffer() + password_bytes.resize(24) + + var payload = PackedByteArray([]) + payload.resize(4) + payload.encode_u32(0, version) + payload.append_array(username_bytes) + payload.append_array(password_bytes) + payload.append(client_type) + + return header + payload |