Pumpkin/pumpkin-protocol/src/text.rs
Snowiiii a0d92fe45c Add Text component
currently very simple, Will be expanded later
2024-08-04 12:22:59 +02:00

18 lines
414 B
Rust

use core::str;
use fastnbt::SerOpts;
use serde::{Deserialize, Serialize};
// represents a text component
// Reference: https://wiki.vg/Text_formatting#Text_components
#[derive(Clone, PartialEq, Default, Debug, Serialize, Deserialize)]
pub struct Text {
pub text: String,
}
impl Text {
pub fn encode(&self) -> Vec<u8> {
fastnbt::to_bytes_with_opts(&self, SerOpts::network_nbt()).unwrap()
}
}