aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-07 21:54:27 -0500
committermat <github@matdoes.dev>2022-05-07 21:54:27 -0500
commitffba10185401ebdbfd93b1181eda04ce08fa72d5 (patch)
tree5934033d0ffad3d027e69ed465478fca2438916c /azalea-protocol/src/packets
parentf62a681474df698d87deb43c71238b83a26f0f1f (diff)
downloadazalea-drasl-ffba10185401ebdbfd93b1181eda04ce08fa72d5.tar.xz
chat and sound packets
Diffstat (limited to 'azalea-protocol/src/packets')
-rw-r--r--azalea-protocol/src/packets/game/clientbound_chat_packet.rs17
-rw-r--r--azalea-protocol/src/packets/game/clientbound_sound_packet.rs28
-rwxr-xr-xazalea-protocol/src/packets/game/mod.rs4
3 files changed, 49 insertions, 0 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs
new file mode 100644
index 00000000..3786993a
--- /dev/null
+++ b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs
@@ -0,0 +1,17 @@
+use azalea_chat::component::Component;
+use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use uuid::Uuid;
+
+#[derive(Clone, Debug, GamePacket)]
+pub struct ClientboundChatPacket {
+ pub message: Component,
+ pub type_: ChatType,
+ pub sender: Uuid,
+}
+
+#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)]
+pub enum ChatType {
+ Chat = 0,
+ System = 1,
+ GameInfo = 2,
+}
diff --git a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs
new file mode 100644
index 00000000..67e832fe
--- /dev/null
+++ b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs
@@ -0,0 +1,28 @@
+use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+
+#[derive(Clone, Debug, GamePacket)]
+pub struct ClientboundSoundPacket {
+ #[var]
+ /// TODO: use the sound registry instead of just being a u32
+ pub sound: u32,
+ pub source: SoundSource,
+ pub x: i32,
+ pub y: i32,
+ pub z: i32,
+ pub volume: f32,
+ pub pitch: f32,
+}
+
+#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)]
+pub enum SoundSource {
+ Master = 0,
+ Music = 1,
+ Records = 2,
+ Weather = 3,
+ Blocks = 4,
+ Hostile = 5,
+ Neutral = 6,
+ Players = 7,
+ Ambient = 8,
+ Voice = 9,
+}
diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs
index dd3a7527..031e95f7 100755
--- a/azalea-protocol/src/packets/game/mod.rs
+++ b/azalea-protocol/src/packets/game/mod.rs
@@ -2,6 +2,7 @@ pub mod clientbound_add_entity_packet;
pub mod clientbound_add_mob_packet;
pub mod clientbound_add_player_packet;
pub mod clientbound_change_difficulty_packet;
+pub mod clientbound_chat_packet;
pub mod clientbound_container_set_content_packet;
pub mod clientbound_custom_payload_packet;
pub mod clientbound_declare_commands_packet;
@@ -30,6 +31,7 @@ pub mod clientbound_set_entity_link_packet;
pub mod clientbound_set_experience_packet;
pub mod clientbound_set_health_packet;
pub mod clientbound_set_time_packet;
+pub mod clientbound_sound_packet;
pub mod clientbound_teleport_entity_packet;
pub mod clientbound_update_advancements_packet;
pub mod clientbound_update_attributes_packet;
@@ -52,6 +54,7 @@ declare_state_packets!(
0x02: clientbound_add_mob_packet::ClientboundAddMobPacket,
0x04: clientbound_add_player_packet::ClientboundAddPlayerPacket,
0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket,
+ 0xf: clientbound_chat_packet::ClientboundChatPacket,
0x12: clientbound_declare_commands_packet::ClientboundDeclareCommandsPacket,
0x14: clientbound_container_set_content_packet::ClientboundContainerSetContentPacket,
0x1a: clientbound_disconnect_packet::ClientboundDisconnectPacket,
@@ -81,6 +84,7 @@ declare_state_packets!(
0x51: clientbound_set_experience_packet::ClientboundSetExperiencePacket,
0x52: clientbound_set_health_packet::ClientboundSetHealthPacket,
0x59: clientbound_set_time_packet::ClientboundSetTimePacket,
+ 0x5d: clientbound_sound_packet::ClientboundSoundPacket,
0x62: clientbound_teleport_entity_packet::ClientboundTeleportEntityPacket,
0x63: clientbound_update_advancements_packet::ClientboundUpdateAdvancementsPacket,
0x64: clientbound_update_attributes_packet::ClientboundUpdateAttributesPacket,