diff options
| author | mat <git@matdoes.dev> | 2023-12-28 17:49:41 -0600 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-12-28 17:49:47 -0600 |
| commit | cbb2ffad920ba88ad042a5d3ea932a62d42f3d4b (patch) | |
| tree | 41122677c94ca181e898b5d07700714f1b2f3f61 /azalea-chat | |
| parent | cacb04718dd4142bded181d004f1fa40fe7ae178 (diff) | |
| download | azalea-drasl-cbb2ffad920ba88ad042a5d3ea932a62d42f3d4b.tar.xz | |
read nbt as optional in more places
Diffstat (limited to 'azalea-chat')
| -rw-r--r-- | azalea-chat/Cargo.toml | 2 | ||||
| -rwxr-xr-x | azalea-chat/src/component.rs | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/azalea-chat/Cargo.toml b/azalea-chat/Cargo.toml index 5aaf7125..247285c5 100644 --- a/azalea-chat/Cargo.toml +++ b/azalea-chat/Cargo.toml @@ -19,7 +19,7 @@ azalea-buf = { path = "../azalea-buf", features = [ "serde_json", ], version = "0.9.0", optional = true } azalea-language = { path = "../azalea-language", version = "0.9.0" } -simdnbt = { version = "0.3", optional = true } +simdnbt = { version = "0.3", optional = true, git = "https://github.com/azalea-rs/simdnbt" } tracing = "0.1.40" once_cell = "1.18.0" serde = { version = "^1.0", features = ["derive"] } diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs index 94a5125f..bd9b7269 100755 --- a/azalea-chat/src/component.rs +++ b/azalea-chat/src/component.rs @@ -412,9 +412,13 @@ impl simdnbt::FromNbtTag for FormattedText { #[cfg(feature = "azalea-buf")] impl McBufReadable for FormattedText { fn read_from(buf: &mut std::io::Cursor<&[u8]>) -> Result<Self, BufReadError> { - let nbt = simdnbt::borrow::NbtTag::read(buf)?; - FormattedText::from_nbt_tag(&nbt) - .ok_or(BufReadError::Custom("couldn't read nbt".to_owned())) + let nbt = simdnbt::borrow::NbtTag::read_optional(buf)?; + if let Some(nbt) = nbt { + FormattedText::from_nbt_tag(&nbt) + .ok_or(BufReadError::Custom("couldn't read nbt".to_owned())) + } else { + Ok(FormattedText::default()) + } } } |
