diff options
| author | mat <github@matdoes.dev> | 2021-12-16 17:51:05 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-16 17:51:05 -0600 |
| commit | 227ba5511d50af8c7c46a47e09db7f55a0ed84b7 (patch) | |
| tree | 1067828ee2082e0f073a4d16b201b2888c55b6e8 /azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs | |
| parent | 999116ed7c5edf113e12aae150c2e23974d539dc (diff) | |
| download | azalea-drasl-227ba5511d50af8c7c46a47e09db7f55a0ed84b7.tar.xz | |
add a few more login packets
Diffstat (limited to 'azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs')
| -rw-r--r-- | azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs | 15 |
1 files changed, 6 insertions, 9 deletions
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 8f501fc9..2c66bfa3 100644 --- a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs @@ -1,15 +1,13 @@ +use super::LoginPacket; +use crate::mc_buf::{Readable, Writable}; +use azalea_core::resource_location::ResourceLocation; use std::hash::Hash; use tokio::io::BufReader; -use crate::mc_buf::{Readable, Writable}; - -use super::LoginPacket; - #[derive(Hash, Clone, Debug)] pub struct ClientboundCustomQueryPacket { pub transaction_id: u32, - // TODO: this should be a resource location - pub identifier: String, + pub identifier: ResourceLocation, pub data: Vec<u8>, } @@ -20,7 +18,7 @@ impl ClientboundCustomQueryPacket { pub fn write(&self, buf: &mut Vec<u8>) { buf.write_varint(self.transaction_id as i32).unwrap(); - buf.write_utf(&self.identifier).unwrap(); + buf.write_utf(self.identifier.to_string().as_str()).unwrap(); buf.write_bytes(&self.data).unwrap(); } @@ -28,8 +26,7 @@ impl ClientboundCustomQueryPacket { buf: &mut BufReader<T>, ) -> Result<LoginPacket, String> { let transaction_id = buf.read_varint().await? as u32; - // TODO: this should be a resource location - let identifier = buf.read_utf().await?; + let identifier = ResourceLocation::new(&buf.read_utf().await?)?; let data = buf.read_bytes(1048576).await?; Ok(ClientboundCustomQueryPacket { transaction_id, |
