aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xazalea-protocol/packet-macros/src/lib.rs2
-rwxr-xr-xazalea-protocol/src/mc_buf/mod.rs18
-rw-r--r--azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs21
-rw-r--r--azalea-protocol/src/packets/game/clientbound_light_update_packet.rs13
4 files changed, 48 insertions, 6 deletions
diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs
index 089d1594..aca7df8c 100755
--- a/azalea-protocol/packet-macros/src/lib.rs
+++ b/azalea-protocol/packet-macros/src/lib.rs
@@ -54,7 +54,7 @@ pub fn derive_mcbufreadable(input: TokenStream) -> TokenStream {
impl crate::mc_buf::McBufReadable for #ident {
async fn read_into<R>(buf: &mut R) -> Result<Self, String>
where
- R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ R: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send,
{
#(#read_fields)*
Ok(#ident {
diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs
index 3ab6e761..b69e94c4 100755
--- a/azalea-protocol/src/mc_buf/mod.rs
+++ b/azalea-protocol/src/mc_buf/mod.rs
@@ -4,13 +4,15 @@ mod read;
mod write;
pub use read::{McBufReadable, McBufVarintReadable, Readable};
-use std::ops::Deref;
+use std::ops::{Deref, Index};
pub use write::{McBufVarintWritable, McBufWritable, Writable};
// const DEFAULT_NBT_QUOTA: u32 = 2097152;
const MAX_STRING_LENGTH: u16 = 32767;
// const MAX_COMPONENT_STRING_LENGTH: u32 = 262144;
+// TODO: have a definitions.rs in mc_buf that contains UnsizedByteArray and BitSet
+
/// A Vec<u8> that isn't prefixed by a VarInt with the size.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UnsizedByteArray(Vec<u8>);
@@ -29,6 +31,20 @@ impl From<Vec<u8>> for UnsizedByteArray {
}
}
+/** Represents Java's BitSet, a list of bits. */
+pub struct BitSet {
+ data: Vec<u64>,
+}
+
+impl Index<usize> for BitSet {
+ type Output = bool;
+
+ fn index(&self, index: usize) -> &Self::Output {
+ let result = (self.data[index / 64] & (1u64 << (index % 64))) != 0;
+ &result
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
index b90e8ff1..0dcb0ff2 100644
--- a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
@@ -1,5 +1,6 @@
-use azalea_core::{game_type::GameType, resource_location::ResourceLocation};
-use packet_macros::GamePacket;
+use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+
+use super::clientbound_light_update_packet::ClientboundLightUpdatePacketData;
#[derive(Clone, Debug, GamePacket)]
pub struct ClientboundLevelChunkWithLightPacket {
@@ -9,4 +10,18 @@ pub struct ClientboundLevelChunkWithLightPacket {
pub light_data: ClientboundLightUpdatePacketData,
}
-pub struct ClientboundLevelChunkPacketData {}
+#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+pub struct ClientboundLevelChunkPacketData {
+ heightmaps: azalea_nbt::Tag,
+ data: Vec<u8>,
+ block_entities: BlockEntity,
+}
+
+#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+pub struct BlockEntity {
+ packed_xz: u8,
+ y: u16,
+ #[varint]
+ type_: i32,
+ data: azalea_nbt::Tag,
+}
diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
index 43d530e0..8e53e12e 100644
--- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
@@ -1,3 +1,4 @@
+use crate::mc_buf::BitSet;
use azalea_core::{game_type::GameType, resource_location::ResourceLocation};
use packet_macros::GamePacket;
@@ -8,4 +9,14 @@ pub struct ClientboundLightUpdatePacket {
pub light_data: ClientboundLightUpdatePacketData,
}
-pub struct ClientboundLightUpdatePacketData {}
+#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+pub struct ClientboundLightUpdatePacketData {
+ trust_edges: bool,
+ sky_y_mask: BitSet,
+ block_y_mask: BitSet,
+ empty_sky_y_mask: BitSet,
+ empty_block_y_mask: BitSet,
+ sky_updates: Vec<>,
+ block_updates: BitSet,
+
+}