add unhandled ClientboundSectionBlocksUpdatePacket

This commit is contained in:
mat 2022-05-14 19:14:34 -05:00
parent 8fb9586609
commit 42f86f73f2
6 changed files with 42 additions and 4 deletions

View file

@ -373,6 +373,9 @@ impl Client {
GamePacket::ClientboundAnimatePacket(p) => {
println!("Got animate packet {:?}", p);
}
GamePacket::ClientboundSectionBlocksUpdatePacket(p) => {
println!("Got section blocks update packet {:?}", p);
}
_ => panic!("Unexpected packet {:?}", packet),
}
}

View file

@ -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,
})
}
}

View file

@ -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(())
}
}

View file

@ -0,0 +1,10 @@
use azalea_core::ChunkSectionPos;
use packet_macros::GamePacket;
#[derive(Clone, Debug, GamePacket)]
pub struct ClientboundSectionBlocksUpdatePacket {
pub section_pos: ChunkSectionPos,
pub suppress_light_updates: bool,
#[var]
pub states: Vec<u64>,
}

View file

@ -26,6 +26,7 @@ pub mod clientbound_player_position_packet;
pub mod clientbound_recipe_packet;
pub mod clientbound_remove_entities_packet;
pub mod clientbound_rotate_head_packet;
pub mod clientbound_section_blocks_update_packet;
pub mod clientbound_set_carried_item_packet;
pub mod clientbound_set_chunk_cache_center;
pub mod clientbound_set_default_spawn_position_packet;
@ -80,6 +81,7 @@ declare_state_packets!(
0x39: clientbound_recipe_packet::ClientboundRecipePacket,
0x3a: clientbound_remove_entities_packet::ClientboundRemoveEntitiesPacket,
0x3e: clientbound_rotate_head_packet::ClientboundRotateHeadPacket,
0x3f: clientbound_section_blocks_update_packet::ClientboundSectionBlocksUpdatePacket,
0x48: clientbound_set_carried_item_packet::ClientboundSetCarriedItemPacket,
0x49: clientbound_set_chunk_cache_center::ClientboundSetChunkCacheCenterPacket,
0x4a: clientbound_update_view_distance_packet::ClientboundUpdateViewDistancePacket,

View file

@ -1,12 +1,12 @@
use azalea_client::{Account, Event};
use azalea_core::{BlockPos, ChunkPos};
use azalea_core::BlockPos;
#[tokio::main]
async fn main() {
println!("Hello, world!");
// let address = "95.111.249.143:10000";
let address = "192.168.2.234:62840";
let address = "192.168.2.234:50736";
// let response = azalea_client::ping::ping_server(&address.try_into().unwrap())
// .await
// .unwrap();