Skip to main content

azalea_chat/component/
nbt.rs

1use azalea_codec::Codec;
2use azalea_core::identifier::Identifier;
3
4use crate::{
5    FormattedText,
6    component::{base::BaseComponent, common::BlockPosArgument, text::TextComponent},
7};
8
9#[derive(Clone, Debug, PartialEq, Codec)]
10pub struct NbtComponent {
11    // NBT_PATH_CODEC
12    pub nbt: String,
13    #[codec(lenient)]
14    pub interpret: bool,
15    #[codec(lenient)]
16    pub plain: bool,
17    #[codec(lenient)]
18    pub separator: Option<Box<FormattedText>>,
19
20    #[codec(flatten)]
21    pub base: BaseComponent,
22}
23
24#[derive(Clone, Debug, PartialEq, Codec)]
25#[codec(tag = "source")]
26#[codec(default_snake_case_key)]
27pub enum DataSource {
28    Entity {
29        // TODO: EntitySelector.COMPILABLE_CODEC
30        entity: String,
31    },
32    Block {
33        block: BlockPosArgument,
34    },
35    Storage {
36        storage: Identifier,
37    },
38}
39
40impl NbtComponent {
41    pub fn into_text_component(self) -> TextComponent {
42        TextComponent::default().with_base(self.base)
43    }
44}