aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-01-01 23:55:19 -0600
committermat <github@matdoes.dev>2022-01-01 23:55:19 -0600
commita1afbb6031527c1db5831fc8e916bc0ecce633b4 (patch)
tree56fbccf52645cc2eefd231506ffe8ed71018dc01 /azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs
parente81b85dd5bdd6d42ee84f24ed4a142f6141f170e (diff)
downloadazalea-drasl-a1afbb6031527c1db5831fc8e916bc0ecce633b4.tar.xz
start adding packet macros
Diffstat (limited to 'azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs')
-rw-r--r--azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs28
1 files changed, 4 insertions, 24 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 63047801..24220a83 100644
--- a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs
@@ -1,30 +1,10 @@
-use super::GamePacket;
use crate::mc_buf::{Readable, Writable};
-use azalea_core::{game_type::GameType, resource_location::ResourceLocation};
+use crate::packets::game::GamePacket;
+use azalea_core::resource_location::ResourceLocation;
+use packet_macros::GamePacket;
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, GamePacket)]
pub struct ClientboundCustomPayloadPacket {
pub identifier: ResourceLocation,
pub data: Vec<u8>,
}
-
-impl ClientboundCustomPayloadPacket {
- pub fn get(self) -> GamePacket {
- GamePacket::ClientboundCustomPayloadPacket(self)
- }
-
- pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
- buf.write_resource_location(&self.identifier)?;
- buf.write_bytes(&self.data)?;
- Ok(())
- }
-
- pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
- buf: &mut T,
- ) -> Result<GamePacket, String> {
- let identifier = buf.read_resource_location().await?;
- let data = buf.read_bytes().await?;
-
- Ok(ClientboundCustomPayloadPacket { identifier, data }.get())
- }
-}