From 1dc56b6f519f386b6e0b5eac47a84576cedbbb33 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 16 Dec 2021 17:55:45 -0600 Subject: [PATCH] fix errors --- Cargo.lock | 1 + azalea-auth/src/game_profile.rs | 2 +- azalea-protocol/Cargo.toml | 1 + .../login/clientbound_game_profile_packet.rs | 23 ++++++++++--------- .../clientbound_login_compression_packet.rs | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f6baa86..529931b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,6 +77,7 @@ dependencies = [ "tokio", "tokio-util", "trust-dns-resolver", + "uuid", ] [[package]] diff --git a/azalea-auth/src/game_profile.rs b/azalea-auth/src/game_profile.rs index a186a208..d75f60a4 100644 --- a/azalea-auth/src/game_profile.rs +++ b/azalea-auth/src/game_profile.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use uuid::Uuid; -#[derive(Hash, Clone, Debug)] +#[derive(Clone, Debug)] pub struct GameProfile { pub uuid: Uuid, pub name: String, diff --git a/azalea-protocol/Cargo.toml b/azalea-protocol/Cargo.toml index cf97f089..9b5c3c07 100644 --- a/azalea-protocol/Cargo.toml +++ b/azalea-protocol/Cargo.toml @@ -19,3 +19,4 @@ thiserror = "^1.0.30" tokio = {version = "^1.14.0", features = ["io-util", "net", "macros"]} tokio-util = "^0.6.9" trust-dns-resolver = "^0.20.3" +uuid = "^0.8.2" diff --git a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs index 88166c54..04ba5369 100644 --- a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs @@ -1,11 +1,11 @@ use super::LoginPacket; use crate::mc_buf::{Readable, Writable}; use azalea_auth::game_profile::GameProfile; -use azalea_core::{resource_location::ResourceLocation, serializable_uuid::SerializableUuid}; -use std::hash::Hash; +use azalea_core::serializable_uuid::SerializableUuid; use tokio::io::BufReader; +use uuid::Uuid; -#[derive(Hash, Clone, Debug)] +#[derive(Clone, Debug)] pub struct ClientboundGameProfilePacket { pub game_profile: GameProfile, } @@ -25,15 +25,16 @@ impl ClientboundGameProfilePacket { pub async fn read( buf: &mut BufReader, ) -> Result { - let uuid = SerializableUuid::from_int_array( - buf.read_int().await?, - buf.read_int().await?, - buf.read_int().await?, - buf.read_int().await?, - ); - let name = buf.read_utf(16).await?; - ClientboundGameProfilePacket { + let uuid = Uuid::from_int_array([ + buf.read_int().await? as u32, + buf.read_int().await? as u32, + buf.read_int().await? as u32, + buf.read_int().await? as u32, + ]); + let name = buf.read_utf_with_len(16).await?; + Ok(ClientboundGameProfilePacket { game_profile: GameProfile::new(uuid, name), } + .get()) } } diff --git a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs index 87fc6e03..53c6c9e1 100644 --- a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs @@ -1,7 +1,7 @@ use std::hash::Hash; use tokio::io::BufReader; -use crate::mc_buf::Readable; +use crate::mc_buf::{Readable, Writable}; use super::LoginPacket; @@ -25,7 +25,7 @@ impl ClientboundLoginCompressionPacket { let compression_threshold = buf.read_varint().await?; Ok(ClientboundLoginCompressionPacket { - compression_threshold + compression_threshold, } .get()) }