diff --git a/pumpkin-protocol/src/client/play/c_update_objectives.rs b/pumpkin-protocol/src/client/play/c_update_objectives.rs index 60845dc56..3b1dadbb9 100644 --- a/pumpkin-protocol/src/client/play/c_update_objectives.rs +++ b/pumpkin-protocol/src/client/play/c_update_objectives.rs @@ -1,7 +1,7 @@ use pumpkin_core::text::{style::Style, TextComponent}; use pumpkin_macros::packet; -use crate::{ClientPacket, VarInt}; +use crate::{ClientPacket, NumberFormat, VarInt}; #[packet(0x5E)] pub struct CUpdateObjectives<'a> { @@ -15,16 +15,16 @@ pub struct CUpdateObjectives<'a> { impl<'a> CUpdateObjectives<'a> { pub fn new( objective_name: &'a str, - mode: u8, + mode: Mode, display_name: TextComponent<'a>, - render_type: VarInt, + render_type: RenderType, number_format: Option>, ) -> Self { Self { objective_name, - mode, + mode: mode as u8, display_name, - render_type, + render_type: VarInt(render_type as i32), number_format, } } @@ -69,12 +69,3 @@ pub enum RenderType { Integer, Hearts, } - -pub enum NumberFormat<'a> { - /// Show nothing - Blank, - /// The styling to be used when formatting the score number - Styled(Style<'a>), - /// The text to be used as placeholder. - Fixed(TextComponent<'a>), -} diff --git a/pumpkin-protocol/src/client/play/c_update_score.rs b/pumpkin-protocol/src/client/play/c_update_score.rs new file mode 100644 index 000000000..f7ecc0d7e --- /dev/null +++ b/pumpkin-protocol/src/client/play/c_update_score.rs @@ -0,0 +1,31 @@ +use pumpkin_core::text::TextComponent; +use pumpkin_macros::packet; + +use crate::{NumberFormat, VarInt}; + +#[packet(0x61)] +pub struct CUpdateScore<'a> { + entity_name: &'a str, + objective_name: &'a str, + value: VarInt, + display_name: Option>, + number_format: Option>, +} + +impl<'a> CUpdateScore<'a> { + pub fn new( + entity_name: &'a str, + objective_name: &'a str, + value: VarInt, + display_name: Option>, + number_format: Option>, + ) -> Self { + Self { + entity_name, + objective_name, + value, + display_name, + number_format, + } + } +} diff --git a/pumpkin-protocol/src/client/play/mod.rs b/pumpkin-protocol/src/client/play/mod.rs index 816f4a8b7..9ce3111dc 100644 --- a/pumpkin-protocol/src/client/play/mod.rs +++ b/pumpkin-protocol/src/client/play/mod.rs @@ -43,6 +43,7 @@ mod c_update_entity_pos; mod c_update_entity_pos_rot; mod c_update_entity_rot; mod c_update_objectives; +mod c_update_score; mod c_worldevent; mod player_action; @@ -91,5 +92,6 @@ pub use c_update_entity_pos::*; pub use c_update_entity_pos_rot::*; pub use c_update_entity_rot::*; pub use c_update_objectives::*; +pub use c_update_score::*; pub use c_worldevent::*; pub use player_action::*; diff --git a/pumpkin-protocol/src/lib.rs b/pumpkin-protocol/src/lib.rs index f51cb750f..7b498490e 100644 --- a/pumpkin-protocol/src/lib.rs +++ b/pumpkin-protocol/src/lib.rs @@ -244,3 +244,12 @@ pub struct KnownPack<'a> { pub id: &'a str, pub version: &'a str, } + +pub enum NumberFormat<'a> { + /// Show nothing + Blank, + /// The styling to be used when formatting the score number + Styled(Style<'a>), + /// The text to be used as placeholder. + Fixed(TextComponent<'a>), +}