diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-05-15 01:46:11 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-15 01:46:11 +0000 |
| commit | d0ac62d85276bc48e4f8e0e60afdc35840681622 (patch) | |
| tree | ff4996b89d6f34c7c452d1b2950e53d512bce3c1 /azalea-protocol/src/packets | |
| parent | ef3cbe27f2a7eed5c635924d6fa0401dd04eae77 (diff) | |
| parent | c16e958d0be671a17edf060aee9850faccbcfe14 (diff) | |
| download | azalea-drasl-d0ac62d85276bc48e4f8e0e60afdc35840681622.tar.xz | |
Merge pull request #6 from mat-1/chunk-decoding
Chunk decoding
Diffstat (limited to 'azalea-protocol/src/packets')
56 files changed, 285 insertions, 168 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs index 55fbd2e1..9afd151b 100644 --- a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundAddEntityPacket { #[var] pub id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_add_mob_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_mob_packet.rs index ab72eb59..bc0ddcef 100644 --- a/azalea-protocol/src/packets/game/clientbound_add_mob_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_add_mob_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundAddMobPacket { #[var] pub id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs index 8f848c99..f1947d09 100644 --- a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundAddPlayerPacket { #[var] pub id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs index 84a20381..0bba1a25 100644 --- a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundAnimatePacket { #[var] pub id: u32, @@ -9,7 +9,7 @@ pub struct ClientboundAnimatePacket { // minecraft actually uses a u8 for this, but a varint still works and makes it // so i don't have to add a special handler -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum AnimationAction { SwingMainHand = 0, Hurt = 1, diff --git a/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs index 575b7f46..f068cc7d 100644 --- a/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_block_update_packet.rs @@ -1,7 +1,7 @@ use azalea_core::BlockPos; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundBlockUpdatePacket { pub pos: BlockPos, // TODO: in vanilla this is a BlockState, but here we just have it as a number. diff --git a/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs b/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs index e12cfff3..edda52d9 100755 --- a/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_change_difficulty_packet.rs @@ -1,7 +1,7 @@ use azalea_core::difficulty::Difficulty; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundChangeDifficultyPacket { pub difficulty: Difficulty, pub locked: bool, diff --git a/azalea-protocol/src/packets/game/clientbound_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs index 3786993a..77c5370c 100644 --- a/azalea-protocol/src/packets/game/clientbound_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs @@ -1,15 +1,15 @@ use azalea_chat::component::Component; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundChatPacket { pub message: Component, pub type_: ChatType, pub sender: Uuid, } -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum ChatType { Chat = 0, System = 1, diff --git a/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs b/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs index aea09e09..d38bbfda 100644 --- a/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_container_set_content_packet.rs @@ -1,7 +1,7 @@ use azalea_core::Slot; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundContainerSetContentPacket { pub container_id: u8, #[var] diff --git a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs index 2c56ea2b..b9ccbba4 100755 --- a/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_custom_payload_packet.rs @@ -1,8 +1,8 @@ use crate::mc_buf::UnsizedByteArray; use azalea_core::resource_location::ResourceLocation; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundCustomPayloadPacket { pub identifier: ResourceLocation, pub data: UnsizedByteArray, diff --git a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs index 27f4fb16..6743c3af 100755 --- a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs @@ -281,7 +281,7 @@ impl McBufReadable for BrigadierParser { } } -// azalea_brigadier::tree::CommandNode +// TODO: BrigadierNodeStub should have more stuff impl McBufReadable for BrigadierNodeStub { fn read_into(buf: &mut impl Read) -> Result<Self, String> { let flags = u8::read_into(buf)?; @@ -292,20 +292,18 @@ impl McBufReadable for BrigadierNodeStub { } let node_type = flags & 0x03; - let is_executable = flags & 0x04 != 0; + let _is_executable = flags & 0x04 != 0; let has_redirect = flags & 0x08 != 0; let has_suggestions_type = flags & 0x10 != 0; - let children = buf.read_int_id_list()?; - let redirect_node = if has_redirect { buf.read_varint()? } else { 0 }; + let _children = buf.read_int_id_list()?; + let _redirect_node = if has_redirect { buf.read_varint()? } else { 0 }; // argument node if node_type == 2 { - let name = buf.read_utf()?; - - let parser = BrigadierParser::read_into(buf)?; - - let suggestions_type = if has_suggestions_type { + let _name = buf.read_utf()?; + let _parser = BrigadierParser::read_into(buf)?; + let _suggestions_type = if has_suggestions_type { Some(buf.read_resource_location()?) } else { None @@ -314,7 +312,7 @@ impl McBufReadable for BrigadierNodeStub { } // literal node if node_type == 1 { - let name = buf.read_utf()?; + let _name = buf.read_utf()?; return Ok(BrigadierNodeStub {}); } Ok(BrigadierNodeStub {}) diff --git a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs index 2e72b19b..c030d512 100644 --- a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs @@ -1,7 +1,7 @@ use azalea_chat::component::Component; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundDisconnectPacket { pub reason: Component, } diff --git a/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs index 55e4d419..1b06bff7 100644 --- a/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_entity_event_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; // we can't identify the status in azalea-protocol since they vary depending on the entity -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundEntityEventPacket { pub entity_id: i32, pub entity_status: i8, diff --git a/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs b/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs index 4fc8f86f..07218c4e 100644 --- a/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_entity_velocity_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundEntityVelocityPacket { #[var] pub entity_id: u32, diff --git a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs new file mode 100644 index 00000000..dd5f08f6 --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs @@ -0,0 +1,23 @@ +use packet_macros::{GamePacket, McBuf}; + +#[derive(Clone, Debug, McBuf, GamePacket)] +pub struct ClientboundGameEventPacket { + pub event: EventType, + pub param: f32, +} + +#[derive(Clone, Debug, Copy, McBuf)] +pub enum EventType { + NoRespawnBlockAvailable = 0, + StartRaining = 1, + StopRaining = 2, + ChangeGameMode = 3, + WinGame = 4, + DemoEvent = 5, + ArrowHitPlayer = 6, + RainLevelChange = 7, + ThunderLevelChange = 8, + PufferFishSting = 9, + GuardianElderEffect = 10, + ImmediateRespawn = 11, +} diff --git a/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs b/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs index 435e43cc..a522eba3 100644 --- a/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_initialize_border_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundInitializeBorderPacket { pub new_center_x: f64, pub new_center_z: f64, diff --git a/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs b/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs index d5dab9a9..18628c86 100644 --- a/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_keep_alive_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundKeepAlivePacket { pub id: u64, } 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 22eedb05..43bda0b6 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,8 +1,8 @@ -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use super::clientbound_light_update_packet::ClientboundLightUpdatePacketData; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundLevelChunkWithLightPacket { pub x: i32, pub z: i32, @@ -10,25 +10,19 @@ pub struct ClientboundLevelChunkWithLightPacket { pub light_data: ClientboundLightUpdatePacketData, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct ClientboundLevelChunkPacketData { - heightmaps: azalea_nbt::Tag, + pub heightmaps: azalea_nbt::Tag, // we can't parse the data in azalea-protocol because it dependso on context from other packets - data: Vec<u8>, - block_entities: Vec<BlockEntity>, + pub data: Vec<u8>, + pub block_entities: Vec<BlockEntity>, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct BlockEntity { - packed_xz: u8, - y: u16, + pub packed_xz: u8, + pub y: u16, #[var] - type_: i32, - data: azalea_nbt::Tag, -} - -pub struct ChunkSection {} - -impl ClientboundLevelChunkPacketData { - pub fn read(world_height: u32) {} + pub type_: i32, + pub data: azalea_nbt::Tag, } diff --git a/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs index b8572a85..70926268 100644 --- a/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_level_event_packet.rs @@ -1,7 +1,7 @@ use azalea_core::BlockPos; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundLevelEventPacket { pub type_: i32, pub pos: BlockPos, diff --git a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs new file mode 100644 index 00000000..a3538598 --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs @@ -0,0 +1,56 @@ +use std::io::{Read, Write}; + +use crate::mc_buf::{McBufReadable, McBufWritable, ParticleData}; +use packet_macros::GamePacket; + +#[derive(Clone, Debug, GamePacket)] +pub struct ClientboundLevelParticlesPacket { + pub particle_id: u32, + pub override_limiter: bool, + pub x: f64, + pub y: f64, + pub z: f64, + pub x_dist: f32, + pub y_dist: f32, + pub z_dist: f32, + pub max_speed: f32, + pub count: i32, + pub data: ParticleData, +} + +impl McBufReadable for ClientboundLevelParticlesPacket { + fn read_into(buf: &mut impl Read) -> Result<Self, String> { + let particle_id = u32::read_into(buf)?; + let override_limiter = bool::read_into(buf)?; + let x = f64::read_into(buf)?; + let y = f64::read_into(buf)?; + let z = f64::read_into(buf)?; + let x_dist = f32::read_into(buf)?; + let y_dist = f32::read_into(buf)?; + let z_dist = f32::read_into(buf)?; + let max_speed = f32::read_into(buf)?; + let count = i32::read_into(buf)?; + + let data = ParticleData::read_from_particle_id(buf, particle_id)?; + + Ok(Self { + particle_id, + override_limiter, + x, + y, + z, + x_dist, + y_dist, + z_dist, + max_speed, + count, + data, + }) + } +} + +impl McBufWritable for ClientboundLevelParticlesPacket { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + todo!(); + } +} 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 c97eacff..f04987ac 100644 --- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs @@ -1,15 +1,14 @@ use crate::mc_buf::BitSet; -use azalea_core::{game_type::GameType, resource_location::ResourceLocation}; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundLightUpdatePacket { pub x: i32, pub z: i32, pub light_data: ClientboundLightUpdatePacketData, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct ClientboundLightUpdatePacketData { trust_edges: bool, sky_y_mask: BitSet, diff --git a/azalea-protocol/src/packets/game/clientbound_login_packet.rs b/azalea-protocol/src/packets/game/clientbound_login_packet.rs index 9c8b7df1..b4a1b8d4 100755 --- a/azalea-protocol/src/packets/game/clientbound_login_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_login_packet.rs @@ -1,7 +1,7 @@ use azalea_core::{game_type::GameType, resource_location::ResourceLocation}; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundLoginPacket { pub player_id: u32, pub hardcore: bool, diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs index c9aff7cb..0fc0104a 100644 --- a/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_move_entity_pos_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundMoveEntityPosPacket { #[var] pub entity_id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs index 645912e7..5fde1b93 100644 --- a/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_move_entity_posrot_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundMoveEntityPosRotPacket { #[var] pub entity_id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs b/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs index 6ce0faa9..c8d0170b 100644 --- a/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_move_entity_rot_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundMoveEntityRotPacket { #[var] pub entity_id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs index cd645fe6..c3387f7f 100755 --- a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs @@ -1,8 +1,8 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable}; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundPlayerAbilitiesPacket { pub flags: PlayerAbilitiesFlags, pub flying_speed: f32, @@ -34,16 +34,16 @@ impl McBufWritable for PlayerAbilitiesFlags { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { let mut byte = 0; if self.invulnerable { - byte = byte | 1; + byte |= 0b1; } if self.flying { - byte = byte | 2; + byte |= 0b10; } if self.can_fly { - byte = byte | 4; + byte |= 0b100; } if self.instant_break { - byte = byte | 8; + byte |= 0b1000; } u8::write_into(&byte, buf) } diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs index 8e7ce4fd..cb17f1f5 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs @@ -1,10 +1,10 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; use azalea_chat::component::Component; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundPlayerInfoPacket { pub action: Action, } @@ -18,14 +18,14 @@ pub enum Action { RemovePlayer(Vec<RemovePlayer>), } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct PlayerProperty { name: String, value: String, signature: Option<String>, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct AddPlayer { uuid: Uuid, name: String, @@ -37,26 +37,26 @@ pub struct AddPlayer { display_name: Option<Component>, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct UpdateGameMode { uuid: Uuid, #[var] gamemode: u32, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct UpdateLatency { uuid: Uuid, #[var] ping: i32, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct UpdateDisplayName { uuid: Uuid, display_name: Option<Component>, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct RemovePlayer { uuid: Uuid, } diff --git a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs index 86266e9f..0457269a 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs @@ -1,8 +1,8 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable}; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundPlayerPositionPacket { pub x: f64, pub y: f64, @@ -43,19 +43,19 @@ impl McBufWritable for RelativeArguments { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { let mut byte = 0; if self.x { - byte = byte | 0b1; + byte |= 0b1; } if self.y { - byte = byte | 0b10; + byte |= 0b10; } if self.z { - byte = byte | 0b100; + byte |= 0b100; } if self.y_rot { - byte = byte | 0b1000; + byte |= 0b1000; } if self.x_rot { - byte = byte | 0b10000; + byte |= 0b10000; } u8::write_into(&byte, buf) } diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs index 543fb64c..e76504cc 100644 --- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs @@ -1,9 +1,9 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; -use azalea_core::{resource_location::ResourceLocation, Slot}; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use azalea_core::resource_location::ResourceLocation; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundRecipePacket { pub action: State, pub settings: RecipeBookSettings, @@ -11,7 +11,7 @@ pub struct ClientboundRecipePacket { pub to_highlight: Vec<ResourceLocation>, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct RecipeBookSettings { pub gui_open: bool, pub filtering_craftable: bool, @@ -41,7 +41,7 @@ impl McBufWritable for State { } impl McBufReadable for State { fn read_into(buf: &mut impl Read) -> Result<Self, String> { - let state = buf.read_varint()?.try_into().unwrap(); + let state = buf.read_varint()?; Ok(match state { 0 => State::Init, 1 => State::Add, diff --git a/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs b/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs index 265d0c64..8f51596d 100644 --- a/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_remove_entities_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundRemoveEntitiesPacket { #[var] pub entity_ids: Vec<u32>, diff --git a/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs b/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs index d423885d..71b485ae 100644 --- a/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_rotate_head_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundRotateHeadPacket { #[var] pub entity_id: u32, 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..6c429edb --- /dev/null +++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs @@ -0,0 +1,43 @@ +use crate::mc_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; +use azalea_core::{ChunkSectionBlockPos, ChunkSectionPos}; +use packet_macros::{GamePacket, McBuf}; +use std::io::{Read, Write}; + +#[derive(Clone, Debug, McBuf, GamePacket)] +pub struct ClientboundSectionBlocksUpdatePacket { + pub section_pos: ChunkSectionPos, + pub suppress_light_updates: bool, + pub states: Vec<BlockStateWithPosition>, +} + +#[derive(Clone, Debug)] +pub struct BlockStateWithPosition { + pub pos: ChunkSectionBlockPos, + pub state: u32, +} + +impl McBufReadable for BlockStateWithPosition { + fn read_into(buf: &mut impl Read) -> Result<Self, String> { + let data = u64::var_read_into(buf)?; + let position_part = data & 4095; + let state = (data >> 12) as u32; + let position = ChunkSectionBlockPos { + x: (position_part >> 8 & 15) as u8, + y: (position_part >> 0 & 15) as u8, + z: (position_part >> 4 & 15) as u8, + }; + Ok(BlockStateWithPosition { + pos: position, + state: state, + }) + } +} + +impl McBufWritable for BlockStateWithPosition { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + let data = (self.state as u64) << 12 + | ((self.pos.x as u64) << 8 | (self.pos.z as u64) << 4 | (self.pos.y as u64)); + u64::var_write_into(&data, buf)?; + Ok(()) + } +} diff --git a/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs index 4f0bf575..003b6ccc 100755 --- a/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_carried_item_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; /// Sent to change the player's slot selection. -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetCarriedItemPacket { pub slot: u8, } diff --git a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs index f4d59e32..7557c16b 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_chunk_cache_center.rs @@ -1,9 +1,9 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetChunkCacheCenterPacket { #[var] pub x: i32, #[var] - pub y: i32, + pub z: i32, } diff --git a/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs index dad050cc..7ac42c5c 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_default_spawn_position_packet.rs @@ -1,7 +1,7 @@ use azalea_core::BlockPos; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetDefaultSpawnPositionPacket { pub pos: BlockPos, pub angle: f32, diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs index 752b7e6a..8a568689 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs @@ -1,7 +1,7 @@ use crate::mc_buf::EntityMetadata; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetEntityDataPacket { #[var] pub id: i32, diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs index 7ee4a43c..e6e3af67 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_entity_link_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetEntityLinkPacket { pub source_id: u32, pub dest_id: u32, diff --git a/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs index 88c306dc..bcb6393d 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_experience_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetExperiencePacket { pub experience_progress: f32, #[var] diff --git a/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs index 136ef475..6c75cf63 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_health_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetHealthPacket { pub health: f32, #[var] diff --git a/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs index 02bf88d7..4cad0693 100644 --- a/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_set_time_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSetTimePacket { pub game_time: u64, pub day_time: u64, diff --git a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs index 67e832fe..797f03de 100644 --- a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundSoundPacket { #[var] /// TODO: use the sound registry instead of just being a u32 @@ -13,7 +13,7 @@ pub struct ClientboundSoundPacket { pub pitch: f32, } -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum SoundSource { Master = 0, Music = 1, diff --git a/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs index ea8788d6..c10db7b9 100644 --- a/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundTeleportEntityPacket { #[var] pub id: u32, diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs index fe2c226d..daa1ac93 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs @@ -1,13 +1,13 @@ use crate::packets::{McBufReadable, McBufWritable}; use azalea_chat::component::Component; use azalea_core::{resource_location::ResourceLocation, Slot}; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use std::{ collections::HashMap, io::{Read, Write}, }; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateAdvancementsPacket { pub reset: bool, pub added: HashMap<ResourceLocation, Advancement>, @@ -15,7 +15,7 @@ pub struct ClientboundUpdateAdvancementsPacket { pub progress: HashMap<ResourceLocation, AdvancementProgress>, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct Advancement { parent_id: Option<ResourceLocation>, display: Option<DisplayInfo>, @@ -25,7 +25,7 @@ pub struct Advancement { // requirements_strategy: RequirementsStrategy.AND } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct DisplayInfo { pub title: Component, pub description: Component, @@ -71,7 +71,7 @@ impl McBufWritable for DisplayFlags { } } -#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, Copy, McBuf)] pub enum FrameType { Task = 0, Challenge = 1, @@ -79,12 +79,12 @@ pub enum FrameType { } // nothing is written here -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct Criterion {} pub type AdvancementProgress = HashMap<ResourceLocation, CriterionProgress>; -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct CriterionProgress { date: Option<u64>, } diff --git a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs index 3d83e6fb..d0e7c9ee 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs @@ -1,24 +1,24 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; use azalea_core::resource_location::ResourceLocation; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use std::io::{Read, Write}; use uuid::Uuid; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateAttributesPacket { #[var] pub entity_id: u32, pub attributes: Vec<AttributeSnapshot>, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct AttributeSnapshot { pub attribute: ResourceLocation, pub base: f64, pub modifiers: Vec<Modifier>, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct Modifier { pub uuid: Uuid, pub amount: f64, diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs index 1c87a472..27839919 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs @@ -1,11 +1,11 @@ use std::io::{Read, Write}; use azalea_core::{resource_location::ResourceLocation, Slot}; -use packet_macros::{GamePacket, McBufReadable, McBufWritable}; +use packet_macros::{GamePacket, McBuf}; use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateRecipesPacket { pub recipes: Vec<Recipe>, } @@ -16,7 +16,7 @@ pub struct Recipe { pub data: RecipeData, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct ShapelessRecipe { /// Used to group similar recipes together in the recipe book. /// Tag is present in recipe JSON @@ -68,7 +68,7 @@ impl McBufReadable for ShapedRecipe { } } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct CookingRecipe { group: String, ingredient: Ingredient, @@ -77,13 +77,13 @@ pub struct CookingRecipe { #[var] cooking_time: u32, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct StoneCuttingRecipe { group: String, ingredient: Ingredient, result: Slot, } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct SmithingRecipe { base: Ingredient, addition: Ingredient, @@ -116,13 +116,13 @@ pub enum RecipeData { Smithing(SmithingRecipe), } -#[derive(Clone, Debug, McBufReadable, McBufWritable)] +#[derive(Clone, Debug, McBuf)] pub struct Ingredient { pub allowed: Vec<Slot>, } impl McBufWritable for Recipe { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> { todo!() } } diff --git a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs index f82a4177..60794f03 100755 --- a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs @@ -1,12 +1,12 @@ use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; use azalea_core::resource_location::ResourceLocation; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; use std::{ collections::HashMap, io::{Read, Write}, }; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateTagsPacket { pub tags: HashMap<ResourceLocation, Vec<Tags>>, } diff --git a/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs index fe65d048..8288bd73 100755 --- a/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_view_distance_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ClientboundUpdateViewDistancePacket { #[var] pub view_distance: i32, diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index 0391ee10..883e03aa 100755 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -11,10 +11,12 @@ pub mod clientbound_declare_commands_packet; pub mod clientbound_disconnect_packet; pub mod clientbound_entity_event_packet; pub mod clientbound_entity_velocity_packet; +pub mod clientbound_game_event_packet; pub mod clientbound_initialize_border_packet; pub mod clientbound_keep_alive_packet; pub mod clientbound_level_chunk_with_light_packet; pub mod clientbound_level_event_packet; +pub mod clientbound_level_particles_packet; pub mod clientbound_light_update_packet; pub mod clientbound_login_packet; pub mod clientbound_move_entity_pos_packet; @@ -26,6 +28,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; @@ -56,19 +59,21 @@ declare_state_packets!( 0x00: clientbound_add_entity_packet::ClientboundAddEntityPacket, 0x02: clientbound_add_mob_packet::ClientboundAddMobPacket, 0x04: clientbound_add_player_packet::ClientboundAddPlayerPacket, - 0x6: clientbound_animate_packet::ClientboundAnimatePacket, - 0xc: clientbound_block_update_packet::ClientboundBlockUpdatePacket, + 0x06: clientbound_animate_packet::ClientboundAnimatePacket, + 0x0c: clientbound_block_update_packet::ClientboundBlockUpdatePacket, 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket, - 0xf: clientbound_chat_packet::ClientboundChatPacket, + 0x0f: clientbound_chat_packet::ClientboundChatPacket, 0x12: clientbound_declare_commands_packet::ClientboundDeclareCommandsPacket, 0x14: clientbound_container_set_content_packet::ClientboundContainerSetContentPacket, 0x1a: clientbound_disconnect_packet::ClientboundDisconnectPacket, 0x1b: clientbound_entity_event_packet::ClientboundEntityEventPacket, 0x18: clientbound_custom_payload_packet::ClientboundCustomPayloadPacket, + 0x1e: clientbound_game_event_packet::ClientboundGameEventPacket, 0x20: clientbound_initialize_border_packet::ClientboundInitializeBorderPacket, 0x21: clientbound_keep_alive_packet::ClientboundKeepAlivePacket, 0x22: clientbound_level_chunk_with_light_packet::ClientboundLevelChunkWithLightPacket, 0x23: clientbound_level_event_packet::ClientboundLevelEventPacket, + 0x24: clientbound_level_particles_packet::ClientboundLevelParticlesPacket, 0x25: clientbound_light_update_packet::ClientboundLightUpdatePacket, 0x26: clientbound_login_packet::ClientboundLoginPacket, 0x29: clientbound_move_entity_pos_packet::ClientboundMoveEntityPosPacket, @@ -80,6 +85,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/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs b/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs index eefafdd1..bef25b59 100644 --- a/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_custom_payload_packet.rs @@ -1,8 +1,8 @@ use crate::mc_buf::UnsizedByteArray; use azalea_core::resource_location::ResourceLocation; -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ServerboundCustomPayloadPacket { pub identifier: ResourceLocation, pub data: UnsizedByteArray, diff --git a/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs b/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs index 740b18e3..c430499e 100644 --- a/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs +++ b/azalea-protocol/src/packets/game/serverbound_keep_alive_packet.rs @@ -1,6 +1,6 @@ -use packet_macros::GamePacket; +use packet_macros::{GamePacket, McBuf}; -#[derive(Clone, Debug, GamePacket)] +#[derive(Clone, Debug, McBuf, GamePacket)] pub struct ServerboundKeepAlivePacket { pub id: u64, } diff --git a/azalea-protocol/src/packets/handshake/client_intention_packet.rs b/azalea-protocol/src/packets/handshake/client_intention_packet.rs index 98caf34c..410c11ab 100755 --- a/azalea-protocol/src/packets/handshake/client_intention_packet.rs +++ b/azalea-protocol/src/packets/handshake/client_intention_packet.rs @@ -1,8 +1,8 @@ use crate::packets::ConnectionProtocol; -use packet_macros::HandshakePacket; +use packet_macros::{HandshakePacket, McBuf}; use std::hash::Hash; -#[derive(Hash, Clone, Debug, HandshakePacket)] +#[derive(Hash, Clone, Debug, McBuf, HandshakePacket)] pub struct ClientIntentionPacket { #[var] pub protocol_version: u32, diff --git a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs index fc5dd1a2..1b1da87a 100755 --- a/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_custom_query_packet.rs @@ -1,9 +1,9 @@ use crate::mc_buf::UnsizedByteArray; use azalea_core::resource_location::ResourceLocation; -use packet_macros::LoginPacket; +use packet_macros::{LoginPacket, McBuf}; use std::hash::Hash; -#[derive(Hash, Clone, Debug, LoginPacket)] +#[derive(Hash, Clone, Debug, McBuf, LoginPacket)] pub struct ClientboundCustomQueryPacket { #[var] pub transaction_id: u32, diff --git a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs index 28d91c79..9ab09e3b 100644 --- a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs +++ b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs @@ -1,7 +1,7 @@ use azalea_chat::component::Component; -use packet_macros::LoginPacket; +use packet_macros::{LoginPacket, McBuf}; -#[derive(Clone, Debug, LoginPacket)] +#[derive(Clone, Debug, McBuf, LoginPacket)] pub struct ClientboundLoginDisconnectPacket { pub reason: Component, } diff --git a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs index eb6a4065..5cb660ed 100755 --- a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs +++ b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs @@ -1,7 +1,7 @@ -use packet_macros::LoginPacket; +use packet_macros::{LoginPacket, McBuf}; use std::hash::Hash; -#[derive(Hash, Clone, Debug, LoginPacket)] +#[derive(Hash, Clone, Debug, McBuf, LoginPacket)] pub struct ServerboundHelloPacket { pub username: String, } diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs index f402d357..9100823d 100644 --- a/azalea-protocol/src/packets/login/serverbound_key_packet.rs +++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs @@ -1,9 +1,7 @@ -use super::LoginPacket; -use crate::mc_buf::Writable; -use packet_macros::LoginPacket; +use packet_macros::{LoginPacket, McBuf}; use std::hash::Hash; -#[derive(Hash, Clone, Debug, LoginPacket)] +#[derive(Hash, Clone, Debug, McBuf, LoginPacket)] pub struct ServerboundKeyPacket { pub shared_secret: Vec<u8>, pub nonce: Vec<u8>, diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index a706646d..16e97068 100755 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -43,7 +43,7 @@ where fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error>; } -impl McBufReadable for ConnectionProtocol { +impl crate::mc_buf::McBufReadable for ConnectionProtocol { fn read_into(buf: &mut impl Read) -> Result<Self, String> { ConnectionProtocol::from_i32(buf.read_varint()?) .ok_or_else(|| "Invalid intention".to_string()) diff --git a/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs b/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs index c15673d9..3369e6a9 100755 --- a/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs +++ b/azalea-protocol/src/packets/status/serverbound_status_request_packet.rs @@ -1,4 +1,4 @@ -use packet_macros::StatusPacket; +use packet_macros::{McBuf, StatusPacket}; -#[derive(Clone, Debug, StatusPacket)] +#[derive(Clone, Debug, McBuf, StatusPacket)] pub struct ServerboundStatusRequestPacket {} |
