diff options
| author | mat <github@matdoes.dev> | 2022-05-14 19:14:34 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-05-14 19:14:34 -0500 |
| commit | 42f86f73f256c0219a923c5ff67a509e7a8a898d (patch) | |
| tree | da9db6effc1503c003b3d08175a35ed3bfb546b7 /azalea-protocol/src/mc_buf | |
| parent | 8fb95866093245bd802bebec08148c87f1188db3 (diff) | |
| download | azalea-drasl-42f86f73f256c0219a923c5ff67a509e7a8a898d.tar.xz | |
add unhandled ClientboundSectionBlocksUpdatePacket
Diffstat (limited to 'azalea-protocol/src/mc_buf')
| -rw-r--r-- | azalea-protocol/src/mc_buf/read.rs | 14 | ||||
| -rw-r--r-- | azalea-protocol/src/mc_buf/write.rs | 13 |
2 files changed, 25 insertions, 2 deletions
diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index ebafad92..1c4fbd6f 100644 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -2,7 +2,7 @@ use super::{UnsizedByteArray, MAX_STRING_LENGTH}; use azalea_chat::component::Component; use azalea_core::{ difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation, - serializable_uuid::SerializableUuid, BlockPos, Direction, Slot, SlotData, + serializable_uuid::SerializableUuid, BlockPos, ChunkSectionPos, Direction, Slot, SlotData, }; use byteorder::{ReadBytesExt, BE}; use serde::Deserialize; @@ -518,3 +518,15 @@ impl McBufReadable for Direction { } } } + +// ChunkSectionPos +impl McBufReadable for ChunkSectionPos { + fn read_into(buf: &mut impl Read) -> Result<Self, String> { + let long = i64::read_into(buf)?; + Ok(ChunkSectionPos { + x: (long >> 42) as i32, + y: (long << 44 >> 44) as i32, + z: (long << 22 >> 42) as i32, + }) + } +} diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs index 7fe61752..c46297a6 100644 --- a/azalea-protocol/src/mc_buf/write.rs +++ b/azalea-protocol/src/mc_buf/write.rs @@ -2,7 +2,7 @@ use super::{UnsizedByteArray, MAX_STRING_LENGTH}; use azalea_chat::component::Component; use azalea_core::{ difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation, - serializable_uuid::SerializableUuid, BlockPos, Direction, Slot, + serializable_uuid::SerializableUuid, BlockPos, ChunkSectionPos, Direction, Slot, }; use byteorder::{BigEndian, WriteBytesExt}; use std::{collections::HashMap, io::Write}; @@ -425,3 +425,14 @@ impl McBufWritable for Direction { buf.write_varint(*self as i32) } } + +// ChunkSectionPos +impl McBufWritable for ChunkSectionPos { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + let long = (((self.x & 0x3FFFFF) as i64) << 42) + | (self.y & 0xFFFFF) as i64 + | (((self.z & 0x3FFFFF) as i64) << 20); + long.write_into(buf)?; + Ok(()) + } +} |
