diff options
| author | mat <github@matdoes.dev> | 2022-04-26 22:58:18 +0000 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-04-26 22:58:18 +0000 |
| commit | dd24110019c0ded21e064b2273acc326173c84f5 (patch) | |
| tree | 5d958ce932379a8b2548e01ccd09d08accce5450 /azalea-protocol/src/mc_buf/write.rs | |
| parent | 5736a790d34cb55202521fcfe807bea6eb5f07c7 (diff) | |
| download | azalea-drasl-dd24110019c0ded21e064b2273acc326173c84f5.tar.xz | |
add derive mcbufreadable/writable
Diffstat (limited to 'azalea-protocol/src/mc_buf/write.rs')
| -rwxr-xr-x | azalea-protocol/src/mc_buf/write.rs | 18 |
1 files changed, 17 insertions, 1 deletions
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<u8>) -> 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(()) + } +} |
