Remove workspace and combine back into one crate
This commit is contained in:
parent
831a53e3b4
commit
58fd071998
282
Cargo.lock
generated
282
Cargo.lock
generated
@ -66,12 +66,59 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "any_vec"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5f6ac04794a7749710e3c7f3c93222e3d04692993b69876d69393efd2565401a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.93"
|
version = "1.0.93"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
|
checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "apecs"
|
||||||
|
version = "0.8.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6df7760d4baebb17003dcf99134d8e3a63f487e146d58911f0bcd27afb185d1c"
|
||||||
|
dependencies = [
|
||||||
|
"any_vec",
|
||||||
|
"apecs-derive",
|
||||||
|
"async-channel",
|
||||||
|
"itertools",
|
||||||
|
"log",
|
||||||
|
"moongraph",
|
||||||
|
"parking_lot",
|
||||||
|
"rayon",
|
||||||
|
"smallvec",
|
||||||
|
"snafu 0.8.5",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "apecs-derive"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc0f3ddfd31fd5276fb8039b75dc4d284c21213757a969e480c6ef8fde494f3b"
|
||||||
|
dependencies = [
|
||||||
|
"moongraph-macros-syntax",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.90",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-channel"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35"
|
||||||
|
dependencies = [
|
||||||
|
"concurrent-queue",
|
||||||
|
"event-listener",
|
||||||
|
"futures-core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.83"
|
version = "0.1.83"
|
||||||
@ -80,7 +127,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.90",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -116,6 +163,17 @@ version = "2.6.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "broomdog"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "52ec65645d8167b03c07e049f114a878a11ab889f20c071d6f7b30bf88fbe5af"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"rustc-hash",
|
||||||
|
"snafu 0.8.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
@ -162,10 +220,10 @@ version = "4.5.18"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
|
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck 0.5.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.90",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -181,13 +239,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "composition-core"
|
name = "composition"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"apecs",
|
||||||
|
"async-trait",
|
||||||
"base64",
|
"base64",
|
||||||
|
"byteorder",
|
||||||
"clap",
|
"clap",
|
||||||
"composition-parsing",
|
|
||||||
"composition-protocol",
|
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -201,35 +261,12 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "composition-parsing"
|
name = "concurrent-queue"
|
||||||
version = "0.1.0"
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"crossbeam-utils",
|
||||||
"serde_json",
|
|
||||||
"thiserror 2.0.3",
|
|
||||||
"tracing",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "composition-protocol"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"byteorder",
|
|
||||||
"composition-parsing",
|
|
||||||
"serde",
|
|
||||||
"thiserror 2.0.3",
|
|
||||||
"tracing",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "composition-world"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"async-trait",
|
|
||||||
"composition-protocol",
|
|
||||||
"thiserror 2.0.3",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -241,12 +278,42 @@ dependencies = [
|
|||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-deque"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-epoch",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-epoch"
|
||||||
|
version = "0.9.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.8.20"
|
version = "0.8.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dagga"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "04cf0d7dcd307c9c5d81277737c35d1faf08af9e2cb262966a01c91021686b68"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"rustc-hash",
|
||||||
|
"snafu 0.7.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deranged"
|
name = "deranged"
|
||||||
version = "0.3.11"
|
version = "0.3.11"
|
||||||
@ -256,12 +323,30 @@ dependencies = [
|
|||||||
"powerfmt",
|
"powerfmt",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "doc-comment"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "event-listener"
|
||||||
|
version = "2.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-core"
|
name = "futures-core"
|
||||||
version = "0.3.31"
|
version = "0.3.31"
|
||||||
@ -286,6 +371,12 @@ version = "0.15.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@ -308,6 +399,15 @@ version = "1.70.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.10.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.14"
|
version = "1.0.14"
|
||||||
@ -368,6 +468,30 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "moongraph"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c5a4b09eb96a84205062b48ec5469c8c35c128167e838aa73dc620c4411af598"
|
||||||
|
dependencies = [
|
||||||
|
"broomdog",
|
||||||
|
"dagga",
|
||||||
|
"log",
|
||||||
|
"rayon",
|
||||||
|
"snafu 0.8.5",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "moongraph-macros-syntax"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "08112087acc92cc28fb5d8f7bda1307123ecc9a275ed4835f1c03f1a8dd02c1d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.90",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-ansi-term"
|
name = "nu-ansi-term"
|
||||||
version = "0.46.0"
|
version = "0.46.0"
|
||||||
@ -458,6 +582,26 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon"
|
||||||
|
version = "1.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"rayon-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon-core"
|
||||||
|
version = "1.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-deque",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.5.7"
|
version = "0.5.7"
|
||||||
@ -473,6 +617,12 @@ version = "0.1.24"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-hash"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.18"
|
version = "1.0.18"
|
||||||
@ -502,7 +652,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.90",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -550,6 +700,49 @@ version = "1.13.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "snafu"
|
||||||
|
version = "0.7.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6"
|
||||||
|
dependencies = [
|
||||||
|
"doc-comment",
|
||||||
|
"snafu-derive 0.7.5",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "snafu"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "223891c85e2a29c3fe8fb900c1fae5e69c2e42415e3177752e8718475efa5019"
|
||||||
|
dependencies = [
|
||||||
|
"snafu-derive 0.8.5",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "snafu-derive"
|
||||||
|
version = "0.7.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf"
|
||||||
|
dependencies = [
|
||||||
|
"heck 0.4.1",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "snafu-derive"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "03c3c6b7927ffe7ecaa769ee0e3994da3b8cafc8f444578982c83ecb161af917"
|
||||||
|
dependencies = [
|
||||||
|
"heck 0.5.0",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.90",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
version = "0.5.8"
|
version = "0.5.8"
|
||||||
@ -566,6 +759,17 @@ version = "0.11.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.109"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.90"
|
version = "2.0.90"
|
||||||
@ -603,7 +807,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.90",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -614,7 +818,7 @@ checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.90",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -684,7 +888,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.90",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -766,7 +970,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.90",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
44
Cargo.toml
44
Cargo.toml
@ -1,8 +1,7 @@
|
|||||||
[workspace]
|
[package]
|
||||||
members = ["crates/*"]
|
name = "composition"
|
||||||
resolver = "2"
|
description = "An extremely fast Minecraft server"
|
||||||
|
build = "build.rs"
|
||||||
[workspace.package]
|
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Garen Tyler <garentyler@garen.dev>"]
|
authors = ["Garen Tyler <garentyler@garen.dev>"]
|
||||||
repository = "https://github.com/garentyler/composition"
|
repository = "https://github.com/garentyler/composition"
|
||||||
@ -10,31 +9,28 @@ readme = "README.md"
|
|||||||
license = "MIT"
|
license = "MIT"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[[bin]]
|
||||||
|
name = "composition"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
update_1_20 = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
anyhow = "1.0.71"
|
anyhow = "1.0.71"
|
||||||
apecs = "0.8.4"
|
apecs = "0.8.4"
|
||||||
async-trait = "0.1.68"
|
async-trait = "0.1.68"
|
||||||
|
base64 = "0.22.1"
|
||||||
byteorder = "1.4.3"
|
byteorder = "1.4.3"
|
||||||
composition-core.path = "./crates/composition-core"
|
clap = { version = "4.2.7", features = ["derive"] }
|
||||||
composition-parsing.path = "./crates/composition-parsing"
|
once_cell = "1.17.1"
|
||||||
composition-protocol.path = "./crates/composition-protocol"
|
|
||||||
composition-world.path = "./crates/composition-world"
|
|
||||||
serde = { version = "1.0.160", features = ["serde_derive"] }
|
serde = { version = "1.0.160", features = ["serde_derive"] }
|
||||||
serde_json = "1.0.96"
|
serde_json = "1.0.96"
|
||||||
thiserror = "2.0.3"
|
thiserror = "2.0.3"
|
||||||
tokio = { version = "1.28.0", features = ["full"] }
|
tokio = { version = "1.28.0", features = ["full"] }
|
||||||
|
tokio-util = "0.7.8"
|
||||||
|
toml = "0.8.19"
|
||||||
tracing = { version = "0.1.37", features = ["log"] }
|
tracing = { version = "0.1.37", features = ["log"] }
|
||||||
|
tracing-subscriber = { version = "0.3.17", features = ["tracing-log"] }
|
||||||
# Unused but possibly useful dependencies:
|
tracing-appender = "0.2.2"
|
||||||
# async-trait = "0.1.48"
|
|
||||||
# backtrace = "0.3.50"
|
|
||||||
# colorful = "0.2.1"
|
|
||||||
# ctrlc = "3.1.8"
|
|
||||||
# fastnbt = "*"
|
|
||||||
# futures = "0.3.28"
|
|
||||||
# mojang-api = "0.6.1"
|
|
||||||
# ozelot = "0.9.0" # Ozelot 0.9.0 supports protocol version 578 (1.15.2)
|
|
||||||
# quartz_nbt = { version = "0.2.6", features = ["serde"] }
|
|
||||||
# radix64 = "0.6.2"
|
|
||||||
# toml = "0.5.6"
|
|
||||||
# uuid = "0.8.2"
|
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "composition-core"
|
|
||||||
description = "An extremely fast Minecraft server"
|
|
||||||
build = "build.rs"
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
repository.workspace = true
|
|
||||||
version.workspace = true
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "composition"
|
|
||||||
path = "src/main.rs"
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
update_1_20 = ["composition-protocol/update_1_20"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
base64 = "0.22.1"
|
|
||||||
clap = { version = "4.2.7", features = ["derive"] }
|
|
||||||
composition-parsing.workspace = true
|
|
||||||
composition-protocol.workspace = true
|
|
||||||
once_cell = "1.17.1"
|
|
||||||
serde.workspace = true
|
|
||||||
serde_json.workspace = true
|
|
||||||
thiserror.workspace = true
|
|
||||||
tokio.workspace = true
|
|
||||||
tokio-util = "0.7.8"
|
|
||||||
toml = "0.8.19"
|
|
||||||
tracing.workspace = true
|
|
||||||
tracing-subscriber = { version = "0.3.17", features = ["tracing-log"] }
|
|
||||||
tracing-appender = "0.2.2"
|
|
@ -1,14 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "composition-parsing"
|
|
||||||
description = "Useful shared parsing functions"
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
repository.workspace = true
|
|
||||||
version.workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
byteorder.workspace = true
|
|
||||||
serde_json.workspace = true
|
|
||||||
thiserror.workspace = true
|
|
||||||
tracing.workspace = true
|
|
@ -1,20 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "composition-protocol"
|
|
||||||
description = "The Minecraft protocol implemented in a network-agnostic way"
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
repository.workspace = true
|
|
||||||
version.workspace = true
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
update_1_20 = []
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow.workspace = true
|
|
||||||
byteorder.workspace = true
|
|
||||||
composition-parsing.workspace = true
|
|
||||||
serde.workspace = true
|
|
||||||
thiserror.workspace = true
|
|
||||||
tracing.workspace = true
|
|
@ -1,14 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "composition-world"
|
|
||||||
description = "A Minecraft world generator implementation that allows for custom worlds"
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
repository.workspace = true
|
|
||||||
version.workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow.workspace = true
|
|
||||||
async-trait.workspace = true
|
|
||||||
composition-protocol.workspace = true
|
|
||||||
thiserror.workspace = true
|
|
@ -122,7 +122,12 @@ impl Config {
|
|||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn write(&self, path: &Path) {
|
fn write(&self, path: &Path) {
|
||||||
trace!("Config.write()");
|
trace!("Config.write()");
|
||||||
if let Ok(mut file) = File::options().write(true).create(true).truncate(true).open(path) {
|
if let Ok(mut file) = File::options()
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(path)
|
||||||
|
{
|
||||||
if file
|
if file
|
||||||
.write_all(toml::to_string(&self).unwrap().as_bytes())
|
.write_all(toml::to_string(&self).unwrap().as_bytes())
|
||||||
.is_ok()
|
.is_ok()
|
||||||
@ -136,7 +141,12 @@ impl Config {
|
|||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn write_server_icon(&self, path: &Path) {
|
fn write_server_icon(&self, path: &Path) {
|
||||||
trace!("Config.write_server_icon()");
|
trace!("Config.write_server_icon()");
|
||||||
if let Ok(mut file) = File::options().write(true).create(true).truncate(true).open(path) {
|
if let Ok(mut file) = File::options()
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(path)
|
||||||
|
{
|
||||||
if file.write_all(&self.server_icon_bytes).is_ok() {
|
if file.write_all(&self.server_icon_bytes).is_ok() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
@ -4,8 +4,12 @@ pub mod config;
|
|||||||
pub(crate) mod error;
|
pub(crate) mod error;
|
||||||
/// Network operations.
|
/// Network operations.
|
||||||
pub(crate) mod net;
|
pub(crate) mod net;
|
||||||
|
/// The Minecraft protocol implemented in a network-agnostic way.
|
||||||
|
pub mod protocol;
|
||||||
/// The core server implementation.
|
/// The core server implementation.
|
||||||
pub(crate) mod server;
|
pub(crate) mod server;
|
||||||
|
/// A Minecraft world generator implementation that allows for custom worlds.
|
||||||
|
pub mod world;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
@ -3,20 +3,18 @@ use tracing_subscriber::prelude::*;
|
|||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
composition_core::START_TIME
|
composition::START_TIME
|
||||||
.set(std::time::Instant::now())
|
.set(std::time::Instant::now())
|
||||||
.expect("could not set composition_core::START_TIME");
|
.expect("could not set composition::START_TIME");
|
||||||
|
|
||||||
// Set up logging.
|
// Set up logging.
|
||||||
let file_writer = tracing_appender::rolling::daily(
|
let file_writer =
|
||||||
&composition_core::config::Args::instance().log_dir,
|
tracing_appender::rolling::daily(&composition::config::Args::instance().log_dir, "log");
|
||||||
"log",
|
|
||||||
);
|
|
||||||
let (file_writer, _guard) = tracing_appender::non_blocking(file_writer);
|
let (file_writer, _guard) = tracing_appender::non_blocking(file_writer);
|
||||||
|
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
.with(tracing_subscriber::filter::LevelFilter::from_level(
|
.with(tracing_subscriber::filter::LevelFilter::from_level(
|
||||||
composition_core::config::Args::instance()
|
composition::config::Args::instance()
|
||||||
.log_level
|
.log_level
|
||||||
.unwrap_or(if cfg!(debug_assertions) {
|
.unwrap_or(if cfg!(debug_assertions) {
|
||||||
tracing::Level::DEBUG
|
tracing::Level::DEBUG
|
||||||
@ -38,7 +36,7 @@ pub fn main() {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// Load the config.
|
// Load the config.
|
||||||
let config = composition_core::config::Config::load();
|
let config = composition::config::Config::load();
|
||||||
|
|
||||||
match config.server_threads {
|
match config.server_threads {
|
||||||
Some(1) => {
|
Some(1) => {
|
||||||
@ -61,10 +59,10 @@ pub fn main() {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.block_on(async move {
|
.block_on(async move {
|
||||||
info!("Starting {} on port {}", config.server_version, config.port);
|
info!("Starting {} on port {}", config.server_version, config.port);
|
||||||
let (mut server, running) = composition_core::start_server().await;
|
let (mut server, running) = composition::start_server().await;
|
||||||
info!(
|
info!(
|
||||||
"Done! Start took {:?}",
|
"Done! Start took {:?}",
|
||||||
composition_core::START_TIME.get().unwrap().elapsed()
|
composition::START_TIME.get().unwrap().elapsed()
|
||||||
);
|
);
|
||||||
|
|
||||||
// The main server loop.
|
// The main server loop.
|
@ -1,7 +1,7 @@
|
|||||||
use composition_parsing::parsable::Parsable;
|
use crate::protocol::{
|
||||||
use composition_protocol::{
|
|
||||||
packets::{serverbound::SL00LoginStart, GenericPacket},
|
|
||||||
ClientState,
|
ClientState,
|
||||||
|
packets::{GenericPacket, serverbound::SL00LoginStart},
|
||||||
|
parsing::parsable::Parsable,
|
||||||
};
|
};
|
||||||
use std::{collections::VecDeque, sync::Arc, time::Instant};
|
use std::{collections::VecDeque, sync::Arc, time::Instant};
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
@ -126,12 +126,12 @@ impl NetworkClient {
|
|||||||
}
|
}
|
||||||
// TODO: Stream compression/encryption.
|
// TODO: Stream compression/encryption.
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub async fn read_packets(&mut self) -> composition_protocol::Result<()> {
|
pub async fn read_packets(&mut self) -> crate::protocol::Result<()> {
|
||||||
trace!("NetworkClient.read_packet() id {}", self.id);
|
trace!("NetworkClient.read_packet() id {}", self.id);
|
||||||
|
|
||||||
if self.read_data().await.is_err() {
|
if self.read_data().await.is_err() {
|
||||||
self.disconnect(None).await;
|
self.disconnect(None).await;
|
||||||
return Err(composition_protocol::Error::Disconnected);
|
return Err(crate::protocol::Error::Disconnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.incoming_data.make_contiguous();
|
self.incoming_data.make_contiguous();
|
||||||
@ -148,7 +148,7 @@ impl NetworkClient {
|
|||||||
data = d;
|
data = d;
|
||||||
self.incoming_packet_queue.push_back(packet);
|
self.incoming_packet_queue.push_back(packet);
|
||||||
}
|
}
|
||||||
Err(composition_parsing::Error::Eof) => break,
|
Err(crate::protocol::parsing::Error::Eof) => break,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Remove the valid bytes before this packet.
|
// Remove the valid bytes before this packet.
|
||||||
self.incoming_data = self.incoming_data.split_off(bytes_consumed);
|
self.incoming_data = self.incoming_data.split_off(bytes_consumed);
|
||||||
@ -185,12 +185,12 @@ impl NetworkClient {
|
|||||||
self.outgoing_packet_queue.push_back(packet.into());
|
self.outgoing_packet_queue.push_back(packet.into());
|
||||||
}
|
}
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub async fn send_queued_packets(&mut self) -> composition_protocol::Result<()> {
|
pub async fn send_queued_packets(&mut self) -> crate::protocol::Result<()> {
|
||||||
let packets: Vec<_> = self.outgoing_packet_queue.drain(..).collect();
|
let packets: Vec<_> = self.outgoing_packet_queue.drain(..).collect();
|
||||||
for packet in packets {
|
for packet in packets {
|
||||||
self.send_packet(packet)
|
self.send_packet(packet)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| composition_protocol::Error::Disconnected)?;
|
.map_err(|_| crate::protocol::Error::Disconnected)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -218,8 +218,8 @@ impl NetworkClient {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub async fn disconnect(&mut self, reason: Option<composition_protocol::mctypes::Chat>) {
|
pub async fn disconnect(&mut self, reason: Option<crate::protocol::mctypes::Chat>) {
|
||||||
use composition_protocol::packets::clientbound::{CL00Disconnect, CP17Disconnect};
|
use crate::protocol::packets::clientbound::{CL00Disconnect, CP17Disconnect};
|
||||||
let reason = reason.unwrap_or(serde_json::json!({
|
let reason = reason.unwrap_or(serde_json::json!({
|
||||||
"text": "You have been disconnected!"
|
"text": "You have been disconnected!"
|
||||||
}));
|
}));
|
@ -1,4 +1,4 @@
|
|||||||
use crate::mctypes::VarInt;
|
use crate::protocol::mctypes::VarInt;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
|
||||||
pub struct Cat {
|
pub struct Cat {
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{
|
use crate::protocol::{
|
||||||
blocks::BlockFace,
|
blocks::BlockFace,
|
||||||
mctypes::{Chat, Position, Uuid, VarInt},
|
mctypes::{Chat, Position, Uuid, VarInt},
|
||||||
};
|
};
|
@ -7,11 +7,11 @@ pub mod player;
|
|||||||
pub mod sniffer;
|
pub mod sniffer;
|
||||||
pub mod villager;
|
pub mod villager;
|
||||||
|
|
||||||
use crate::{
|
use crate::protocol::parsing::{ParseResult, parsable::Parsable};
|
||||||
|
use crate::protocol::{
|
||||||
blocks::BlockPosition,
|
blocks::BlockPosition,
|
||||||
mctypes::{Chat, Uuid, VarInt},
|
mctypes::{Chat, Uuid, VarInt},
|
||||||
};
|
};
|
||||||
use composition_parsing::{parsable::Parsable, ParseResult};
|
|
||||||
|
|
||||||
pub type EntityId = VarInt;
|
pub type EntityId = VarInt;
|
||||||
pub type EntityUuid = Uuid;
|
pub type EntityUuid = Uuid;
|
@ -1,5 +1,5 @@
|
|||||||
use super::EntityId;
|
use super::EntityId;
|
||||||
use crate::mctypes::{Position, VarInt};
|
use crate::protocol::mctypes::{Position, VarInt};
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct Particle {
|
pub struct Particle {
|
@ -1,4 +1,4 @@
|
|||||||
use crate::mctypes::VarInt;
|
use crate::protocol::mctypes::VarInt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Default)]
|
#[derive(Clone, Debug, PartialEq, Default)]
|
||||||
pub struct Player {
|
pub struct Player {
|
@ -1,4 +1,4 @@
|
|||||||
use crate::mctypes::VarInt;
|
use crate::protocol::mctypes::VarInt;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
|
||||||
pub struct Sniffer {
|
pub struct Sniffer {
|
@ -1,4 +1,4 @@
|
|||||||
use crate::mctypes::VarInt;
|
use crate::protocol::mctypes::VarInt;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
|
||||||
pub struct Villager {
|
pub struct Villager {
|
@ -13,9 +13,9 @@ pub enum Error {
|
|||||||
/// This error was caused by attempting to send or receive data from a disconnected client.
|
/// This error was caused by attempting to send or receive data from a disconnected client.
|
||||||
#[error("communicating to disconnected client")]
|
#[error("communicating to disconnected client")]
|
||||||
Disconnected,
|
Disconnected,
|
||||||
/// This error is a wrapper for `composition_parsing::Error`.
|
/// This error is a wrapper for `crate::parsing::Error`.
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
ParseError(#[from] composition_parsing::Error),
|
ParseError(#[from] crate::protocol::parsing::Error),
|
||||||
/// This error is general purpose.
|
/// This error is general purpose.
|
||||||
/// When possible, other error variants should be used.
|
/// When possible, other error variants should be used.
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
@ -1,10 +1,10 @@
|
|||||||
use composition_parsing::parsable::Parsable;
|
use crate::protocol::parsing::parsable::Parsable;
|
||||||
|
|
||||||
/// Alias for a u128.
|
/// Alias for a u128.
|
||||||
pub type Uuid = u128;
|
pub type Uuid = u128;
|
||||||
pub use composition_parsing::VarInt;
|
pub use crate::protocol::parsing::VarInt;
|
||||||
/// Alias for a `serde_json::Value`.
|
/// Alias for a `serde_json::Value`.
|
||||||
pub type Json = composition_parsing::serde_json::Value;
|
pub type Json = crate::protocol::parsing::serde_json::Value;
|
||||||
/// Alias for a `Json`.
|
/// Alias for a `Json`.
|
||||||
pub type Chat = Json;
|
pub type Chat = Json;
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ impl Position {
|
|||||||
}
|
}
|
||||||
impl Parsable for Position {
|
impl Parsable for Position {
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn parse(data: &[u8]) -> composition_parsing::ParseResult<'_, Self> {
|
fn parse(data: &[u8]) -> crate::protocol::parsing::ParseResult<'_, Self> {
|
||||||
let (data, i) = i64::parse(data)?;
|
let (data, i) = i64::parse(data)?;
|
||||||
|
|
||||||
// x: i26, z: i26, y: i12
|
// x: i26, z: i26, y: i12
|
||||||
@ -67,7 +67,7 @@ impl TryFrom<u8> for Difficulty {
|
|||||||
}
|
}
|
||||||
impl Parsable for Difficulty {
|
impl Parsable for Difficulty {
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn parse(data: &[u8]) -> composition_parsing::ParseResult<'_, Self> {
|
fn parse(data: &[u8]) -> crate::protocol::parsing::ParseResult<'_, Self> {
|
||||||
let (data, difficulty) = u8::parse(data)?;
|
let (data, difficulty) = u8::parse(data)?;
|
||||||
let difficulty: Difficulty = difficulty
|
let difficulty: Difficulty = difficulty
|
||||||
.try_into()
|
.try_into()
|
||||||
@ -87,13 +87,10 @@ mod tests {
|
|||||||
fn get_positions() -> Vec<(Position, Vec<u8>)> {
|
fn get_positions() -> Vec<(Position, Vec<u8>)> {
|
||||||
vec![
|
vec![
|
||||||
// x: 01000110000001110110001100 z: 10110000010101101101001000 y: 001100111111
|
// x: 01000110000001110110001100 z: 10110000010101101101001000 y: 001100111111
|
||||||
(
|
(Position::new(18357644, 831, -20882616), vec![
|
||||||
Position::new(18357644, 831, -20882616),
|
0b01000110, 0b00000111, 0b01100011, 0b00101100, 0b00010101, 0b10110100, 0b10000011,
|
||||||
vec![
|
0b00111111,
|
||||||
0b01000110, 0b00000111, 0b01100011, 0b00101100, 0b00010101, 0b10110100,
|
]),
|
||||||
0b10000011, 0b00111111,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
@ -17,6 +17,8 @@ pub mod mctypes;
|
|||||||
/// and "Name" is the packet's name as found on [wiki.vg](https://wiki.vg/Protocol) in PascalCase.
|
/// and "Name" is the packet's name as found on [wiki.vg](https://wiki.vg/Protocol) in PascalCase.
|
||||||
/// Examples include "SH00Handshake", "CP00SpawnEntity", and "SP11KeepAlive".
|
/// Examples include "SH00Handshake", "CP00SpawnEntity", and "SP11KeepAlive".
|
||||||
pub mod packets;
|
pub mod packets;
|
||||||
|
/// Useful shared parsing functions.
|
||||||
|
pub mod parsing;
|
||||||
|
|
||||||
pub use error::{Error, Result};
|
pub use error::{Error, Result};
|
||||||
|
|
@ -1,16 +1,16 @@
|
|||||||
use crate::mctypes::{Chat, Json, Uuid, VarInt};
|
use crate::protocol::mctypes::{Chat, Json, Uuid, VarInt};
|
||||||
use composition_parsing::parsable::Parsable;
|
use crate::protocol::parsing::parsable::Parsable;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct CL00Disconnect {
|
pub struct CL00Disconnect {
|
||||||
pub reason: Chat,
|
pub reason: Chat,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CL00Disconnect,
|
CL00Disconnect,
|
||||||
0x00,
|
0x00,
|
||||||
crate::ClientState::Login,
|
crate::protocol::ClientState::Login,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CL00Disconnect> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CL00Disconnect> {
|
||||||
let (data, reason) = Json::parse(data)?;
|
let (data, reason) = Json::parse(data)?;
|
||||||
Ok((data, CL00Disconnect { reason }))
|
Ok((data, CL00Disconnect { reason }))
|
||||||
},
|
},
|
||||||
@ -23,24 +23,21 @@ pub struct CL01EncryptionRequest {
|
|||||||
pub public_key: Vec<u8>,
|
pub public_key: Vec<u8>,
|
||||||
pub verify_token: Vec<u8>,
|
pub verify_token: Vec<u8>,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CL01EncryptionRequest,
|
CL01EncryptionRequest,
|
||||||
0x01,
|
0x01,
|
||||||
crate::ClientState::Login,
|
crate::protocol::ClientState::Login,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CL01EncryptionRequest> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CL01EncryptionRequest> {
|
||||||
let (data, server_id) = String::parse(data)?;
|
let (data, server_id) = String::parse(data)?;
|
||||||
let (data, public_key) = u8::parse_vec(data)?;
|
let (data, public_key) = u8::parse_vec(data)?;
|
||||||
let (data, verify_token) = u8::parse_vec(data)?;
|
let (data, verify_token) = u8::parse_vec(data)?;
|
||||||
|
|
||||||
Ok((
|
Ok((data, CL01EncryptionRequest {
|
||||||
data,
|
server_id,
|
||||||
CL01EncryptionRequest {
|
public_key,
|
||||||
server_id,
|
verify_token,
|
||||||
public_key,
|
}))
|
||||||
verify_token,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &CL01EncryptionRequest| -> Vec<u8> {
|
|packet: &CL01EncryptionRequest| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -65,18 +62,15 @@ pub struct CL02LoginSuccessProperty {
|
|||||||
}
|
}
|
||||||
impl Parsable for CL02LoginSuccessProperty {
|
impl Parsable for CL02LoginSuccessProperty {
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn parse(data: &[u8]) -> composition_parsing::ParseResult<'_, Self> {
|
fn parse(data: &[u8]) -> crate::protocol::parsing::ParseResult<'_, Self> {
|
||||||
let (data, name) = String::parse(data)?;
|
let (data, name) = String::parse(data)?;
|
||||||
let (data, value) = String::parse(data)?;
|
let (data, value) = String::parse(data)?;
|
||||||
let (data, signature) = String::parse_optional(data)?;
|
let (data, signature) = String::parse_optional(data)?;
|
||||||
Ok((
|
Ok((data, CL02LoginSuccessProperty {
|
||||||
data,
|
name,
|
||||||
CL02LoginSuccessProperty {
|
value,
|
||||||
name,
|
signature,
|
||||||
value,
|
}))
|
||||||
signature,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn serialize(&self) -> Vec<u8> {
|
fn serialize(&self) -> Vec<u8> {
|
||||||
@ -87,24 +81,21 @@ impl Parsable for CL02LoginSuccessProperty {
|
|||||||
output
|
output
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CL02LoginSuccess,
|
CL02LoginSuccess,
|
||||||
0x02,
|
0x02,
|
||||||
crate::ClientState::Login,
|
crate::protocol::ClientState::Login,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CL02LoginSuccess> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CL02LoginSuccess> {
|
||||||
let (data, uuid) = Uuid::parse(data)?;
|
let (data, uuid) = Uuid::parse(data)?;
|
||||||
let (data, username) = String::parse(data)?;
|
let (data, username) = String::parse(data)?;
|
||||||
let (data, properties) = CL02LoginSuccessProperty::parse_vec(data)?;
|
let (data, properties) = CL02LoginSuccessProperty::parse_vec(data)?;
|
||||||
|
|
||||||
Ok((
|
Ok((data, CL02LoginSuccess {
|
||||||
data,
|
uuid,
|
||||||
CL02LoginSuccess {
|
username,
|
||||||
uuid,
|
properties,
|
||||||
username,
|
}))
|
||||||
properties,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &CL02LoginSuccess| -> Vec<u8> {
|
|packet: &CL02LoginSuccess| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -119,12 +110,12 @@ crate::packets::packet!(
|
|||||||
pub struct CL03SetCompression {
|
pub struct CL03SetCompression {
|
||||||
pub threshold: VarInt,
|
pub threshold: VarInt,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CL03SetCompression,
|
CL03SetCompression,
|
||||||
0x03,
|
0x03,
|
||||||
crate::ClientState::Login,
|
crate::protocol::ClientState::Login,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CL03SetCompression> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CL03SetCompression> {
|
||||||
let (data, threshold) = VarInt::parse(data)?;
|
let (data, threshold) = VarInt::parse(data)?;
|
||||||
Ok((data, CL03SetCompression { threshold }))
|
Ok((data, CL03SetCompression { threshold }))
|
||||||
},
|
},
|
||||||
@ -137,22 +128,19 @@ pub struct CL04LoginPluginRequest {
|
|||||||
pub channel: String,
|
pub channel: String,
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CL04LoginPluginRequest,
|
CL04LoginPluginRequest,
|
||||||
0x04,
|
0x04,
|
||||||
crate::ClientState::Login,
|
crate::protocol::ClientState::Login,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CL04LoginPluginRequest> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CL04LoginPluginRequest> {
|
||||||
let (data, message_id) = VarInt::parse(data)?;
|
let (data, message_id) = VarInt::parse(data)?;
|
||||||
let (data, channel) = String::parse(data)?;
|
let (data, channel) = String::parse(data)?;
|
||||||
Ok((
|
Ok((data, CL04LoginPluginRequest {
|
||||||
data,
|
message_id,
|
||||||
CL04LoginPluginRequest {
|
channel,
|
||||||
message_id,
|
data: data.to_vec(),
|
||||||
channel,
|
}))
|
||||||
data: data.to_vec(),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &CL04LoginPluginRequest| -> Vec<u8> {
|
|packet: &CL04LoginPluginRequest| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{
|
use crate::protocol::{
|
||||||
entities::{EntityPosition, EntityRotation, EntityVelocity},
|
entities::{EntityPosition, EntityRotation, EntityVelocity},
|
||||||
mctypes::{Chat, Difficulty, Position, Uuid, VarInt},
|
mctypes::{Chat, Difficulty, Position, Uuid, VarInt},
|
||||||
};
|
};
|
||||||
@ -14,12 +14,12 @@ pub struct CP00SpawnEntity {
|
|||||||
pub data: VarInt,
|
pub data: VarInt,
|
||||||
pub velocity: EntityVelocity,
|
pub velocity: EntityVelocity,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CP00SpawnEntity,
|
CP00SpawnEntity,
|
||||||
0x00,
|
0x00,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CP00SpawnEntity> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CP00SpawnEntity> {
|
||||||
let (data, id) = VarInt::parse(data)?;
|
let (data, id) = VarInt::parse(data)?;
|
||||||
let (data, uuid) = Uuid::parse(data)?;
|
let (data, uuid) = Uuid::parse(data)?;
|
||||||
let (data, kind) = VarInt::parse(data)?;
|
let (data, kind) = VarInt::parse(data)?;
|
||||||
@ -29,19 +29,16 @@ crate::packets::packet!(
|
|||||||
let (data, d) = VarInt::parse(data)?;
|
let (data, d) = VarInt::parse(data)?;
|
||||||
let (data, velocity) = EntityVelocity::parse(data)?;
|
let (data, velocity) = EntityVelocity::parse(data)?;
|
||||||
|
|
||||||
Ok((
|
Ok((data, CP00SpawnEntity {
|
||||||
data,
|
id,
|
||||||
CP00SpawnEntity {
|
uuid,
|
||||||
id,
|
kind,
|
||||||
uuid,
|
position,
|
||||||
kind,
|
rotation,
|
||||||
position,
|
head_yaw,
|
||||||
rotation,
|
data: d,
|
||||||
head_yaw,
|
velocity,
|
||||||
data: d,
|
}))
|
||||||
velocity,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &CP00SpawnEntity| -> Vec<u8> {
|
|packet: &CP00SpawnEntity| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -62,21 +59,18 @@ pub struct CP0BChangeDifficulty {
|
|||||||
pub difficulty: Difficulty,
|
pub difficulty: Difficulty,
|
||||||
pub is_locked: bool,
|
pub is_locked: bool,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CP0BChangeDifficulty,
|
CP0BChangeDifficulty,
|
||||||
0x0b,
|
0x0b,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CP0BChangeDifficulty> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CP0BChangeDifficulty> {
|
||||||
let (data, difficulty) = Difficulty::parse(data)?;
|
let (data, difficulty) = Difficulty::parse(data)?;
|
||||||
let (data, is_locked) = bool::parse(data)?;
|
let (data, is_locked) = bool::parse(data)?;
|
||||||
Ok((
|
Ok((data, CP0BChangeDifficulty {
|
||||||
data,
|
difficulty,
|
||||||
CP0BChangeDifficulty {
|
is_locked,
|
||||||
difficulty,
|
}))
|
||||||
is_locked,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &CP0BChangeDifficulty| -> Vec<u8> {
|
|packet: &CP0BChangeDifficulty| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -90,12 +84,12 @@ crate::packets::packet!(
|
|||||||
pub struct CP17Disconnect {
|
pub struct CP17Disconnect {
|
||||||
pub reason: Chat,
|
pub reason: Chat,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CP17Disconnect,
|
CP17Disconnect,
|
||||||
0x17,
|
0x17,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CP17Disconnect> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CP17Disconnect> {
|
||||||
let (data, reason) = Chat::parse(data)?;
|
let (data, reason) = Chat::parse(data)?;
|
||||||
Ok((data, CP17Disconnect { reason }))
|
Ok((data, CP17Disconnect { reason }))
|
||||||
},
|
},
|
||||||
@ -106,12 +100,12 @@ crate::packets::packet!(
|
|||||||
pub struct CP1FKeepAlive {
|
pub struct CP1FKeepAlive {
|
||||||
pub payload: i64,
|
pub payload: i64,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CP1FKeepAlive,
|
CP1FKeepAlive,
|
||||||
0x1f,
|
0x1f,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CP1FKeepAlive> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CP1FKeepAlive> {
|
||||||
let (data, payload) = i64::parse(data)?;
|
let (data, payload) = i64::parse(data)?;
|
||||||
Ok((data, CP1FKeepAlive { payload }))
|
Ok((data, CP1FKeepAlive { payload }))
|
||||||
},
|
},
|
||||||
@ -125,25 +119,22 @@ pub struct CP21WorldEvent {
|
|||||||
pub data: i32,
|
pub data: i32,
|
||||||
pub disable_relative_volume: bool,
|
pub disable_relative_volume: bool,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CP21WorldEvent,
|
CP21WorldEvent,
|
||||||
0x21,
|
0x21,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CP21WorldEvent> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CP21WorldEvent> {
|
||||||
let (data, event) = i32::parse(data)?;
|
let (data, event) = i32::parse(data)?;
|
||||||
let (data, location) = Position::parse(data)?;
|
let (data, location) = Position::parse(data)?;
|
||||||
let (data, d) = i32::parse(data)?;
|
let (data, d) = i32::parse(data)?;
|
||||||
let (data, disable_relative_volume) = bool::parse(data)?;
|
let (data, disable_relative_volume) = bool::parse(data)?;
|
||||||
Ok((
|
Ok((data, CP21WorldEvent {
|
||||||
data,
|
event,
|
||||||
CP21WorldEvent {
|
location,
|
||||||
event,
|
data: d,
|
||||||
location,
|
disable_relative_volume,
|
||||||
data: d,
|
}))
|
||||||
disable_relative_volume,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &CP21WorldEvent| -> Vec<u8> {
|
|packet: &CP21WorldEvent| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -160,21 +151,18 @@ pub struct CP50SetEntityVelocity {
|
|||||||
pub entity_id: VarInt,
|
pub entity_id: VarInt,
|
||||||
pub entity_velocity: EntityVelocity,
|
pub entity_velocity: EntityVelocity,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CP50SetEntityVelocity,
|
CP50SetEntityVelocity,
|
||||||
0x50,
|
0x50,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CP50SetEntityVelocity> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CP50SetEntityVelocity> {
|
||||||
let (data, entity_id) = VarInt::parse(data)?;
|
let (data, entity_id) = VarInt::parse(data)?;
|
||||||
let (data, entity_velocity) = EntityVelocity::parse(data)?;
|
let (data, entity_velocity) = EntityVelocity::parse(data)?;
|
||||||
Ok((
|
Ok((data, CP50SetEntityVelocity {
|
||||||
data,
|
entity_id,
|
||||||
CP50SetEntityVelocity {
|
entity_velocity,
|
||||||
entity_id,
|
}))
|
||||||
entity_velocity,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &CP50SetEntityVelocity| -> Vec<u8> {
|
|packet: &CP50SetEntityVelocity| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -190,23 +178,20 @@ pub struct CP52SetExperience {
|
|||||||
pub total_experience: VarInt,
|
pub total_experience: VarInt,
|
||||||
pub level: VarInt,
|
pub level: VarInt,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CP52SetExperience,
|
CP52SetExperience,
|
||||||
0x52,
|
0x52,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CP52SetExperience> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CP52SetExperience> {
|
||||||
let (data, experience_bar) = f32::parse(data)?;
|
let (data, experience_bar) = f32::parse(data)?;
|
||||||
let (data, total_experience) = VarInt::parse(data)?;
|
let (data, total_experience) = VarInt::parse(data)?;
|
||||||
let (data, level) = VarInt::parse(data)?;
|
let (data, level) = VarInt::parse(data)?;
|
||||||
Ok((
|
Ok((data, CP52SetExperience {
|
||||||
data,
|
experience_bar,
|
||||||
CP52SetExperience {
|
total_experience,
|
||||||
experience_bar,
|
level,
|
||||||
total_experience,
|
}))
|
||||||
level,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &CP52SetExperience| -> Vec<u8> {
|
|packet: &CP52SetExperience| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -229,12 +214,12 @@ pub struct CP68EntityEffect {
|
|||||||
pub has_factor_data: bool,
|
pub has_factor_data: bool,
|
||||||
// TODO: pub factor_codec: NBT
|
// TODO: pub factor_codec: NBT
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CP68EntityEffect,
|
CP68EntityEffect,
|
||||||
0x68,
|
0x68,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CP68EntityEffect> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CP68EntityEffect> {
|
||||||
let (data, entity_id) = VarInt::parse(data)?;
|
let (data, entity_id) = VarInt::parse(data)?;
|
||||||
let (data, effect_id) = VarInt::parse(data)?;
|
let (data, effect_id) = VarInt::parse(data)?;
|
||||||
let (data, amplifier) = i8::parse(data)?;
|
let (data, amplifier) = i8::parse(data)?;
|
||||||
@ -246,19 +231,16 @@ crate::packets::packet!(
|
|||||||
let (data, has_factor_data) = bool::parse(data)?;
|
let (data, has_factor_data) = bool::parse(data)?;
|
||||||
// TODO: factor_codec
|
// TODO: factor_codec
|
||||||
|
|
||||||
Ok((
|
Ok((data, CP68EntityEffect {
|
||||||
data,
|
entity_id,
|
||||||
CP68EntityEffect {
|
effect_id,
|
||||||
entity_id,
|
amplifier,
|
||||||
effect_id,
|
duration,
|
||||||
amplifier,
|
is_ambient,
|
||||||
duration,
|
show_particles,
|
||||||
is_ambient,
|
show_icon,
|
||||||
show_particles,
|
has_factor_data,
|
||||||
show_icon,
|
}))
|
||||||
has_factor_data,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &CP68EntityEffect| -> Vec<u8> {
|
|packet: &CP68EntityEffect| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
@ -1,15 +1,15 @@
|
|||||||
use crate::mctypes::Json;
|
use crate::protocol::mctypes::Json;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct CS00StatusResponse {
|
pub struct CS00StatusResponse {
|
||||||
pub response: Json,
|
pub response: Json,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CS00StatusResponse,
|
CS00StatusResponse,
|
||||||
0x00,
|
0x00,
|
||||||
crate::ClientState::Status,
|
crate::protocol::ClientState::Status,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CS00StatusResponse> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CS00StatusResponse> {
|
||||||
let (data, response) = Json::parse(data)?;
|
let (data, response) = Json::parse(data)?;
|
||||||
Ok((data, CS00StatusResponse { response }))
|
Ok((data, CS00StatusResponse { response }))
|
||||||
},
|
},
|
||||||
@ -20,12 +20,12 @@ crate::packets::packet!(
|
|||||||
pub struct CS01PingResponse {
|
pub struct CS01PingResponse {
|
||||||
pub payload: i64,
|
pub payload: i64,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
CS01PingResponse,
|
CS01PingResponse,
|
||||||
0x01,
|
0x01,
|
||||||
crate::ClientState::Status,
|
crate::protocol::ClientState::Status,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, CS01PingResponse> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, CS01PingResponse> {
|
||||||
let (data, payload) = i64::parse(data)?;
|
let (data, payload) = i64::parse(data)?;
|
||||||
Ok((data, CS01PingResponse { payload }))
|
Ok((data, CS01PingResponse { payload }))
|
||||||
},
|
},
|
@ -3,8 +3,8 @@ pub mod clientbound;
|
|||||||
/// Packets that are heading to the server.
|
/// Packets that are heading to the server.
|
||||||
pub mod serverbound;
|
pub mod serverbound;
|
||||||
|
|
||||||
use crate::mctypes::VarInt;
|
use crate::protocol::mctypes::VarInt;
|
||||||
use composition_parsing::prelude::*;
|
use crate::protocol::parsing::prelude::*;
|
||||||
|
|
||||||
/// Alias for a `VarInt`.
|
/// Alias for a `VarInt`.
|
||||||
pub type PacketId = VarInt;
|
pub type PacketId = VarInt;
|
||||||
@ -13,7 +13,7 @@ pub trait Packet:
|
|||||||
std::fmt::Debug + Clone + TryFrom<GenericPacket> + Into<GenericPacket> + Parsable
|
std::fmt::Debug + Clone + TryFrom<GenericPacket> + Into<GenericPacket> + Parsable
|
||||||
{
|
{
|
||||||
const ID: i32;
|
const ID: i32;
|
||||||
const CLIENT_STATE: crate::ClientState;
|
const CLIENT_STATE: crate::protocol::ClientState;
|
||||||
const IS_SERVERBOUND: bool;
|
const IS_SERVERBOUND: bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,19 +28,19 @@ macro_rules! generic_packet {
|
|||||||
impl GenericPacket {
|
impl GenericPacket {
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub fn parse_uncompressed<'data>(
|
pub fn parse_uncompressed<'data>(
|
||||||
client_state: crate::ClientState,
|
client_state: crate::protocol::ClientState,
|
||||||
is_serverbound: bool,
|
is_serverbound: bool,
|
||||||
data: &'data [u8]
|
data: &'data [u8]
|
||||||
) -> composition_parsing::ParseResult<'data, Self> {
|
) -> crate::protocol::parsing::ParseResult<'data, Self> {
|
||||||
use composition_parsing::parsable::Parsable;
|
use crate::protocol::parsing::parsable::Parsable;
|
||||||
tracing::trace!(
|
tracing::trace!(
|
||||||
"GenericPacket::parse_uncompressed: {:?} {} {:?}",
|
"GenericPacket::parse_uncompressed: {:?} {} {:?}",
|
||||||
client_state,
|
client_state,
|
||||||
is_serverbound,
|
is_serverbound,
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
let (data, packet_length) = crate::mctypes::VarInt::parse(data)?;
|
let (data, packet_length) = crate::protocol::mctypes::VarInt::parse(data)?;
|
||||||
let (data, packet_data) = composition_parsing::take_bytes(*packet_length as usize)(data)?;
|
let (data, packet_data) = crate::protocol::parsing::take_bytes(*packet_length as usize)(data)?;
|
||||||
|
|
||||||
let (packet_data, packet_id) = PacketId::parse(packet_data)?;
|
let (packet_data, packet_id) = PacketId::parse(packet_data)?;
|
||||||
let (_packet_data, packet_body) =
|
let (_packet_data, packet_body) =
|
||||||
@ -55,12 +55,12 @@ macro_rules! generic_packet {
|
|||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub fn parse_body<'data>(
|
pub fn parse_body<'data>(
|
||||||
client_state: crate::ClientState,
|
client_state: crate::protocol::ClientState,
|
||||||
packet_id: crate::packets::PacketId,
|
packet_id: crate::protocol::packets::PacketId,
|
||||||
is_serverbound: bool,
|
is_serverbound: bool,
|
||||||
data: &'data [u8],
|
data: &'data [u8],
|
||||||
) -> composition_parsing::ParseResult<'data, Self> {
|
) -> crate::protocol::parsing::ParseResult<'data, Self> {
|
||||||
use composition_parsing::parsable::Parsable;
|
use crate::protocol::parsing::parsable::Parsable;
|
||||||
tracing::trace!(
|
tracing::trace!(
|
||||||
"GenericPacket::parse_body: {:?} {} {}",
|
"GenericPacket::parse_body: {:?} {} {}",
|
||||||
client_state,
|
client_state,
|
||||||
@ -76,8 +76,8 @@ macro_rules! generic_packet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub fn serialize(&self) -> (crate::packets::PacketId, Vec<u8>) {
|
pub fn serialize(&self) -> (crate::protocol::packets::PacketId, Vec<u8>) {
|
||||||
use composition_parsing::parsable::Parsable;
|
use crate::protocol::parsing::parsable::Parsable;
|
||||||
tracing::trace!("GenericPacket::serialize: {:?}", self);
|
tracing::trace!("GenericPacket::serialize: {:?}", self);
|
||||||
match self {
|
match self {
|
||||||
$(
|
$(
|
||||||
@ -94,9 +94,9 @@ pub struct UnimplementedPacket(VarInt);
|
|||||||
packet!(
|
packet!(
|
||||||
UnimplementedPacket,
|
UnimplementedPacket,
|
||||||
0x00,
|
0x00,
|
||||||
crate::ClientState::Disconnected,
|
crate::protocol::ClientState::Disconnected,
|
||||||
false,
|
false,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, UnimplementedPacket> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, UnimplementedPacket> {
|
||||||
Ok((data, UnimplementedPacket(0i32.into())))
|
Ok((data, UnimplementedPacket(0i32.into())))
|
||||||
},
|
},
|
||||||
|_packet: &UnimplementedPacket| -> Vec<u8> { vec![] }
|
|_packet: &UnimplementedPacket| -> Vec<u8> { vec![] }
|
||||||
@ -140,14 +140,16 @@ generic_packet!(
|
|||||||
|
|
||||||
macro_rules! packet {
|
macro_rules! packet {
|
||||||
($packet_type: ident, $id: literal, $client_state: expr, $serverbound: literal, $parse_body: expr, $serialize_body: expr) => {
|
($packet_type: ident, $id: literal, $client_state: expr, $serverbound: literal, $parse_body: expr, $serialize_body: expr) => {
|
||||||
impl crate::packets::Packet for $packet_type {
|
impl crate::protocol::packets::Packet for $packet_type {
|
||||||
const ID: i32 = $id;
|
const ID: i32 = $id;
|
||||||
const CLIENT_STATE: crate::ClientState = $client_state;
|
const CLIENT_STATE: crate::protocol::ClientState = $client_state;
|
||||||
const IS_SERVERBOUND: bool = $serverbound;
|
const IS_SERVERBOUND: bool = $serverbound;
|
||||||
}
|
}
|
||||||
impl composition_parsing::parsable::Parsable for $packet_type {
|
impl crate::protocol::parsing::parsable::Parsable for $packet_type {
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn parse<'data>(data: &'data [u8]) -> composition_parsing::ParseResult<'data, Self> {
|
fn parse<'data>(
|
||||||
|
data: &'data [u8],
|
||||||
|
) -> crate::protocol::parsing::ParseResult<'data, Self> {
|
||||||
$parse_body(data)
|
$parse_body(data)
|
||||||
}
|
}
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
@ -155,17 +157,19 @@ macro_rules! packet {
|
|||||||
$serialize_body(self)
|
$serialize_body(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<$packet_type> for crate::packets::GenericPacket {
|
impl From<$packet_type> for crate::protocol::packets::GenericPacket {
|
||||||
fn from(value: $packet_type) -> Self {
|
fn from(value: $packet_type) -> Self {
|
||||||
crate::packets::GenericPacket::$packet_type(value)
|
crate::protocol::packets::GenericPacket::$packet_type(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl TryFrom<crate::packets::GenericPacket> for $packet_type {
|
impl TryFrom<crate::protocol::packets::GenericPacket> for $packet_type {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(value: crate::packets::GenericPacket) -> Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
value: crate::protocol::packets::GenericPacket,
|
||||||
|
) -> Result<Self, Self::Error> {
|
||||||
match value {
|
match value {
|
||||||
crate::packets::GenericPacket::$packet_type(packet) => Ok(packet),
|
crate::protocol::packets::GenericPacket::$packet_type(packet) => Ok(packet),
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{mctypes::VarInt, ClientState};
|
use crate::protocol::{ClientState, mctypes::VarInt};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct SH00Handshake {
|
pub struct SH00Handshake {
|
||||||
@ -7,30 +7,27 @@ pub struct SH00Handshake {
|
|||||||
pub server_port: u16,
|
pub server_port: u16,
|
||||||
pub next_state: ClientState,
|
pub next_state: ClientState,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SH00Handshake,
|
SH00Handshake,
|
||||||
0x00,
|
0x00,
|
||||||
ClientState::Handshake,
|
ClientState::Handshake,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SH00Handshake> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SH00Handshake> {
|
||||||
let (data, protocol_version) = VarInt::parse(data)?;
|
let (data, protocol_version) = VarInt::parse(data)?;
|
||||||
let (data, server_address) = String::parse(data)?;
|
let (data, server_address) = String::parse(data)?;
|
||||||
let (data, server_port) = u16::parse(data)?;
|
let (data, server_port) = u16::parse(data)?;
|
||||||
let (data, next_state) = VarInt::parse(data)?;
|
let (data, next_state) = VarInt::parse(data)?;
|
||||||
|
|
||||||
Ok((
|
Ok((data, SH00Handshake {
|
||||||
data,
|
protocol_version,
|
||||||
SH00Handshake {
|
server_address,
|
||||||
protocol_version,
|
server_port,
|
||||||
server_address,
|
next_state: match *next_state {
|
||||||
server_port,
|
1 => ClientState::Status,
|
||||||
next_state: match *next_state {
|
2 => ClientState::Login,
|
||||||
1 => ClientState::Status,
|
_ => todo!("Invalid next state"),
|
||||||
2 => ClientState::Login,
|
|
||||||
_ => todo!("Invalid next state"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
))
|
}))
|
||||||
},
|
},
|
||||||
|packet: &SH00Handshake| -> Vec<u8> {
|
|packet: &SH00Handshake| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
@ -1,28 +1,25 @@
|
|||||||
use crate::mctypes::{Uuid, VarInt};
|
use crate::protocol::mctypes::{Uuid, VarInt};
|
||||||
use composition_parsing::take_bytes;
|
use crate::protocol::parsing::take_bytes;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct SL00LoginStart {
|
pub struct SL00LoginStart {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub uuid: Option<Uuid>,
|
pub uuid: Option<Uuid>,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SL00LoginStart,
|
SL00LoginStart,
|
||||||
0x00,
|
0x00,
|
||||||
crate::ClientState::Login,
|
crate::protocol::ClientState::Login,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SL00LoginStart> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SL00LoginStart> {
|
||||||
let (data, name) = String::parse(data)?;
|
let (data, name) = String::parse(data)?;
|
||||||
let (data, has_uuid) = bool::parse(data)?;
|
let (data, has_uuid) = bool::parse(data)?;
|
||||||
if has_uuid {
|
if has_uuid {
|
||||||
let (data, uuid) = Uuid::parse(data)?;
|
let (data, uuid) = Uuid::parse(data)?;
|
||||||
Ok((
|
Ok((data, SL00LoginStart {
|
||||||
data,
|
name,
|
||||||
SL00LoginStart {
|
uuid: Some(uuid),
|
||||||
name,
|
}))
|
||||||
uuid: Some(uuid),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
} else {
|
} else {
|
||||||
Ok((data, SL00LoginStart { name, uuid: None }))
|
Ok((data, SL00LoginStart { name, uuid: None }))
|
||||||
}
|
}
|
||||||
@ -43,24 +40,21 @@ pub struct SL01EncryptionResponse {
|
|||||||
pub shared_secret: Vec<u8>,
|
pub shared_secret: Vec<u8>,
|
||||||
pub verify_token: Vec<u8>,
|
pub verify_token: Vec<u8>,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SL01EncryptionResponse,
|
SL01EncryptionResponse,
|
||||||
0x01,
|
0x01,
|
||||||
crate::ClientState::Login,
|
crate::protocol::ClientState::Login,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SL01EncryptionResponse> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SL01EncryptionResponse> {
|
||||||
let (data, shared_secret_len) = VarInt::parse(data)?;
|
let (data, shared_secret_len) = VarInt::parse(data)?;
|
||||||
let (data, shared_secret) = take_bytes(*shared_secret_len as usize)(data)?;
|
let (data, shared_secret) = take_bytes(*shared_secret_len as usize)(data)?;
|
||||||
let (data, verify_token_len) = VarInt::parse(data)?;
|
let (data, verify_token_len) = VarInt::parse(data)?;
|
||||||
let (data, verify_token) = take_bytes(*verify_token_len as usize)(data)?;
|
let (data, verify_token) = take_bytes(*verify_token_len as usize)(data)?;
|
||||||
|
|
||||||
Ok((
|
Ok((data, SL01EncryptionResponse {
|
||||||
data,
|
shared_secret: shared_secret.to_vec(),
|
||||||
SL01EncryptionResponse {
|
verify_token: verify_token.to_vec(),
|
||||||
shared_secret: shared_secret.to_vec(),
|
}))
|
||||||
verify_token: verify_token.to_vec(),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &SL01EncryptionResponse| -> Vec<u8> {
|
|packet: &SL01EncryptionResponse| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -78,32 +72,26 @@ pub struct SL02LoginPluginResponse {
|
|||||||
pub successful: bool,
|
pub successful: bool,
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SL02LoginPluginResponse,
|
SL02LoginPluginResponse,
|
||||||
0x02,
|
0x02,
|
||||||
crate::ClientState::Login,
|
crate::protocol::ClientState::Login,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SL02LoginPluginResponse> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SL02LoginPluginResponse> {
|
||||||
let (data, message_id) = VarInt::parse(data)?;
|
let (data, message_id) = VarInt::parse(data)?;
|
||||||
let (data, successful) = bool::parse(data)?;
|
let (data, successful) = bool::parse(data)?;
|
||||||
if successful {
|
if successful {
|
||||||
Ok((
|
Ok((&[], SL02LoginPluginResponse {
|
||||||
&[],
|
message_id,
|
||||||
SL02LoginPluginResponse {
|
successful,
|
||||||
message_id,
|
data: data.to_vec(),
|
||||||
successful,
|
}))
|
||||||
data: data.to_vec(),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
} else {
|
} else {
|
||||||
Ok((
|
Ok((data, SL02LoginPluginResponse {
|
||||||
data,
|
message_id,
|
||||||
SL02LoginPluginResponse {
|
successful,
|
||||||
message_id,
|
data: vec![],
|
||||||
successful,
|
}))
|
||||||
data: vec![],
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|packet: &SL02LoginPluginResponse| -> Vec<u8> {
|
|packet: &SL02LoginPluginResponse| -> Vec<u8> {
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{
|
use crate::protocol::{
|
||||||
entities::{EntityPosition, EntityRotation},
|
entities::{EntityPosition, EntityRotation},
|
||||||
mctypes::VarInt,
|
mctypes::VarInt,
|
||||||
};
|
};
|
||||||
@ -8,21 +8,18 @@ pub struct SP08CommandSuggestionsRequest {
|
|||||||
pub transaction_id: VarInt,
|
pub transaction_id: VarInt,
|
||||||
pub text: String,
|
pub text: String,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SP08CommandSuggestionsRequest,
|
SP08CommandSuggestionsRequest,
|
||||||
0x08,
|
0x08,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SP08CommandSuggestionsRequest> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SP08CommandSuggestionsRequest> {
|
||||||
let (data, transaction_id) = VarInt::parse(data)?;
|
let (data, transaction_id) = VarInt::parse(data)?;
|
||||||
let (data, text) = String::parse(data)?;
|
let (data, text) = String::parse(data)?;
|
||||||
Ok((
|
Ok((data, SP08CommandSuggestionsRequest {
|
||||||
data,
|
transaction_id,
|
||||||
SP08CommandSuggestionsRequest {
|
text,
|
||||||
transaction_id,
|
}))
|
||||||
text,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &SP08CommandSuggestionsRequest| -> Vec<u8> {
|
|packet: &SP08CommandSuggestionsRequest| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -36,12 +33,12 @@ crate::packets::packet!(
|
|||||||
pub struct SP11KeepAlive {
|
pub struct SP11KeepAlive {
|
||||||
pub payload: i64,
|
pub payload: i64,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SP11KeepAlive,
|
SP11KeepAlive,
|
||||||
0x11,
|
0x11,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SP11KeepAlive> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SP11KeepAlive> {
|
||||||
let (data, payload) = i64::parse(data)?;
|
let (data, payload) = i64::parse(data)?;
|
||||||
Ok((data, SP11KeepAlive { payload }))
|
Ok((data, SP11KeepAlive { payload }))
|
||||||
},
|
},
|
||||||
@ -53,21 +50,18 @@ pub struct SP13SetPlayerPosition {
|
|||||||
pub position: EntityPosition,
|
pub position: EntityPosition,
|
||||||
pub on_ground: bool,
|
pub on_ground: bool,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SP13SetPlayerPosition,
|
SP13SetPlayerPosition,
|
||||||
0x13,
|
0x13,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SP13SetPlayerPosition> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SP13SetPlayerPosition> {
|
||||||
let (data, position) = EntityPosition::parse(data)?;
|
let (data, position) = EntityPosition::parse(data)?;
|
||||||
let (data, on_ground) = bool::parse(data)?;
|
let (data, on_ground) = bool::parse(data)?;
|
||||||
Ok((
|
Ok((data, SP13SetPlayerPosition {
|
||||||
data,
|
position,
|
||||||
SP13SetPlayerPosition {
|
on_ground,
|
||||||
position,
|
}))
|
||||||
on_ground,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &SP13SetPlayerPosition| -> Vec<u8> {
|
|packet: &SP13SetPlayerPosition| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -83,23 +77,20 @@ pub struct SP14SetPlayerPositionAndRotation {
|
|||||||
pub rotation: EntityRotation,
|
pub rotation: EntityRotation,
|
||||||
pub on_ground: bool,
|
pub on_ground: bool,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SP14SetPlayerPositionAndRotation,
|
SP14SetPlayerPositionAndRotation,
|
||||||
0x14,
|
0x14,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SP14SetPlayerPositionAndRotation> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SP14SetPlayerPositionAndRotation> {
|
||||||
let (data, position) = EntityPosition::parse(data)?;
|
let (data, position) = EntityPosition::parse(data)?;
|
||||||
let (data, rotation) = EntityRotation::parse(data)?;
|
let (data, rotation) = EntityRotation::parse(data)?;
|
||||||
let (data, on_ground) = bool::parse(data)?;
|
let (data, on_ground) = bool::parse(data)?;
|
||||||
Ok((
|
Ok((data, SP14SetPlayerPositionAndRotation {
|
||||||
data,
|
position,
|
||||||
SP14SetPlayerPositionAndRotation {
|
rotation,
|
||||||
position,
|
on_ground,
|
||||||
rotation,
|
}))
|
||||||
on_ground,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &SP14SetPlayerPositionAndRotation| -> Vec<u8> {
|
|packet: &SP14SetPlayerPositionAndRotation| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
@ -115,21 +106,18 @@ pub struct SP15SetPlayerRotation {
|
|||||||
pub rotation: EntityRotation,
|
pub rotation: EntityRotation,
|
||||||
pub on_ground: bool,
|
pub on_ground: bool,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SP15SetPlayerRotation,
|
SP15SetPlayerRotation,
|
||||||
0x15,
|
0x15,
|
||||||
crate::ClientState::Play,
|
crate::protocol::ClientState::Play,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SP15SetPlayerRotation> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SP15SetPlayerRotation> {
|
||||||
let (data, rotation) = EntityRotation::parse(data)?;
|
let (data, rotation) = EntityRotation::parse(data)?;
|
||||||
let (data, on_ground) = bool::parse(data)?;
|
let (data, on_ground) = bool::parse(data)?;
|
||||||
Ok((
|
Ok((data, SP15SetPlayerRotation {
|
||||||
data,
|
rotation,
|
||||||
SP15SetPlayerRotation {
|
on_ground,
|
||||||
rotation,
|
}))
|
||||||
on_ground,
|
|
||||||
},
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
|packet: &SP15SetPlayerRotation| -> Vec<u8> {
|
|packet: &SP15SetPlayerRotation| -> Vec<u8> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
@ -1,11 +1,11 @@
|
|||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
pub struct SS00StatusRequest;
|
pub struct SS00StatusRequest;
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SS00StatusRequest,
|
SS00StatusRequest,
|
||||||
0x00,
|
0x00,
|
||||||
crate::ClientState::Status,
|
crate::protocol::ClientState::Status,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SS00StatusRequest> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SS00StatusRequest> {
|
||||||
Ok((data, SS00StatusRequest))
|
Ok((data, SS00StatusRequest))
|
||||||
},
|
},
|
||||||
|_packet: &SS00StatusRequest| -> Vec<u8> { vec![] }
|
|_packet: &SS00StatusRequest| -> Vec<u8> { vec![] }
|
||||||
@ -15,12 +15,12 @@ crate::packets::packet!(
|
|||||||
pub struct SS01PingRequest {
|
pub struct SS01PingRequest {
|
||||||
pub payload: i64,
|
pub payload: i64,
|
||||||
}
|
}
|
||||||
crate::packets::packet!(
|
crate::protocol::packets::packet!(
|
||||||
SS01PingRequest,
|
SS01PingRequest,
|
||||||
0x01,
|
0x01,
|
||||||
crate::ClientState::Status,
|
crate::protocol::ClientState::Status,
|
||||||
true,
|
true,
|
||||||
|data: &'data [u8]| -> composition_parsing::ParseResult<'data, SS01PingRequest> {
|
|data: &'data [u8]| -> crate::protocol::parsing::ParseResult<'data, SS01PingRequest> {
|
||||||
let (data, payload) = i64::parse(data)?;
|
let (data, payload) = i64::parse(data)?;
|
||||||
Ok((data, SS01PingRequest { payload }))
|
Ok((data, SS01PingRequest { payload }))
|
||||||
},
|
},
|
@ -7,7 +7,7 @@ pub enum Error {
|
|||||||
/// This error was caused by prematurely reaching the end of the input data.
|
/// This error was caused by prematurely reaching the end of the input data.
|
||||||
#[error("unexpected end of file")]
|
#[error("unexpected end of file")]
|
||||||
Eof,
|
Eof,
|
||||||
/// This error was caused by reading a `composition_parsing::VarInt` that was longer than 5 bytes.
|
/// This error was caused by reading a `crate::parsing::VarInt` that was longer than 5 bytes.
|
||||||
#[error("VarInt was more than 5 bytes")]
|
#[error("VarInt was more than 5 bytes")]
|
||||||
VarIntTooLong,
|
VarIntTooLong,
|
||||||
/// This error is a wrapper for `serde_json::Error`.
|
/// This error is a wrapper for `serde_json::Error`.
|
||||||
@ -19,11 +19,11 @@ pub enum Error {
|
|||||||
Message(String),
|
Message(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Alias for a Result with the error type `composition_parsing::Error`.
|
/// Alias for a Result with the error type `crate::parsing::Error`.
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
/// Alias for a Result that helps with zero-copy parsing.
|
/// Alias for a Result that helps with zero-copy parsing.
|
||||||
///
|
///
|
||||||
/// The error type is `composition_parsing::Error`,
|
/// The error type is `crate::parsing::Error`,
|
||||||
/// and the result type is a tuple of the remaining bytes and the parsed item.
|
/// and the result type is a tuple of the remaining bytes and the parsed item.
|
||||||
pub type ParseResult<'data, T> = Result<(&'data [u8], T)>;
|
pub type ParseResult<'data, T> = Result<(&'data [u8], T)>;
|
@ -4,7 +4,7 @@ pub mod error;
|
|||||||
pub mod parsable;
|
pub mod parsable;
|
||||||
/// Useful re-exports.
|
/// Useful re-exports.
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::{parsable::Parsable, take_bytes, VarInt};
|
pub use super::{VarInt, parsable::Parsable, take_bytes};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use error::{Error, ParseResult, Result};
|
pub use error::{Error, ParseResult, Result};
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{take_bytes, Error, ParseResult, VarInt};
|
use super::{Error, ParseResult, VarInt, take_bytes};
|
||||||
use byteorder::{BigEndian, ReadBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt};
|
||||||
|
|
||||||
/// A structure that can be serialized and deserialized.
|
/// A structure that can be serialized and deserialized.
|
||||||
@ -321,11 +321,7 @@ impl Parsable for bool {
|
|||||||
}
|
}
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn serialize(&self) -> Vec<u8> {
|
fn serialize(&self) -> Vec<u8> {
|
||||||
if *self {
|
if *self { vec![0x01] } else { vec![0x00] }
|
||||||
vec![0x01]
|
|
||||||
} else {
|
|
||||||
vec![0x00]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@ -1,7 +1,7 @@
|
|||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
use crate::net::{NetworkClient, NetworkClientState};
|
use crate::net::{NetworkClient, NetworkClientState};
|
||||||
use composition_protocol::ClientState;
|
use crate::protocol::ClientState;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::net::{TcpListener, ToSocketAddrs};
|
use tokio::net::{TcpListener, ToSocketAddrs};
|
||||||
use tokio::{sync::RwLock, task::JoinHandle};
|
use tokio::{sync::RwLock, task::JoinHandle};
|
||||||
@ -162,7 +162,7 @@ impl Server {
|
|||||||
.filter(|client| matches!(client.state, NetworkClientState::Play))
|
.filter(|client| matches!(client.state, NetworkClientState::Play))
|
||||||
.count();
|
.count();
|
||||||
'clients: for client in clients.iter_mut() {
|
'clients: for client in clients.iter_mut() {
|
||||||
use composition_protocol::packets::{clientbound::*, serverbound::*};
|
use crate::protocol::packets::{clientbound::*, serverbound::*};
|
||||||
'packets: while !client.incoming_packet_queue.is_empty() {
|
'packets: while !client.incoming_packet_queue.is_empty() {
|
||||||
// client.read_packet()
|
// client.read_packet()
|
||||||
// None: The client doesn't have any more packets.
|
// None: The client doesn't have any more packets.
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{
|
use crate::world::{
|
||||||
blocks::{Block, BlockPosition},
|
blocks::{Block, BlockPosition},
|
||||||
entities::{Entity, EntityId, EntityPosition},
|
entities::{Entity, EntityId, EntityPosition},
|
||||||
};
|
};
|
@ -6,13 +6,13 @@ pub mod error;
|
|||||||
pub mod generators;
|
pub mod generators;
|
||||||
/// Useful re-exports.
|
/// Useful re-exports.
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::{chunks::Chunk, World};
|
pub use super::{World, chunks::Chunk};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use composition_protocol::{blocks, entities};
|
pub use crate::protocol::{blocks, entities};
|
||||||
pub use error::{Error, Result};
|
pub use error::{Error, Result};
|
||||||
|
|
||||||
use crate::chunks::{Chunk, ChunkPosition};
|
use crate::world::chunks::{Chunk, ChunkPosition};
|
||||||
use blocks::{Block, BlockPosition};
|
use blocks::{Block, BlockPosition};
|
||||||
use entities::{Entity, EntityId, EntityPosition};
|
use entities::{Entity, EntityId, EntityPosition};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
Loading…
x
Reference in New Issue
Block a user