chunkedge_protocol/packets/play/
set_objective_s2c.rs

1use std::borrow::Cow;
2
3use bevy_ecs::prelude::*;
4use chunkedge_binary::{Decode, Encode, TextComponent};
5use chunkedge_nbt::Compound;
6
7use crate::Packet;
8
9#[derive(Clone, Debug, Encode, Decode, Packet)]
10pub struct SetObjectiveS2c<'a> {
11    pub objective_name: &'a str,
12    pub mode: ObjectiveMode<'a>,
13}
14
15#[derive(Clone, PartialEq, Debug, Encode, Decode)]
16pub enum ObjectiveMode<'a> {
17    Create {
18        objective_display_name: Cow<'a, TextComponent>,
19        render_type: ObjectiveRenderType,
20        number_format: Option<NumberFormat<'a>>,
21    },
22    Remove,
23    Update {
24        objective_display_name: Cow<'a, TextComponent>,
25        render_type: ObjectiveRenderType,
26        number_format: Option<NumberFormat<'a>>,
27    },
28}
29
30#[derive(Copy, Clone, PartialEq, Eq, Debug, Encode, Decode, Component, Default)]
31pub enum ObjectiveRenderType {
32    /// Display the value as a number.
33    #[default]
34    Integer,
35    /// Display the value as hearts.
36    Hearts,
37}
38#[derive(Clone, PartialEq, Debug, Encode, Decode, Component)]
39pub enum NumberFormat<'a> {
40    Blank,
41    Styled { styling: Compound },
42    Fixed { content: Cow<'a, TextComponent> },
43}