aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-04-26 15:33:41 +0000
committermat <github@matdoes.dev>2022-04-26 15:33:41 +0000
commite5fcfa119309877ab515b921f8ada5f1b1ec4c30 (patch)
treec5084a2f7840979feaf7483e7b598cbc888c509f /azalea-protocol/src/packets
parentf9528a9f9a9e73b1d657af7c78d743067307d843 (diff)
downloadazalea-drasl-e5fcfa119309877ab515b921f8ada5f1b1ec4c30.tar.xz
default implementation for read and write Vec<T>
Diffstat (limited to 'azalea-protocol/src/packets')
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs44
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_update_tags_packet.rs27
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_custom_query_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_hello_packet.rs6
-rw-r--r--azalea-protocol/src/packets/login/serverbound_key_packet.rs6
6 files changed, 10 insertions, 79 deletions
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<u8>,
+ 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<Recipe> {
- fn write_into(&self, buf: &mut Vec<u8>) -> 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<Recipe> {
- async fn read_into<R>(buf: &mut R) -> Result<Self, String>
- 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<Ingredient> {
- fn write_into(&self, buf: &mut Vec<u8>) -> 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<Ingredient> {
- async fn read_into<R>(buf: &mut R) -> Result<Self, String>
- 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<ResourceLocation, Vec<Tags>> {
Ok(())
}
}
-
-#[async_trait]
-impl McBufReadable for Vec<Tags> {
- async fn read_into<R>(buf: &mut R) -> Result<Self, String>
- 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<Tags> {
- fn write_into(&self, buf: &mut Vec<u8>) -> 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<R>(buf: &mut R) -> Result<Self, String>
diff --git a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs
index 3138106e..9e1e1df5 100755
--- a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs
@@ -1,3 +1,4 @@
+use crate::mc_buf::UnsizedByteArray;
use azalea_core::resource_location::ResourceLocation;
use packet_macros::LoginPacket;
use std::hash::Hash;
@@ -7,5 +8,5 @@ pub struct ClientboundCustomQueryPacket {
#[varint]
pub transaction_id: u32,
pub identifier: ResourceLocation,
- pub data: Vec<u8>,
+ pub data: UnsizedByteArray,
}
diff --git a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
index d36f1335..20af1bec 100755
--- a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
@@ -1,13 +1,13 @@
use std::hash::Hash;
use super::LoginPacket;
-use crate::mc_buf::{ByteArray, Readable};
+use crate::mc_buf::Readable;
#[derive(Hash, Clone, Debug)]
pub struct ClientboundHelloPacket {
pub server_id: String,
- pub public_key: ByteArray,
- pub nonce: ByteArray,
+ pub public_key: Vec<u8>,
+ pub nonce: Vec<u8>,
}
impl ClientboundHelloPacket {
diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
index 3750331f..f402d357 100644
--- a/azalea-protocol/src/packets/login/serverbound_key_packet.rs
+++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
@@ -1,10 +1,10 @@
use super::LoginPacket;
-use crate::mc_buf::{ByteArray, Writable};
+use crate::mc_buf::Writable;
use packet_macros::LoginPacket;
use std::hash::Hash;
#[derive(Hash, Clone, Debug, LoginPacket)]
pub struct ServerboundKeyPacket {
- pub shared_secret: ByteArray,
- pub nonce: ByteArray,
+ pub shared_secret: Vec<u8>,
+ pub nonce: Vec<u8>,
}