diff --git a/README.md b/README.md index 251e3af5..4317a3ce 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,6 @@ This project was heavily inspired by PrismarineJS. - Bypass all anticheats - Only support the latest Minecraft version - +- Do everything a vanilla client can do diff --git a/azalea-protocol/src/mc_buf.rs b/azalea-protocol/src/mc_buf.rs index 6eab5db3..e165eba0 100644 --- a/azalea-protocol/src/mc_buf.rs +++ b/azalea-protocol/src/mc_buf.rs @@ -107,22 +107,6 @@ pub trait Readable { async fn read_byte(&mut self) -> Result; } -// unfortunately we can't put this in Readable since rust gets mad -pub async fn read_collection(buf: &mut R, reader: F) -> Result, String> -where - R: AsyncRead + std::marker::Unpin + std::marker::Send, - T: Send, - F: FnOnce(&mut R) -> Fut + Send + Copy, - Fut: Future> + Send, -{ - let mut v: Vec = Vec::new(); - let length = buf.read_varint().await?.0; - for _ in 0..length { - v.push(reader(buf).await?); - } - Ok(v) -} - #[async_trait] impl Readable for R where @@ -240,19 +224,21 @@ mod tests { let mut buf = BufReader::new(Cursor::new(vec![138, 56, 0, 135, 56, 123])); assert_eq!(buf.read_varint().await.unwrap(), (7178, 2)); } - - async fn readutf(r: &mut BufReader>>) -> Result { - r.read_utf().await - } - #[tokio::test] async fn test_collection() { let mut buf = Vec::new(); buf.write_collection(vec!["a", "bc", "def"], Vec::write_utf) .unwrap(); + // there's no read_collection because idk how to do it in rust let mut buf = BufReader::new(Cursor::new(buf)); - let result = read_collection(&mut buf, readutf).await.unwrap(); + + let mut result = Vec::new(); + let length = buf.read_varint().await.unwrap().0; + for _ in 0..length { + result.push(buf.read_utf().await.unwrap()); + } + assert_eq!(result, vec!["a", "bc", "def"]); } }