azalea_chat/component/
object.rs1use azalea_codec::{Codec, types::Drain};
2use azalea_core::identifier::Identifier;
3
4use crate::{
5 FormattedText,
6 component::{base::BaseComponent, text::TextComponent},
7};
8
9#[derive(Clone, Debug, PartialEq, Codec)]
10pub struct ObjectComponent {
11 pub object: ObjectInfo,
12 #[codec(optional)]
13 pub fallback: Option<Box<FormattedText>>,
14
15 #[codec(flatten)]
16 pub base: BaseComponent,
17}
18
19#[derive(Clone, Debug, PartialEq, Codec)]
20#[codec(tag = "object")]
21#[codec(default_snake_case_key)]
22pub enum ObjectInfo {
23 Atlas {
24 #[codec(optional)]
25 atlas: Option<Identifier>,
26 sprite: Identifier,
27 },
28 Player {
29 player: Drain,
32 #[codec(optional)]
33 hat: bool,
34 },
35}
36
37impl ObjectComponent {
38 pub fn into_text_component(self) -> TextComponent {
39 TextComponent::default().with_base(self.base)
40 }
41}