From 29ad65320ceafb299a35210d62ec8991344362d3 Mon Sep 17 00:00:00 2001 From: Freddie <69014593+FrederoxDev@users.noreply.github.com> Date: Thu, 1 Aug 2024 23:14:24 +0100 Subject: [PATCH 1/3] push to pull up --- proto/src/packets/level_chunk.rs | 2 +- proto/src/types/chunk_pos.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/proto/src/packets/level_chunk.rs b/proto/src/packets/level_chunk.rs index a4498d57..22f4472c 100644 --- a/proto/src/packets/level_chunk.rs +++ b/proto/src/packets/level_chunk.rs @@ -6,7 +6,7 @@ use bedrockrs_proto_core::ProtoCodec; pub struct LevelChunkPacket { pub chunk_position: ChunkPos, pub dimension_id: VAR, - pub sub_chunk_count: VAR, + pub sub_chunk_count: VAR, pub cache_enabled: bool, pub serialized_chunk_data: Vec, diff --git a/proto/src/types/chunk_pos.rs b/proto/src/types/chunk_pos.rs index a227bc3b..b4f5bce0 100644 --- a/proto/src/types/chunk_pos.rs +++ b/proto/src/types/chunk_pos.rs @@ -10,8 +10,8 @@ pub struct ChunkPos { impl ChunkPos { pub fn new(x: i32, z: i32) -> Self { ChunkPos { - x: VAR::new(x), - z: VAR::new(z) + x: VAR::::new(x), + z: VAR::::new(z) } } } \ No newline at end of file From faebbe123a11f3312e1bc2cb7273436927c1cb4c Mon Sep 17 00:00:00 2001 From: Freddie <69014593+FrederoxDev@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:39:34 +0100 Subject: [PATCH 2/3] add PlayerActionPacket --- proto/src/gamepacket.rs | 9 +++++---- proto/src/packets/level_chunk.rs | 1 + proto/src/packets/mod.rs | 1 + proto/src/packets/player_action.rs | 13 +++++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 proto/src/packets/player_action.rs diff --git a/proto/src/gamepacket.rs b/proto/src/gamepacket.rs index 77e13bfb..6b774415 100644 --- a/proto/src/gamepacket.rs +++ b/proto/src/gamepacket.rs @@ -19,6 +19,7 @@ use crate::packets::network_settings::NetworkSettingsPacket; use crate::packets::network_settings_request::NetworkSettingsRequestPacket; use crate::packets::packet_violation_warning::PacketViolationWarningPacket; use crate::packets::play_status::PlayStatusPacket; +use crate::packets::player_action::PlayerActionPacket; use crate::packets::player_auth_input::PlayerAuthInputPacket; use crate::packets::request_chunk_radius::RequestChunkRadiusPacket; use crate::packets::resource_packs_info::ResourcePacksInfoPacket; @@ -69,7 +70,7 @@ pub enum GamePacket { Interact(InteractPacket), BlockPickRequest(), EntityPickRequest(), - PlayerAction(), + PlayerAction(PlayerActionPacket), HurtArmor(), SetEntityData(), SetEntityMotion(), @@ -494,8 +495,8 @@ impl GamePacket { GamePacket::EntityPickRequest() => { unimplemented!() } - GamePacket::PlayerAction() => { - unimplemented!() + GamePacket::PlayerAction(pk) => { + ser_packet!(stream, GamePacket::PlayerActionID, pk) } GamePacket::HurtArmor() => { unimplemented!() @@ -974,7 +975,7 @@ impl GamePacket { unimplemented!() } GamePacket::PlayerActionID => { - unimplemented!() + GamePacket::PlayerAction(de_packet!(stream, PlayerActionPacket)) } GamePacket::HurtArmorID => { unimplemented!() diff --git a/proto/src/packets/level_chunk.rs b/proto/src/packets/level_chunk.rs index 22f4472c..a9e2faa3 100644 --- a/proto/src/packets/level_chunk.rs +++ b/proto/src/packets/level_chunk.rs @@ -38,6 +38,7 @@ impl ProtoCodec for LevelChunkPacket { unimplemented!() } + VAR::::new(self.serialized_chunk_data.len().try_into().unwrap()).proto_serialize(stream)?; stream.extend_from_slice(&self.serialized_chunk_data); return Ok(()); diff --git a/proto/src/packets/mod.rs b/proto/src/packets/mod.rs index 7de849bc..d72f0484 100644 --- a/proto/src/packets/mod.rs +++ b/proto/src/packets/mod.rs @@ -23,3 +23,4 @@ pub mod server_settings_response; pub mod model_form_request; pub mod model_form_response; pub mod text_message; +pub mod player_action; \ No newline at end of file diff --git a/proto/src/packets/player_action.rs b/proto/src/packets/player_action.rs new file mode 100644 index 00000000..60246830 --- /dev/null +++ b/proto/src/packets/player_action.rs @@ -0,0 +1,13 @@ +use bedrockrs_core::int::{VAR, LE}; +use bedrockrs_proto_derive::ProtoCodec; +use crate::types::network_block_pos::NetworkBlockPos; +use bedrockrs_shared::actor_runtime_id::ActorRuntimeID; + +#[derive(ProtoCodec, Debug, Clone)] +pub struct PlayerActionPacket { + pub player_runtime_id: ActorRuntimeID, + pub action: VAR, + pub block_pos: NetworkBlockPos, + pub result_pos: NetworkBlockPos, + pub face: VAR +} \ No newline at end of file From 3160ffb667d48423e0991b4e84f2f738ae36d80c Mon Sep 17 00:00:00 2001 From: Freddie <69014593+FrederoxDev@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:49:32 +0100 Subject: [PATCH 3/3] push b4 moving on --- proto/src/packets/player_action.rs | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/proto/src/packets/player_action.rs b/proto/src/packets/player_action.rs index 60246830..f5a45027 100644 --- a/proto/src/packets/player_action.rs +++ b/proto/src/packets/player_action.rs @@ -3,6 +3,48 @@ use bedrockrs_proto_derive::ProtoCodec; use crate::types::network_block_pos::NetworkBlockPos; use bedrockrs_shared::actor_runtime_id::ActorRuntimeID; +pub enum PlayerActionType { + Unknown = -1, + StartDestroyBlock = 0, + AbortDestroyBlock, + StopDestroyBlock, + GetUpdatedBlock, + DropItem, + StartSleeping, + StopSleeping, + Respawn, + StartJump, + StartSprinting, + StopSprinting, + StartSneaking, + StopSneaking, + CreativeDestroyBlock, + ChangeDimensionAck, + StartGliding, + StopGlibiding, + DenyDestroyBlock, + CrackBlock, + ChangeSkin, + DeprecatedUpdatedEnchantingSeed, + StartSwimming, + StopSwimming, + StartSpinAttack, + StopSpinAttack, + InteractWithBlock, + PredictDestroyBlock, + ContinueDestroyBlock, + StartItemUseOn, + StopItemUseOn, + HandledTeleport, + MissedSwing, + StartCrawling, + StopCrawling, + StartFlying, + StopFlying, + ClientAckServerData, + Count +} + #[derive(ProtoCodec, Debug, Clone)] pub struct PlayerActionPacket { pub player_runtime_id: ActorRuntimeID,