From 9f496a89b5af63fef1a60276d6f7cf4d79c315e2 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 7 May 2022 16:54:02 -0500 Subject: basic code generator --- azalea-protocol/src/mc_buf/mod.rs | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) (limited to 'azalea-protocol/src/mc_buf/mod.rs') diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs index 1626d163..bee269c9 100755 --- a/azalea-protocol/src/mc_buf/mod.rs +++ b/azalea-protocol/src/mc_buf/mod.rs @@ -1,8 +1,10 @@ //! Utilities for reading and writing for the Minecraft protocol +mod definitions; mod read; mod write; +pub use definitions::{BitSet, EntityMetadata, UnsizedByteArray}; use packet_macros::{McBufReadable, McBufWritable}; pub use read::{read_varint_async, McBufReadable, McBufVarReadable, Readable}; use std::ops::Deref; @@ -14,43 +16,6 @@ const MAX_STRING_LENGTH: u16 = 32767; // TODO: have a definitions.rs in mc_buf that contains UnsizedByteArray and BitSet -/// A Vec that isn't prefixed by a VarInt with the size. -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct UnsizedByteArray(Vec); - -impl Deref for UnsizedByteArray { - type Target = Vec; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl From> for UnsizedByteArray { - fn from(vec: Vec) -> Self { - Self(vec) - } -} - -impl From<&str> for UnsizedByteArray { - fn from(s: &str) -> Self { - Self(s.as_bytes().to_vec()) - } -} - -/// Represents Java's BitSet, a list of bits. -#[derive(Debug, Clone, PartialEq, Eq, Hash, McBufReadable, McBufWritable)] -pub struct BitSet { - data: Vec, -} - -// the Index trait requires us to return a reference, but we can't do that -impl BitSet { - pub fn index(&self, index: usize) -> bool { - (self.data[index / 64] & (1u64 << (index % 64))) != 0 - } -} - #[cfg(test)] mod tests { use super::*; -- cgit v1.2.3