Add Text component
currently very simple, Will be expanded later
This commit is contained in:
parent
19af3618cb
commit
a0d92fe45c
@ -8,6 +8,7 @@ use thiserror::Error;
|
||||
pub mod bytebuf;
|
||||
pub mod client;
|
||||
pub mod server;
|
||||
pub mod text;
|
||||
|
||||
pub mod packet_decoder;
|
||||
pub mod packet_encoder;
|
||||
|
||||
17
pumpkin-protocol/src/text.rs
Normal file
17
pumpkin-protocol/src/text.rs
Normal file
@ -0,0 +1,17 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user