From 9642558f8f8d983a7087f15d68be8cf07a85f0c2 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 15 Dec 2021 23:10:55 -0600 Subject: azalea --- minecraft-protocol/src/read.rs | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 minecraft-protocol/src/read.rs (limited to 'minecraft-protocol/src/read.rs') diff --git a/minecraft-protocol/src/read.rs b/minecraft-protocol/src/read.rs deleted file mode 100644 index 6f242e8b..00000000 --- a/minecraft-protocol/src/read.rs +++ /dev/null @@ -1,28 +0,0 @@ -use tokio::{io::BufReader, net::TcpStream}; - -use crate::{connect::PacketFlow, mc_buf::Readable, packets::ProtocolPacket}; - -pub async fn read_packet( - flow: &PacketFlow, - stream: &mut TcpStream, -) -> Result { - // what this does: - // 1. reads the first 5 bytes, probably only some of this will be used to get the packet length - // 2. how much we should read = packet length - 5 - // 3. read the rest of the packet and add it to the cursor - // 4. figure out what packet this is and parse it - - // the first thing minecraft sends us is the length as a varint, which can be up to 5 bytes long - let mut buf = BufReader::with_capacity(4 * 1024 * 1024, stream); - - let (_packet_size, _packet_size_varint_size) = buf.read_varint().await?; - - // then, minecraft tells us the packet id as a varint - let (packet_id, _packet_id_size) = buf.read_varint().await?; - - // if we recognize the packet id, parse it - - let packet = P::read(packet_id.try_into().unwrap(), flow, &mut buf).await?; - - Ok(packet) -} -- cgit v1.2.3