From cbb2ffad920ba88ad042a5d3ea932a62d42f3d4b Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 28 Dec 2023 17:49:41 -0600 Subject: read nbt as optional in more places --- azalea-chat/Cargo.toml | 2 +- azalea-chat/src/component.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'azalea-chat') 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 { - 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()) + } } } -- cgit v1.2.3