From 41442c5b5dd230264b4c70d2dccf848ff46d9807 Mon Sep 17 00:00:00 2001 From: Snowiiii Date: Sun, 11 Aug 2024 14:18:56 +0200 Subject: [PATCH] Add text Titles --- pumpkin-protocol/src/client/play/c_actionbar.rs | 15 +++++++++++++++ pumpkin-protocol/src/client/play/c_set_title.rs | 15 +++++++++++++++ pumpkin-protocol/src/client/play/c_subtitle.rs | 15 +++++++++++++++ pumpkin-protocol/src/client/play/mod.rs | 6 ++++++ pumpkin/src/commands/gamemode.rs | 6 ------ pumpkin/src/commands/pumpkin.rs | 6 ------ 6 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 pumpkin-protocol/src/client/play/c_actionbar.rs create mode 100644 pumpkin-protocol/src/client/play/c_set_title.rs create mode 100644 pumpkin-protocol/src/client/play/c_subtitle.rs diff --git a/pumpkin-protocol/src/client/play/c_actionbar.rs b/pumpkin-protocol/src/client/play/c_actionbar.rs new file mode 100644 index 000000000..d9046de06 --- /dev/null +++ b/pumpkin-protocol/src/client/play/c_actionbar.rs @@ -0,0 +1,15 @@ +use pumpkin_macros::packet; +use pumpkin_text::TextComponent; +use serde::Serialize; + +#[derive(Serialize)] +#[packet(0x4C)] +pub struct CActionBar { + action_bar: TextComponent, +} + +impl CActionBar { + pub fn new(action_bar: TextComponent) -> Self { + Self { action_bar } + } +} diff --git a/pumpkin-protocol/src/client/play/c_set_title.rs b/pumpkin-protocol/src/client/play/c_set_title.rs new file mode 100644 index 000000000..7a549b904 --- /dev/null +++ b/pumpkin-protocol/src/client/play/c_set_title.rs @@ -0,0 +1,15 @@ +use pumpkin_macros::packet; +use pumpkin_text::TextComponent; +use serde::Serialize; + +#[derive(Serialize)] +#[packet(0x65)] +pub struct CTitleText { + title: TextComponent, +} + +impl CTitleText { + pub fn new(title: TextComponent) -> Self { + Self { title } + } +} diff --git a/pumpkin-protocol/src/client/play/c_subtitle.rs b/pumpkin-protocol/src/client/play/c_subtitle.rs new file mode 100644 index 000000000..35ebbe50b --- /dev/null +++ b/pumpkin-protocol/src/client/play/c_subtitle.rs @@ -0,0 +1,15 @@ +use pumpkin_macros::packet; +use pumpkin_text::TextComponent; +use serde::Serialize; + +#[derive(Serialize)] +#[packet(0x63)] +pub struct CSubtitle { + subtitle: TextComponent, +} + +impl CSubtitle { + pub fn new(subtitle: TextComponent) -> Self { + Self { subtitle } + } +} diff --git a/pumpkin-protocol/src/client/play/mod.rs b/pumpkin-protocol/src/client/play/mod.rs index 664d22b40..84b92e1d0 100644 --- a/pumpkin-protocol/src/client/play/mod.rs +++ b/pumpkin-protocol/src/client/play/mod.rs @@ -1,3 +1,4 @@ +mod c_actionbar; mod c_change_difficulty; mod c_chunk_data_update_light; mod c_disguised_chat_message; @@ -13,7 +14,9 @@ mod c_player_chat_message; mod c_player_info_update; mod c_remove_entities; mod c_set_held_item; +mod c_set_title; mod c_spawn_player; +mod c_subtitle; mod c_sync_player_position; mod c_system_chat_message; mod c_update_entitiy_pos_rot; @@ -21,6 +24,7 @@ mod c_update_entity_pos; mod c_update_entity_rot; mod player_action; +pub use c_actionbar::*; pub use c_change_difficulty::*; pub use c_chunk_data_update_light::*; pub use c_disguised_chat_message::*; @@ -36,7 +40,9 @@ pub use c_player_chat_message::*; pub use c_player_info_update::*; pub use c_remove_entities::*; pub use c_set_held_item::*; +pub use c_set_title::*; pub use c_spawn_player::*; +pub use c_subtitle::*; pub use c_sync_player_position::*; pub use c_system_chat_message::*; pub use c_update_entitiy_pos_rot::*; diff --git a/pumpkin/src/commands/gamemode.rs b/pumpkin/src/commands/gamemode.rs index f21345987..4533f06e9 100644 --- a/pumpkin/src/commands/gamemode.rs +++ b/pumpkin/src/commands/gamemode.rs @@ -2,12 +2,6 @@ use super::Command; pub struct GamemodeCommand {} -impl GamemodeCommand { - pub fn new() -> Self { - Self {} - } -} - impl<'a> Command<'a> for GamemodeCommand { const NAME: &'a str = "gamemode"; diff --git a/pumpkin/src/commands/pumpkin.rs b/pumpkin/src/commands/pumpkin.rs index 0b6eabc76..8a648dd50 100644 --- a/pumpkin/src/commands/pumpkin.rs +++ b/pumpkin/src/commands/pumpkin.rs @@ -7,12 +7,6 @@ use super::Command; pub struct PumpkinCommand {} -impl PumpkinCommand { - pub fn new() -> Self { - Self {} - } -} - impl<'a> Command<'a> for PumpkinCommand { const NAME: &'a str = "pumpkin";