From a58258e8d39294544a104e490c798c29353f2c83 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 23 Jun 2022 04:50:27 -0700 Subject: [PATCH] Update packets --- src/client.rs | 2 -- src/packets.rs | 72 +++++++++++++++++++++++++++++++++----------------- src/world.rs | 1 + 3 files changed, 49 insertions(+), 26 deletions(-) diff --git a/src/client.rs b/src/client.rs index 9d4634d..fb6b3b2 100644 --- a/src/client.rs +++ b/src/client.rs @@ -156,8 +156,6 @@ pub struct Client { new_game_mode: GameMode, old_game_mode: GameMode, settings: Option, - // TODO: latency - // TODO: time, weather } pub struct ClientMut<'a>(&'a mut Client); diff --git a/src/packets.rs b/src/packets.rs index c6f2f27..f89e84f 100644 --- a/src/packets.rs +++ b/src/packets.rs @@ -434,12 +434,12 @@ pub mod login { def_struct! { LoginStart 0x00 { username: BoundedString<3, 16>, - sig_data: Option, + sig_data: Option, } } def_struct! { - LoginStartSignatureData { + SignatureData { timestamp: i64, public_key: Vec, signature: Vec, @@ -472,6 +472,8 @@ pub mod login { /// Packets and types used during the play state. pub mod play { pub mod s2c { + use crate::packets::login::{s2c::Property, c2s::SignatureData}; + use super::super::*; def_struct! { @@ -635,28 +637,6 @@ pub mod play { } } - def_struct! { - ChatMessageClientbound 0x30 { - message: Text, - typ: ChatMessageType, - sender: Uuid, - // TODO more fields - } - } - - def_enum! { - ChatMessageType: VarInt { - Chat = 0, - SystemMessage = 1, - GameInfo = 2, - SayCommand = 3, - MsgCommand = 4, - TeamMsgCommand = 5, - EmoteCommand = 6, - TellrawCommand = 7, - } - } - def_struct! { ClearTitles 0x0d { reset: bool, @@ -1014,6 +994,50 @@ pub mod play { } } + def_struct! { + ChatMessageClientbound 0x30 { + message: Text, + typ: ChatMessageType, + sender: Uuid, + // TODO more fields + } + } + + def_enum! { + ChatMessageType: VarInt { + Chat = 0, + SystemMessage = 1, + GameInfo = 2, + SayCommand = 3, + MsgCommand = 4, + TeamMsgCommand = 5, + EmoteCommand = 6, + TellrawCommand = 7, + } + } + + def_enum! { + PlayerInfo 0x34: VarInt { + AddPlayer: Vec = 0, + UpdateGameMode: Vec<(Uuid, GameMode)> = 1, + UpdateLatency: Vec<(Uuid, VarInt)> = 2, + UpdateDisplayName: Vec<(Uuid, Option)> = 3, + RemovePlayer: Vec = 4, + } + } + + def_struct! { + PlayerInfoAddPlayer { + uuid: Uuid, + username: BoundedString<3, 16>, + properties: Vec, + game_mode: GameMode, + ping: VarInt, + display_name: Option, + sig_data: Option, + } + } + def_struct! { PlayerPositionAndLook 0x36 { position: Vec3, diff --git a/src/world.rs b/src/world.rs index 432c34c..8199a0f 100644 --- a/src/world.rs +++ b/src/world.rs @@ -183,6 +183,7 @@ impl<'a> WorldMut<'a> { pub struct WorldMeta { dimension: DimensionId, is_flat: bool, + // TODO: time, weather } impl WorldMeta {