From e5fcfa119309877ab515b921f8ada5f1b1ec4c30 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 26 Apr 2022 15:33:41 +0000 Subject: default implementation for read and write Vec --- .../game/clientbound_custom_payload_packet.rs | 3 +- .../game/clientbound_update_recipes_packet.rs | 44 ---------------------- .../packets/game/clientbound_update_tags_packet.rs | 27 ------------- 3 files changed, 2 insertions(+), 72 deletions(-) (limited to 'azalea-protocol/src/packets/game') diff --git a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs index 134a3109..2c56ea2b 100755 --- a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs @@ -1,8 +1,9 @@ +use crate::mc_buf::UnsizedByteArray; use azalea_core::resource_location::ResourceLocation; use packet_macros::GamePacket; #[derive(Clone, Debug, GamePacket)] pub struct ClientboundCustomPayloadPacket { pub identifier: ResourceLocation, - pub data: Vec, + pub data: UnsizedByteArray, } diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs index 558b74c7..2e8532df 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs @@ -88,47 +88,3 @@ impl McBufReadable for Ingredient { Ok(ingredient) } } - -impl McBufWritable for Vec { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { - buf.write_varint(self.len() as i32)?; - for recipe in self { - recipe.write_into(buf)?; - } - Ok(()) - } -} -#[async_trait] -impl McBufReadable for Vec { - async fn read_into(buf: &mut R) -> Result - where - R: AsyncRead + std::marker::Unpin + std::marker::Send, - { - let recipe_count = buf.read_varint().await?; - let mut recipes = Vec::with_capacity(recipe_count as usize); - for _ in 0..recipe_count { - recipes.push(Recipe::read_into(buf).await?); - } - Ok(recipes) - } -} - -impl McBufWritable for Vec { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { - buf.write_varint(self.len() as i32)?; - for ingredient in self { - ingredient.write_into(buf)?; - } - Ok(()) - } -} - -#[async_trait] -impl McBufReadable for Vec { - async fn read_into(buf: &mut R) -> Result - where - R: AsyncRead + std::marker::Unpin + std::marker::Send, - { - todo!() - } -} diff --git a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs index a2f17370..66eee4b6 100755 --- a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs @@ -54,33 +54,6 @@ impl McBufWritable for HashMap> { Ok(()) } } - -#[async_trait] -impl McBufReadable for Vec { - async fn read_into(buf: &mut R) -> Result - where - R: AsyncRead + std::marker::Unpin + std::marker::Send, - { - let tags_count = buf.read_varint().await? as usize; - let mut tags_vec = Vec::with_capacity(tags_count); - for _ in 0..tags_count { - let tags = Tags::read_into(buf).await?; - tags_vec.push(tags); - } - Ok(tags_vec) - } -} - -impl McBufWritable for Vec { - fn write_into(&self, buf: &mut Vec) -> Result<(), std::io::Error> { - buf.write_varint(self.len() as i32)?; - for tag in self { - tag.write_into(buf)?; - } - Ok(()) - } -} - #[async_trait] impl McBufReadable for Tags { async fn read_into(buf: &mut R) -> Result -- cgit v1.2.3