From 43fbb6a68d58df47e6ce1d3cc59ea40b3670eec4 Mon Sep 17 00:00:00 2001 From: Snowiiii Date: Mon, 19 Aug 2024 15:05:16 +0200 Subject: [PATCH] Fix: Resource pack --- .../src/client/config/c_add_resource_pack.rs | 18 ++++++++++-------- pumpkin/src/client/client_packet.rs | 10 ++++++---- pumpkin/src/client/player_packet.rs | 6 ++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/pumpkin-protocol/src/client/config/c_add_resource_pack.rs b/pumpkin-protocol/src/client/config/c_add_resource_pack.rs index 2980d85d0..6a112e36e 100644 --- a/pumpkin-protocol/src/client/config/c_add_resource_pack.rs +++ b/pumpkin-protocol/src/client/config/c_add_resource_pack.rs @@ -2,21 +2,23 @@ use pumpkin_macros::packet; use pumpkin_text::TextComponent; use serde::Serialize; +use crate::uuid::UUID; + #[derive(Serialize)] #[packet(0x09)] -pub struct CConfigAddResourcePack { - uuid: uuid::Uuid, - url: String, - hash: String, +pub struct CConfigAddResourcePack<'a> { + uuid: UUID, + url: &'a str, + hash: &'a str, // max 40 forced: bool, prompt_message: Option, } -impl CConfigAddResourcePack { +impl<'a> CConfigAddResourcePack<'a> { pub fn new( - uuid: uuid::Uuid, - url: String, - hash: String, + uuid: UUID, + url: &'a str, + hash: &'a str, forced: bool, prompt_message: Option, ) -> Self { diff --git a/pumpkin/src/client/client_packet.rs b/pumpkin/src/client/client_packet.rs index ded91bdd3..ac0698009 100644 --- a/pumpkin/src/client/client_packet.rs +++ b/pumpkin/src/client/client_packet.rs @@ -1,4 +1,3 @@ -use std::str::FromStr; use num_traits::FromPrimitive; use pumpkin_protocol::{ @@ -203,9 +202,12 @@ impl Client { Some(TextComponent::from(resource_config.prompt_message.clone())) }; self.send_packet(&CConfigAddResourcePack::new( - uuid::Uuid::from_str(&resource_config.resource_pack_url).unwrap(), - resource_config.resource_pack_url.clone(), - resource_config.resource_pack_sha1.clone(), + pumpkin_protocol::uuid::UUID(uuid::Uuid::new_v3( + &uuid::Uuid::NAMESPACE_DNS, + resource_config.resource_pack_url.as_bytes(), + )), + &resource_config.resource_pack_url, + &resource_config.resource_pack_sha1, resource_config.force, prompt_message, )); diff --git a/pumpkin/src/client/player_packet.rs b/pumpkin/src/client/player_packet.rs index 51d4d878e..9bf292f34 100644 --- a/pumpkin/src/client/player_packet.rs +++ b/pumpkin/src/client/player_packet.rs @@ -116,7 +116,7 @@ impl Client { entity.x = Self::clamp_horizontal(position_rotation.x); entity.y = Self::clamp_vertical(position_rotation.feet_y); entity.z = Self::clamp_horizontal(position_rotation.z); - entity.yaw = wrap_degrees(position_rotation.yaw) % 360.0; + entity.yaw = wrap_degrees(position_rotation.yaw) % 360.0; entity.pitch = wrap_degrees(position_rotation.pitch).clamp(-90.0, 90.0) % 360.0; // send new position to all other players @@ -314,9 +314,7 @@ impl Client { &CHurtAnimation::new(&entity_id, 10.0), ) } - if config.swing { - - } + if config.swing {} } else { self.kick("Interacted with invalid entitiy id") }