aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xazalea-client/src/connect.rs3
-rw-r--r--azalea-protocol/src/mc_buf/read.rs14
-rw-r--r--azalea-protocol/src/mc_buf/write.rs13
-rw-r--r--azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs10
-rwxr-xr-xazalea-protocol/src/packets/game/mod.rs2
-rw-r--r--bot/src/main.rs4
6 files changed, 42 insertions, 4 deletions
diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs
index 8d2e9dc1..48fd16f2 100755
--- a/azalea-client/src/connect.rs
+++ b/azalea-client/src/connect.rs
@@ -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),
}
}
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(())
+ }
+}
diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
new file mode 100644
index 00000000..f220b07f
--- /dev/null
+++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
@@ -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>,
+}
diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs
index 0391ee10..66c55cd2 100755
--- a/azalea-protocol/src/packets/game/mod.rs
+++ b/azalea-protocol/src/packets/game/mod.rs
@@ -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,
diff --git a/bot/src/main.rs b/bot/src/main.rs
index 1f2cb6e1..76a5a15d 100644
--- a/bot/src/main.rs
+++ b/bot/src/main.rs
@@ -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();