From dd24110019c0ded21e064b2273acc326173c84f5 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 26 Apr 2022 22:58:18 +0000 Subject: add derive mcbufreadable/writable --- azalea-protocol/src/mc_buf/write.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'azalea-protocol/src/mc_buf') diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index e8845f25..2c46157b 100755 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -2,7 +2,7 @@ use super::{UnsizedByteArray, MAX_STRING_LENGTH}; 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, }; use byteorder::{BigEndian, WriteBytesExt}; use std::io::Write; @@ -337,3 +337,19 @@ impl McBufWritable for Component { todo!() } } + +// Slot +impl McBufWritable for Slot { + fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + match self { + Slot::Empty => buf.write_byte(0)?, + Slot::Present(i) => { + buf.write_varint(i.id)?; + buf.write_byte(i.count)?; + buf.write_nbt(&i.nbt)?; + } + } + + Ok(()) + } +} -- cgit v1.2.3