diff --git a/README.md b/README.md index fd65b1ec..c307bd77 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A collection of Rust crates primarily for creating Minecraft bots.

-*Currently supported Minecraft version: `1.19.1-pre4`.* +*Currently supported Minecraft version: `1.19.1-rc2`.* I named this Azalea because it sounds like a cool word and this is a cool library. This project was heavily inspired by PrismarineJS. diff --git a/azalea-crypto/src/signing.rs b/azalea-crypto/src/signing.rs index 99c7b3d7..3bad08c9 100644 --- a/azalea-crypto/src/signing.rs +++ b/azalea-crypto/src/signing.rs @@ -15,5 +15,5 @@ pub struct MessageSignature { #[derive(Clone, Debug, McBuf)] pub struct SignedMessageHeader { pub previous_signature: Option, - pub uuid: Uuid, + pub sender: Uuid, } diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs index f5df8869..1b71ccea 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs @@ -17,7 +17,8 @@ pub enum ChatType { MsgCommandIncoming = 2, MsgCommandOutgoing = 3, TeamMsgCommandIncoming = 4, - EmoteCommand = 5, + TeamMsgCommandOutgoing = 5, + EmoteCommand = 6, } #[derive(Clone, Debug, McBuf)] @@ -37,14 +38,27 @@ pub struct PlayerChatMessage { #[derive(Clone, Debug, McBuf)] pub struct SignedMessageBody { - pub content: Component, + pub content: ChatMessageContent, pub timestamp: u64, pub salt: u64, - pub last_seen: Vec, + pub last_seen: Vec, } #[derive(Clone, Debug, McBuf)] -pub struct LastSeen { +pub struct LastSeenMessagesEntry { pub profile_id: Uuid, pub last_signature: MessageSignature, } + +#[derive(Clone, Debug, McBuf)] +pub struct LastSeenMessagesUpdate { + pub last_seen: Vec, + pub last_received: Option, +} + +#[derive(Clone, Debug, McBuf)] +pub struct ChatMessageContent { + pub plain: String, + /// Only sent if the decorated message is different than the plain. + pub decorated: Option, +} diff --git a/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs index 1dddfc1e..2bfa00bd 100644 --- a/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs @@ -1,5 +1,4 @@ use azalea_buf::McBuf; -use azalea_chat::component::Component; use packet_macros::GamePacket; #[derive(Clone, Debug, McBuf, GamePacket)] @@ -7,4 +6,5 @@ pub struct ClientboundServerDataPacket { pub motd: Option, pub icon_base64: Option, pub previews_chat: bool, + pub enforces_secure_chat: bool, } diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index c9d632e2..0b5c4d3e 100755 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -54,7 +54,9 @@ pub mod clientbound_update_recipes_packet; pub mod clientbound_update_tags_packet; pub mod clientbound_update_view_distance_packet; pub mod serverbound_accept_teleportation_packet; +pub mod serverbound_chat_ack_packet; pub mod serverbound_chat_command_packet; +pub mod serverbound_chat_packet; pub mod serverbound_chat_preview_packet; pub mod serverbound_custom_payload_packet; pub mod serverbound_keep_alive_packet; @@ -69,14 +71,16 @@ declare_state_packets!( GamePacket, Serverbound => { 0x00: serverbound_accept_teleportation_packet::ServerboundAcceptTeleportationPacket, - 0x03: serverbound_chat_command_packet::ServerboundChatCommandPacket, - 0x05: serverbound_chat_preview_packet::ServerboundChatPreviewPacket, - 0x0c: serverbound_custom_payload_packet::ServerboundCustomPayloadPacket, - 0x11: serverbound_keep_alive_packet::ServerboundKeepAlivePacket, - 0x13: serverbound_move_player_packet_pos::ServerboundMovePlayerPacketPos, - 0x14: serverbound_move_player_packet_pos_rot::ServerboundMovePlayerPacketPosRot, - 0x15: serverbound_move_player_packet_rot::ServerboundMovePlayerPacketRot, - 0x16: serverbound_move_player_packet_status_only::ServerboundMovePlayerPacketStatusOnly, + 0x03: serverbound_chat_ack_packet::ServerboundChatAckPacket, + 0x04: serverbound_chat_command_packet::ServerboundChatCommandPacket, + 0x05: serverbound_chat_packet::ServerboundChatPacket, + 0x06: serverbound_chat_preview_packet::ServerboundChatPreviewPacket, + 0x0d: serverbound_custom_payload_packet::ServerboundCustomPayloadPacket, + 0x12: serverbound_keep_alive_packet::ServerboundKeepAlivePacket, + 0x14: serverbound_move_player_packet_pos::ServerboundMovePlayerPacketPos, + 0x15: serverbound_move_player_packet_pos_rot::ServerboundMovePlayerPacketPosRot, + 0x16: serverbound_move_player_packet_rot::ServerboundMovePlayerPacketRot, + 0x17: serverbound_move_player_packet_status_only::ServerboundMovePlayerPacketStatusOnly, }, Clientbound => { 0x00: clientbound_add_entity_packet::ClientboundAddEntityPacket, @@ -105,8 +109,8 @@ declare_state_packets!( 0x29: clientbound_move_entity_posrot_packet::ClientboundMoveEntityPosrotPacket, 0x2a: clientbound_move_entity_rot_packet::ClientboundMoveEntityRotPacket, 0x31: clientbound_player_abilities_packet::ClientboundPlayerAbilitiesPacket, - 0x32: clientbound_player_chat_packet::ClientboundPlayerChatPacket, - 0x33: clientbound_player_chat_header_packet::ClientboundPlayerChatHeaderPacket, + 0x32: clientbound_player_chat_header_packet::ClientboundPlayerChatHeaderPacket, + 0x33: clientbound_player_chat_packet::ClientboundPlayerChatPacket, 0x37: clientbound_player_info_packet::ClientboundPlayerInfoPacket, 0x39: clientbound_player_position_packet::ClientboundPlayerPositionPacket, 0x3a: clientbound_recipe_packet::ClientboundRecipePacket, diff --git a/azalea-protocol/src/packets/game/serverbound_chat_ack_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_ack_packet.rs new file mode 100644 index 00000000..759373e9 --- /dev/null +++ b/azalea-protocol/src/packets/game/serverbound_chat_ack_packet.rs @@ -0,0 +1,8 @@ +use crate::packets::game::clientbound_player_chat_packet::LastSeenUpdate; +use azalea_buf::McBuf; +use packet_macros::GamePacket; + +#[derive(Clone, Debug, McBuf, GamePacket)] +pub struct ServerboundChatAckPacket { + pub last_seen_messages: LastSeenUpdate, +} diff --git a/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs index 6371463b..1639deae 100644 --- a/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_chat_command_packet.rs @@ -1,19 +1,22 @@ -use std::collections::HashMap; - use azalea_buf::McBuf; +use azalea_crypto::MessageSignature; use packet_macros::GamePacket; +use super::clientbound_player_chat_packet::LastSeenMessagesUpdate; + #[derive(Clone, Debug, McBuf, GamePacket)] pub struct ServerboundChatCommandPacket { pub command: String, // TODO: Choose a real timestamp type pub timestamp: u64, - pub argument_signatures: ArgumentSignatures, + pub salt: i64, + pub argument_signatures: Vec, pub signed_preview: bool, + pub last_seen_messages: LastSeenMessagesUpdate, } #[derive(Clone, Debug, McBuf)] -pub struct ArgumentSignatures { - pub salt: u64, - pub signatures: HashMap>, +pub struct ArgumentSignature { + pub name: String, + pub signature: MessageSignature, } diff --git a/azalea-protocol/src/packets/game/serverbound_chat_packet.rs b/azalea-protocol/src/packets/game/serverbound_chat_packet.rs new file mode 100644 index 00000000..f0c99b14 --- /dev/null +++ b/azalea-protocol/src/packets/game/serverbound_chat_packet.rs @@ -0,0 +1,14 @@ +use crate::packets::game::clientbound_player_chat_packet::LastSeenMessagesUpdate; +use azalea_buf::McBuf; +use azalea_crypto::MessageSignature; +use packet_macros::GamePacket; + +#[derive(Clone, Debug, McBuf, GamePacket)] +pub struct ServerboundChatPacket { + pub message: String, + pub timestamp: u64, + pub salt: u64, + pub signature: MessageSignature, + pub signed_preview: bool, + pub last_seen_messages: LastSeenMessagesUpdate, +} diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index 64a5b3b3..2ea163af 100644 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -7,7 +7,7 @@ use crate::connect::PacketFlow; use azalea_buf::{McBufWritable, Readable, Writable}; use std::io::{Read, Write}; -pub const PROTOCOL_VERSION: u32 = 1073741921; +pub const PROTOCOL_VERSION: u32 = 1073741924; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ConnectionProtocol {