aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/mc_buf
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-04-26 15:13:47 +0000
committermat <github@matdoes.dev>2022-04-26 15:13:47 +0000
commitf9528a9f9a9e73b1d657af7c78d743067307d843 (patch)
treed24e46982572d3b8607e130a5f24a7f7c198f484 /azalea-protocol/src/mc_buf
parent15b4dd6bd1c50ee8a9ebadf781e3ecbfdf62e266 (diff)
downloadazalea-drasl-f9528a9f9a9e73b1d657af7c78d743067307d843.tar.xz
work on adding more stuff for recipes
Diffstat (limited to 'azalea-protocol/src/mc_buf')
-rwxr-xr-xazalea-protocol/src/mc_buf/read.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs
index 3d50e5aa..1e7db1dd 100755
--- a/azalea-protocol/src/mc_buf/read.rs
+++ b/azalea-protocol/src/mc_buf/read.rs
@@ -1,11 +1,12 @@
+use crate::mc_buf::ByteArray;
use async_trait::async_trait;
use azalea_chat::component::Component;
use azalea_core::{
- difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation,
+ difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation, Slot,
+ SlotData,
};
use serde::Deserialize;
use tokio::io::{AsyncRead, AsyncReadExt};
-use crate::mc_buf::ByteArray;
use super::MAX_STRING_LENGTH;
@@ -252,7 +253,6 @@ impl McBufReadable for Vec<u8> {
}
}
-
#[async_trait]
impl McBufReadable for ByteArray {
async fn read_into<R>(buf: &mut R) -> Result<Self, String>
@@ -469,3 +469,21 @@ impl McBufReadable for Component {
Ok(component)
}
}
+
+// Slot
+#[async_trait]
+impl McBufReadable for Slot {
+ async fn read_into<R>(buf: &mut R) -> Result<Self, String>
+ where
+ R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ {
+ let present = buf.read_boolean().await?;
+ if !present {
+ return Ok(Slot::Empty);
+ }
+ let id = buf.read_varint().await?;
+ let count = buf.read_byte().await?;
+ let nbt = buf.read_nbt().await?;
+ Ok(Slot::Present(SlotData { id, count, nbt }))
+ }
+}