diff --git a/assets/message_type.json b/assets/message_type.json index 3bb0284ac..f34dc3bac 100644 --- a/assets/message_type.json +++ b/assets/message_type.json @@ -1 +1 @@ -{"chat":{"chat":{"translation_key":"chat.type.text","parameters":["sender","content"]},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}},"emote_command":{"chat":{"translation_key":"chat.type.emote","parameters":["sender","content"]},"narration":{"translation_key":"chat.type.emote","parameters":["sender","content"]}},"msg_command_incoming":{"chat":{"translation_key":"commands.message.display.incoming","parameters":["sender","content"],"style":{"italic":true,"color":"gray"}},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}},"msg_command_outgoing":{"chat":{"translation_key":"commands.message.display.outgoing","parameters":["target","content"],"style":{"italic":true,"color":"gray"}},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}},"say_command":{"chat":{"translation_key":"chat.type.announcement","parameters":["sender","content"]},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}},"team_msg_command_incoming":{"chat":{"translation_key":"chat.type.team.text","parameters":["target","sender","content"]},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}},"team_msg_command_outgoing":{"chat":{"translation_key":"chat.type.team.sent","parameters":["target","sender","content"]},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}}} \ No newline at end of file +{"chat":{"id":0,"components":{"chat":{"translation_key":"chat.type.text","parameters":["sender","content"]},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}}},"emote_command":{"id":1,"components":{"chat":{"translation_key":"chat.type.emote","parameters":["sender","content"]},"narration":{"translation_key":"chat.type.emote","parameters":["sender","content"]}}},"msg_command_incoming":{"id":2,"components":{"chat":{"translation_key":"commands.message.display.incoming","parameters":["sender","content"],"style":{"italic":true,"color":"gray"}},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}}},"msg_command_outgoing":{"id":3,"components":{"chat":{"translation_key":"commands.message.display.outgoing","parameters":["target","content"],"style":{"italic":true,"color":"gray"}},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}}},"say_command":{"id":4,"components":{"chat":{"translation_key":"chat.type.announcement","parameters":["sender","content"]},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}}},"team_msg_command_incoming":{"id":5,"components":{"chat":{"translation_key":"chat.type.team.text","parameters":["target","sender","content"]},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}}},"team_msg_command_outgoing":{"id":6,"components":{"chat":{"translation_key":"chat.type.team.sent","parameters":["target","sender","content"]},"narration":{"translation_key":"chat.type.text.narrate","parameters":["sender","content"]}}}} \ No newline at end of file diff --git a/pumpkin-data/Cargo.toml b/pumpkin-data/Cargo.toml index 9e96d644f..f9c83cccd 100644 --- a/pumpkin-data/Cargo.toml +++ b/pumpkin-data/Cargo.toml @@ -8,6 +8,8 @@ build = "build/build.rs" serde.workspace = true [build-dependencies] +pumpkin-util = { path = "../pumpkin-util" } + serde.workspace = true serde_json.workspace = true diff --git a/pumpkin-data/build/build.rs b/pumpkin-data/build/build.rs index ce9ee25d8..0e5554d39 100644 --- a/pumpkin-data/build/build.rs +++ b/pumpkin-data/build/build.rs @@ -10,6 +10,7 @@ mod chunk_status; mod entity_pose; mod entity_type; mod game_event; +mod message_type; mod noise_parmeter; mod packet; mod particle; @@ -33,6 +34,7 @@ pub fn main() { write_generated_file(entity_type::build(), "entity_type.rs"); write_generated_file(noise_parmeter::build(), "noise_parmeter.rs"); write_generated_file(biome::build(), "biome.rs"); + write_generated_file(message_type::build(), "message_type.rs"); } pub fn array_to_tokenstream(array: Vec) -> TokenStream { diff --git a/pumpkin-data/build/message_type.rs b/pumpkin-data/build/message_type.rs new file mode 100644 index 000000000..1403608cd --- /dev/null +++ b/pumpkin-data/build/message_type.rs @@ -0,0 +1,49 @@ +use std::collections::HashMap; + +use proc_macro2::TokenStream; +use pumpkin_util::text::style::Style; +use quote::quote; +use serde::{Deserialize, Serialize}; + +use crate::ident; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct RawChatType { + id: u32, + components: ChatType, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ChatType { + chat: Decoration, + narration: Decoration, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Decoration { + translation_key: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + style: Option