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/src/component.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'azalea-chat/src') 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