diff --git a/src/mc_types.rs b/src/mc_types.rs index c5bf232..e07541b 100644 --- a/src/mc_types.rs +++ b/src/mc_types.rs @@ -13,6 +13,7 @@ use rand::Rng; use crate::login; use crate::encrypt; +use crate::play::Play; pub type Result = std::result::Result>; @@ -235,6 +236,18 @@ impl<'a> ProtocolConnection<'a> { None => Err(Box::new(PacketError::EncryptionError)) } } + + pub async fn forward_play( + &mut self, + other: &mut ProtocolConnection<'_>, + ) -> Result<()> { + loop { + let packet = Play::read(self).await?; + match packet { + Play::PlayPacket(packet) => packet.write(other).await?, + }; + } + } } #[async_trait]