Add Clientbound Update Score

This commit is contained in:
Snowiiii committed 2024-10-18 15:09:32 +02:00
1 parent 3d03a4bbc5
commit 5d0bb14a85
4 files changed
+47 -14

No files matched your search

@@ -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<NumberFormat<'a>>,
) -> 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>),
}
@@ -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<TextComponent<'a>>,
number_format: Option<NumberFormat<'a>>,
}
impl<'a> CUpdateScore<'a> {
pub fn new(
entity_name: &'a str,
objective_name: &'a str,
value: VarInt,
display_name: Option<TextComponent<'a>>,
number_format: Option<NumberFormat<'a>>,
) -> Self {
Self {
entity_name,
objective_name,
value,
display_name,
number_format,
}
}
}
+2
View File
@@ -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::*;
+9
View File
@@ -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>),
}