From 85721213dea60049fb844616f925478a26845143 Mon Sep 17 00:00:00 2001 From: theaddon Date: Sun, 15 Sep 2024 13:42:27 +0200 Subject: [PATCH] adapt to new nbtx lib #3 --- crates/proto/src/packets/add_actor.rs | 2 +- crates/proto/src/packets/start_game.rs | 3 +-- crates/proto/src/types/{dataitem.rs => data_item.rs} | 8 ++++---- crates/proto/src/types/mod.rs | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) rename crates/proto/src/types/{dataitem.rs => data_item.rs} (92%) diff --git a/crates/proto/src/packets/add_actor.rs b/crates/proto/src/packets/add_actor.rs index af70bc03..85ca9f73 100644 --- a/crates/proto/src/packets/add_actor.rs +++ b/crates/proto/src/packets/add_actor.rs @@ -6,7 +6,7 @@ use bedrockrs_proto_macros::{gamepacket, ProtoCodec}; use bedrockrs_shared::{actor_runtime_id::ActorRuntimeID, actor_unique_id::ActorUniqueID}; use crate::types::{ - actor_link::ActorLink, attribute::Attribute, dataitem::DataItem, + actor_link::ActorLink, attribute::Attribute, data_item::DataItem, property_sync_data::PropertySyncData, }; diff --git a/crates/proto/src/packets/start_game.rs b/crates/proto/src/packets/start_game.rs index ba7e0bdd..194e61b6 100644 --- a/crates/proto/src/packets/start_game.rs +++ b/crates/proto/src/packets/start_game.rs @@ -1,6 +1,5 @@ use bedrockrs_core::int::{LE, VAR}; use bedrockrs_core::{Vec2, Vec3}; -use bedrockrs_nbt as nbt; use bedrockrs_proto_macros::{gamepacket, ProtoCodec}; use uuid::Uuid; @@ -39,7 +38,7 @@ pub struct StartGamePacket { pub server_version: String, // TODO: This can now be a concrete type rather than an NBT value. // How should we do this with the ProtoCodec macro? - pub player_property_data: nbt::Value, + pub player_property_data: nbtx::Value, pub block_type_registry_checksum: LE, pub world_template_id: Uuid, pub enable_clientside_world_generation: bool, diff --git a/crates/proto/src/types/dataitem.rs b/crates/proto/src/types/data_item.rs similarity index 92% rename from crates/proto/src/types/dataitem.rs rename to crates/proto/src/types/data_item.rs index 5d2efaa1..c5d5fa81 100644 --- a/crates/proto/src/types/dataitem.rs +++ b/crates/proto/src/types/data_item.rs @@ -1,10 +1,9 @@ use std::collections::HashMap; - +use bedrockrs_proto_core::ProtoCodec; use bedrockrs_core::{ int::{LE, VAR}, Vec3, }; -use bedrockrs_nbt as nbt; use bedrockrs_proto_macros::ProtoCodec; #[derive(ProtoCodec, Debug, Clone)] @@ -12,6 +11,7 @@ pub struct DataItem { pub id: VAR, pub value: DataItemValue, } + #[derive(Debug, Clone)] pub enum DataItemValue { ValByte(u8), @@ -19,12 +19,12 @@ pub enum DataItemValue { ValInt(i32), ValFloat(f32), ValString(String), - ValCompoundTag(HashMap), + ValCompoundTag(HashMap), ValPos(Vec3>), ValInt64(LE), ValVec3(Vec3>), } -use bedrockrs_proto_core::ProtoCodec; + impl ProtoCodec for DataItemValue { fn proto_serialize( &self, diff --git a/crates/proto/src/types/mod.rs b/crates/proto/src/types/mod.rs index a7aa39b6..8e6cbe06 100644 --- a/crates/proto/src/types/mod.rs +++ b/crates/proto/src/types/mod.rs @@ -14,7 +14,7 @@ pub mod connection_request; pub mod container_id; pub mod container_type; pub mod credits_state; -pub mod dataitem; +pub mod data_item; pub mod disconnect_reason; pub mod edu_shared_uri_resource; pub mod event_type;