From 3af2dd0cc2af4952e92ad0ae41b23559f1c98068 Mon Sep 17 00:00:00 2001 From: theaddon Date: Mon, 2 Sep 2024 23:06:52 +0200 Subject: [PATCH 1/4] fix formatting --- crates/proto_macros/src/lib.rs | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/crates/proto_macros/src/lib.rs b/crates/proto_macros/src/lib.rs index 5295feda..c200a401 100644 --- a/crates/proto_macros/src/lib.rs +++ b/crates/proto_macros/src/lib.rs @@ -189,39 +189,27 @@ pub fn gamepackets(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let variants = args.packets.clone(); let variants = variants.iter().map(|(name, value)| { if let Some(value) = value { - quote! { - #name(#value), - } + quote! { #name(#value), } } else { - quote! { - #name(), - } + quote! { #name(), } } }); let compress = args.packets.clone(); let compress = compress.iter().map(|(name, value)| { if let Some(v) = value { - quote! { - GamePackets::#name(_) => { return <#v as ::bedrockrs_proto_core::GamePacket>::COMPRESS; }, - } + quote! { GamePackets::#name(_) => { return <#v as ::bedrockrs_proto_core::GamePacket>::COMPRESS; }, } } else { - quote! { - GamePackets::#name() => { todo!("impl GamePackets::{}", stringify!(name)); }, - } + quote! { GamePackets::#name() => { todo!("impl GamePackets::{}", stringify!(name)); }, } } }); let encrypt = args.packets.clone(); let encrypt = encrypt.iter().map(|(name, value)| { if let Some(v) = value { - quote! { - GamePackets::#name(_) => { return <#v as ::bedrockrs_proto_core::GamePacket>::ENCRYPT; }, - } + quote! { GamePackets::#name(_) => { return <#v as ::bedrockrs_proto_core::GamePacket>::ENCRYPT; }, } } else { - quote! { - GamePackets::#name() => { todo!("impl GamePackets::{}", stringify!(name)); }, - } + quote! { GamePackets::#name() => { todo!("impl GamePackets::{}", stringify!(name)); }, } } }); @@ -231,17 +219,17 @@ pub fn gamepackets(input: proc_macro::TokenStream) -> proc_macro::TokenStream { quote! { GamePackets::#name(pk) => { let mut buf = Vec::new(); - + match <#v as bedrockrs_proto_core::ProtoCodec>::proto_serialize(pk, &mut buf) { Ok(_) => {}, Err(err) => return Err(err), }; - + let len: u32 = match buf.len().try_into() { Ok(len) => len, Err(err) => return Err(::bedrockrs_proto_core::error::ProtoCodecError::FromIntError(err)), }; - + match write_gamepacket_header(stream, len, <#v as ::bedrockrs_proto_core::GamePacket>::ID, subclient_sender_id, subclient_target_id) { Ok(_) => {}, Err(err) => return Err(err), From f2746d287ac1d4bfeec4b19849a98a1407bc7917 Mon Sep 17 00:00:00 2001 From: theaddon Date: Mon, 2 Sep 2024 23:07:05 +0200 Subject: [PATCH 2/4] reexport gamepacket trait --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index add145b3..fe78842c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,7 @@ pub mod nbt { #[cfg(feature = "proto")] pub mod proto { pub use ::bedrockrs_proto::*; + pub use ::bedrockrs_proto_core::GamePacket; pub mod codec { pub use ::bedrockrs_proto_core::error::ProtoCodecError; From f69968edb505181f5286847306cc41440b91b77d Mon Sep 17 00:00:00 2001 From: theaddon Date: Wed, 4 Sep 2024 01:24:20 +0200 Subject: [PATCH 3/4] ad xsapi --- Cargo.toml | 2 ++ crates/xsapi/Cargo.toml | 7 +++++++ crates/xsapi/src/lib.rs | 1 + crates/xsapi/src/session/member.rs | 0 crates/xsapi/src/session/mod.rs | 20 ++++++++++++++++++++ 5 files changed, 30 insertions(+) create mode 100644 crates/xsapi/Cargo.toml create mode 100644 crates/xsapi/src/lib.rs create mode 100644 crates/xsapi/src/session/member.rs create mode 100644 crates/xsapi/src/session/mod.rs diff --git a/Cargo.toml b/Cargo.toml index b050de08..95cc0621 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,8 @@ bedrockrs_form = { path = "crates/form" } bedrockrs_world = { path = "crates/world", optional = true } bedrockrs_paletted_storage = { path = "crates/paletted_storage", optional = true } +bedrockrs_xsapi = { path = "crates/xsapi" } + [features] full = ["addons", "proto", "world"] diff --git a/crates/xsapi/Cargo.toml b/crates/xsapi/Cargo.toml new file mode 100644 index 00000000..507714c2 --- /dev/null +++ b/crates/xsapi/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bedrockrs_xsapi" +version = "0.1.0" +edition = "2021" + +[dependencies] +serde = { version = "1.0", features = ["derive"] } diff --git a/crates/xsapi/src/lib.rs b/crates/xsapi/src/lib.rs new file mode 100644 index 00000000..055e2dcc --- /dev/null +++ b/crates/xsapi/src/lib.rs @@ -0,0 +1 @@ +mod session; \ No newline at end of file diff --git a/crates/xsapi/src/session/member.rs b/crates/xsapi/src/session/member.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/xsapi/src/session/mod.rs b/crates/xsapi/src/session/mod.rs new file mode 100644 index 00000000..aafe540f --- /dev/null +++ b/crates/xsapi/src/session/mod.rs @@ -0,0 +1,20 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct Session { + pub properties: SessionProperties, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct SessionProperties { + pub system: SessionPropertiesSystem, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct SessionPropertiesSystem { + #[serde(rename = "joinRestriction")] + pub join_restriction: String, + #[serde(rename = "readRestriction")] + pub read_restriction: String, + pub closed: bool, +} From 703ef19604c60435706416ba0ffb6ef82e4223ae Mon Sep 17 00:00:00 2001 From: theaddon Date: Wed, 4 Sep 2024 01:25:20 +0200 Subject: [PATCH 4/4] add play fab --- Cargo.toml | 1 + crates/play_fab/Cargo.toml | 6 ++++++ crates/play_fab/src/lib.rs | 14 ++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 crates/play_fab/Cargo.toml create mode 100644 crates/play_fab/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 95cc0621..39d9fc2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ bedrockrs_form = { path = "crates/form" } bedrockrs_world = { path = "crates/world", optional = true } bedrockrs_paletted_storage = { path = "crates/paletted_storage", optional = true } +bedrockrs_play_fab = { path = "crates/play_fab" } bedrockrs_xsapi = { path = "crates/xsapi" } [features] diff --git a/crates/play_fab/Cargo.toml b/crates/play_fab/Cargo.toml new file mode 100644 index 00000000..3b6d1069 --- /dev/null +++ b/crates/play_fab/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "bedrockrs_play_fab" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/crates/play_fab/src/lib.rs b/crates/play_fab/src/lib.rs new file mode 100644 index 00000000..b93cf3ff --- /dev/null +++ b/crates/play_fab/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +}