From 4afe60aca9420037c86deccd264584cdd0c7a005 Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Sat, 21 Feb 2026 20:52:37 +0100 Subject: [PATCH] chore: i'm back --- .github/workflows/rust.yml | 2 +- Cargo.lock | 376 ++++++------ Cargo.toml | 18 +- .../src/java/client/config/plugin_message.rs | 25 +- .../src/java/client/config/registry_data.rs | 40 +- .../src/java/client/login/plugin_request.rs | 27 +- .../src/java/client/play/block_entity_data.rs | 30 +- .../src/java/client/play/custom_payload.rs | 25 +- .../src/java/client/play/entity_metadata.rs | 26 +- .../src/java/client/play/particle.rs | 39 +- pumpkin-protocol/src/ser/mod.rs | 10 - pumpkin-protocol/src/ser/serializer.rs | 178 +----- pumpkin-util/src/math/vector3.rs.orig | 543 ------------------ .../structure/structures/buried_treasure.rs | 2 - pumpkin-world/src/generation/surface/mod.rs | 4 - pumpkin-world/src/generation/surface/rule.rs | 3 - 16 files changed, 374 insertions(+), 974 deletions(-) delete mode 100644 pumpkin-util/src/math/vector3.rs.orig diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0b82b2f76..4ffa5a9e9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -117,7 +117,7 @@ jobs: shell: bash run: | if [[ "${{ runner.arch }}" == "X64" ]]; then - export RUSTFLAGS="$RUSTFLAGS -C target-cpu=x86-64-v3" + export RUSTFLAGS="$RUSTFLAGS -C target-cpu=x86-64-v4" fi cargo build --verbose --release - name: Prepare artifacts diff --git a/Cargo.lock b/Cargo.lock index 145b0cffe..24d210475 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher", - "cpufeatures", + "cpufeatures 0.2.17", ] [[package]] @@ -51,24 +51,24 @@ checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "anyhow" -version = "1.0.100" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] name = "arc-swap" -version = "1.8.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d03449bb8ca2cc2ef70869af31463d1ae5ccc8fa3e334b307203fbf815207e" +checksum = "f9f3647c145568cec02c42054e07bdf9a5a698e15b466fb2341bfc393cd24aa5" dependencies = [ "rustversion", ] [[package]] name = "async-compression" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68650b7df54f0293fd061972a0fb05aaf4fc0879d3b3d21a638a182c5c543b9f" +checksum = "7d67d43201f4d20c78bcda740c142ca52482d81da80681533d33bf3f0596c8e2" dependencies = [ "compression-codecs", "compression-core", @@ -174,9 +174,9 @@ checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" [[package]] name = "bitflags" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" [[package]] name = "block-buffer" @@ -198,9 +198,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.19.1" +version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] name = "byteorder" @@ -222,9 +222,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.55" +version = "1.2.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b26a0954ae34af09b50f0de26458fa95369a0d478d8236d3f93082b219bd29" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" dependencies = [ "find-msvc-tools", "shlex", @@ -259,12 +259,12 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chacha20" -version = "0.10.0-rc.10" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c536927023d1c432e6e23a25ef45f6756094eac2ab460db5fb17a772acdfd312" +checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" dependencies = [ "cfg-if", - "cpufeatures", + "cpufeatures 0.3.0", "rand_core 0.10.0", ] @@ -307,18 +307,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.55" +version = "4.5.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e34525d5bbbd55da2bb745d34b36121baac88d07619a9a09cfcf4a6c0832785" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.55" +version = "4.5.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a20016a20a3da95bef50ec7238dbd09baeef4311dcdd38ec15aba69812fb61" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" dependencies = [ "anstyle", "clap_lex", @@ -326,9 +326,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" [[package]] name = "clipboard-win" @@ -356,9 +356,9 @@ dependencies = [ [[package]] name = "compression-codecs" -version = "0.4.36" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00828ba6fd27b45a448e57dbfe84f1029d4c9f26b368157e9a448a5f49a2ec2a" +checksum = "eb7b51a7d9c967fc26773061ba86150f19c50c0d65c887cb1fbe295fd16619b7" dependencies = [ "compression-core", "flate2", @@ -435,9 +435,9 @@ dependencies = [ [[package]] name = "cookie_store" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fc4bff745c9b4c7fb1e97b25d13153da2bc7796260141df62378998d070207f" +checksum = "15b2c103cf610ec6cae3da84a766285b42fd16aad564758459e6ecf128c75206" dependencies = [ "cookie", "document-features", @@ -466,6 +466,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + [[package]] name = "crc-fast" version = "1.10.0" @@ -487,9 +496,9 @@ dependencies = [ [[package]] name = "criterion" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d883447757bb0ee46f233e9dc22eb84d93a9508c9b868687b274fc431d886bf" +checksum = "950046b2aa2492f9a536f5f4f9a3de7b9e2476e575e05bd6c333371add4d98f3" dependencies = [ "alloca", "anes", @@ -511,9 +520,9 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed943f81ea2faa8dcecbbfa50164acf95d555afec96a27871663b300e387b2e4" +checksum = "d8d80a2f4f5b554395e47b5d8305bc3d27813bacb73493eb1001e8f76dae29ea" dependencies = [ "cast", "itertools 0.13.0", @@ -577,9 +586,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crossfire" -version = "3.0.4" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86db11309bffee9435040d648c13c3efbdbcdcd3ead9872e65ce9dff4c3f79ce" +checksum = "4150133c3f558d3190b52a4d36b571e29c18a24e98d24d12201bed0c038986f8" dependencies = [ "crossbeam-utils", "futures-core", @@ -607,9 +616,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.7.0-rc.25" +version = "0.7.0-rc.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cba9eeeb213f7fd29353032f71f7c173e5f6d95d85151cb3a47197b0ea7e8be7" +checksum = "b43308b9b6a47554f4612d5b1fb95ff935040aa3927dd42b1d6cbc015a262d96" dependencies = [ "cpubits", "ctutils", @@ -640,11 +649,11 @@ dependencies = [ [[package]] name = "crypto-primes" -version = "0.7.0-pre.8" +version = "0.7.0-pre.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "334a79c97c0b7fa536716dc132fd417d0afbf471440a41fc25a5d9f66d8771cd" +checksum = "6081ce8b60c0e533e2bba42771b94eb6149052115f4179744d5779883dc98583" dependencies = [ - "crypto-bigint 0.7.0-rc.25", + "crypto-bigint 0.7.0-rc.27", "libm", "rand_core 0.10.0", ] @@ -685,9 +694,9 @@ dependencies = [ [[package]] name = "der" -version = "0.8.0-rc.10" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c1d73e9668ea6b6a28172aa55f3ebec38507131ce179051c8033b5c6037653" +checksum = "71fd89660b2dc699704064e59e9dba0147b903e85319429e131620d022be411b" dependencies = [ "const-oid 0.10.2", "pem-rfc7468 1.0.0", @@ -696,9 +705,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +checksum = "2163a0e204a148662b6b6816d4b5d5668a5f2f8df498ccbd5cd0e864e78fecba" dependencies = [ "powerfmt", ] @@ -717,14 +726,14 @@ dependencies = [ [[package]] name = "digest" -version = "0.11.0-rc.11" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b42f1d9edf5207c137646b568a0168ca0ec25b7f9eaf7f9961da51a3d91cea" +checksum = "f8bf3682cdec91817be507e4aa104314898b95b84d74f3d43882210101a545b6" dependencies = [ "block-buffer 0.11.0", "const-oid 0.10.2", "crypto-common 0.2.0", - "subtle", + "ctutils", ] [[package]] @@ -894,9 +903,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" dependencies = [ "futures-channel", "futures-core", @@ -909,9 +918,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" dependencies = [ "futures-core", "futures-sink", @@ -919,15 +928,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" [[package]] name = "futures-executor" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" dependencies = [ "futures-core", "futures-task", @@ -936,15 +945,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" [[package]] name = "futures-macro" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" dependencies = [ "proc-macro2", "quote", @@ -953,21 +962,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" dependencies = [ "futures-channel", "futures-core", @@ -977,7 +986,6 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] @@ -1005,21 +1013,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi", - "wasip2", -] - -[[package]] -name = "getrandom" -version = "0.4.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f70a332ddf75e5e5e43284304179ba02f391f82f692f030b08a8378adf3c99" +checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" dependencies = [ "cfg-if", "libc", @@ -1140,7 +1136,7 @@ version = "0.13.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef451d73f36d8a3f93ad32c332ea01146c9650e1ec821a9b0e46c01277d544f8" dependencies = [ - "digest 0.11.0-rc.11", + "digest 0.11.0", ] [[package]] @@ -1250,13 +1246,12 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", "http", "http-body", @@ -1424,9 +1419,9 @@ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "js-sys" -version = "0.3.85" +version = "0.3.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +checksum = "93f0862381daaec758576dcc22eb7bbf4d7efd67328553f3b45a412a51a3fb21" dependencies = [ "once_cell", "wasm-bindgen", @@ -1446,9 +1441,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" -version = "0.2.180" +version = "0.2.182" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" [[package]] name = "libloading" @@ -1548,9 +1543,9 @@ checksum = "ae960838283323069879657ca3de837e9f7bbb4c7bf6ea7f1b290d5e9476d2e0" [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "mime" @@ -1770,9 +1765,9 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.8.5" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9eb05c21a464ea704b53158d358a31e6425db2f63a1a7312268b05fe2b75f7" +checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" dependencies = [ "memchr", "ucd-trie", @@ -1780,9 +1775,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.8.5" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f9dbced329c441fa79d80472764b1a2c7e57123553b8519b36663a2fb234ed" +checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" dependencies = [ "pest", "pest_generator", @@ -1790,9 +1785,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.5" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bb96d5051a78f44f43c8f712d8e810adb0ebf923fc9ed2655a7f66f63ba8ee5" +checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" dependencies = [ "pest", "pest_meta", @@ -1803,9 +1798,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.8.5" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113b5b5e8621770cfd490cfd90b9f84ab29bd2b0e49ad83eb6d186cef2365" +checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" dependencies = [ "pest", "sha2 0.10.9", @@ -1892,7 +1887,7 @@ version = "0.8.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "986d2e952779af96ea048f160fd9194e1751b4faea78bcf3ceb456efe008088e" dependencies = [ - "der 0.8.0-rc.10", + "der 0.8.0", "spki 0.8.0-rc.4", ] @@ -1908,11 +1903,11 @@ dependencies = [ [[package]] name = "pkcs8" -version = "0.11.0-rc.10" +version = "0.11.0-rc.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b226d2cc389763951db8869584fd800cbbe2962bf454e2edeb5172b31ee99774" +checksum = "12922b6296c06eb741b02d7b5161e3aaa22864af38dfa025a1a3ba3f68c84577" dependencies = [ - "der 0.8.0-rc.10", + "der 0.8.0", "spki 0.8.0-rc.4", ] @@ -2027,7 +2022,7 @@ dependencies = [ "hmac 0.13.0-rc.5", "libloading", "num-bigint", - "pkcs8 0.11.0-rc.10", + "pkcs8 0.11.0-rc.11", "pumpkin-config", "pumpkin-data", "pumpkin-inventory", @@ -2233,11 +2228,12 @@ dependencies = [ [[package]] name = "rand" -version = "0.10.0-rc.9" -source = "git+https://github.com/rust-random/rand#72afe1e973fcd83d840cf597888223072bbdb04c" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8" dependencies = [ "chacha20", - "getrandom 0.4.0-rc.1", + "getrandom 0.4.1", "rand_core 0.10.0", ] @@ -2267,14 +2263,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.12.2" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.13", - "regex-syntax 0.8.8", + "regex-automata 0.4.14", + "regex-syntax 0.8.9", ] [[package]] @@ -2288,13 +2284,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.8", + "regex-syntax 0.8.9", ] [[package]] @@ -2305,9 +2301,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +checksum = "a96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4c" [[package]] name = "rfc6979" @@ -2340,11 +2336,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b342b99544549f37509ed7fd42b0cea04bfd9ce07c16ca56094cf0fbeefbbcd" dependencies = [ "const-oid 0.10.2", - "crypto-bigint 0.7.0-rc.25", + "crypto-bigint 0.7.0-rc.27", "crypto-primes", - "digest 0.11.0-rc.11", + "digest 0.11.0", "pkcs1", - "pkcs8 0.11.0-rc.10", + "pkcs8 0.11.0-rc.11", "rand_core 0.10.0", "signature 3.0.0-rc.10", "spki 0.8.0-rc.4", @@ -2557,8 +2553,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b167252f3c126be0d8926639c4c4706950f01445900c4b3db0fd7e89fcb750a" dependencies = [ "cfg-if", - "cpufeatures", - "digest 0.11.0-rc.11", + "cpufeatures 0.2.17", + "digest 0.11.0", ] [[package]] @@ -2568,7 +2564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", - "cpufeatures", + "cpufeatures 0.2.17", "digest 0.10.7", ] @@ -2579,8 +2575,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c5f3b1e2dc8aad28310d8410bd4d7e180eca65fca176c52ab00d364475d0024" dependencies = [ "cfg-if", - "cpufeatures", - "digest 0.11.0-rc.11", + "cpufeatures 0.2.17", + "digest 0.11.0", ] [[package]] @@ -2624,7 +2620,7 @@ version = "3.0.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f1880df446116126965eeec169136b2e0251dba37c6223bcc819569550edea3" dependencies = [ - "digest 0.11.0-rc.11", + "digest 0.11.0", "rand_core 0.10.0", ] @@ -2642,9 +2638,9 @@ checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" [[package]] name = "slab" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "slotmap" @@ -2694,7 +2690,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8baeff88f34ed0691978ec34440140e1572b68c7dd4a495fd14a3dc1944daa80" dependencies = [ "base64ct", - "der 0.8.0-rc.10", + "der 0.8.0", ] [[package]] @@ -2717,9 +2713,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.114" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -2751,15 +2747,15 @@ checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" [[package]] name = "temp-dir" -version = "0.1.16" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83176759e9416cf81ee66cb6508dbfe9c96f20b8b56265a39917551c23c70964" +checksum = "016ef9739649996fcc983b9c588fe3d557cf216d4d98503ce1b057ab5a66d689" [[package]] name = "tempfile" -version = "3.24.0" +version = "3.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +checksum = "0136791f7c95b1f6dd99f9cc786b91bb81c3800b639b3478e561ddb7be95e5f1" dependencies = [ "fastrand", "once_cell", @@ -2798,9 +2794,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9da98b7d9b7dad93488a84b8248efc35352b0b2657397d4167e7ad67e5d535e5" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" dependencies = [ "deranged", "itoa", @@ -2819,9 +2815,9 @@ checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" [[package]] name = "time-macros" -version = "0.2.26" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc610bac2dcee56805c99642447d4c5dbde4d01f752ffea0199aee1f601dc4" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" dependencies = [ "num-conv", "time-core", @@ -2902,9 +2898,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.9.11+spec-1.1.0" +version = "1.0.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46" +checksum = "c7614eaf19ad818347db24addfa201729cf2a9b6fdfd9eb0ab870fcacc606c0c" dependencies = [ "indexmap", "serde_core", @@ -2917,18 +2913,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.5+spec-1.1.0" +version = "1.0.0+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +checksum = "32c2555c699578a4f59f0cc68e5116c8d7cabbd45e1409b989d4be085b53f13e" dependencies = [ "serde_core", ] [[package]] name = "toml_parser" -version = "1.0.6+spec-1.1.0" +version = "1.0.9+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" +checksum = "702d4415e08923e7e1ef96cd5727c0dfed80b4d2fa25db9647fe5eb6f7c5a4c4" dependencies = [ "winnow", ] @@ -2941,9 +2937,9 @@ checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" [[package]] name = "tonic" -version = "0.14.2" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb7613188ce9f7df5bfe185db26c5814347d110db17920415cf2fbcad85e7203" +checksum = "fec7c61a0695dc1887c1b53952990f3ad2e3a31453e1f49f10e75424943a93ec" dependencies = [ "async-trait", "axum", @@ -2970,9 +2966,9 @@ dependencies = [ [[package]] name = "tonic-prost" -version = "0.14.2" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bd50ad6ce1252d87ef024b3d64fe4c3cf54a86fb9ef4c631fdd0ded7aeaa67" +checksum = "a55376a0bbaa4975a3f10d009ad763d8f4108f067c7c2e74f3001fb49778d309" dependencies = [ "bytes", "prost", @@ -3108,9 +3104,9 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-segmentation" @@ -3200,11 +3196,11 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee48d38b119b0cd71fe4141b30f5ba9c7c5d9f4e7a3a8b4a674e4b6ef789976f" +checksum = "b672338555252d43fd2240c714dc444b8c6fb0a5c5335e65a07bba7742735ddb" dependencies = [ - "getrandom 0.3.4", + "getrandom 0.4.1", "js-sys", "md-5", "serde_core", @@ -3254,23 +3250,23 @@ version = "1.0.2+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" dependencies = [ - "wit-bindgen 0.51.0", + "wit-bindgen", ] [[package]] name = "wasip3" -version = "0.3.1+wasi-0.3.0-rc-2025-09-16" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba4be47b1d11244670d11857eee0758a8f2c39aea64d80b78c1ce29b4642cd" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" dependencies = [ - "wit-bindgen 0.48.1", + "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.108" +version = "0.2.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +checksum = "1de241cdc66a9d91bd84f097039eb140cdc6eec47e0cdbaf9d932a1dd6c35866" dependencies = [ "cfg-if", "once_cell", @@ -3281,9 +3277,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.108" +version = "0.2.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +checksum = "e12fdf6649048f2e3de6d7d5ff3ced779cdedee0e0baffd7dff5cdfa3abc8a52" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3291,9 +3287,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.108" +version = "0.2.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +checksum = "0e63d1795c565ac3462334c1e396fd46dbf481c40f51f5072c310717bc4fb309" dependencies = [ "bumpalo", "proc-macro2", @@ -3304,18 +3300,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.108" +version = "0.2.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +checksum = "e9f9cdac23a5ce71f6bf9f8824898a501e511892791ea2a0c6b8568c68b9cb53" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-encoder" -version = "0.241.2" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01164c9dda68301e34fdae536c23ed6fe90ce6d97213ccc171eebbd3d02d6b8" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" dependencies = [ "leb128fmt", "wasmparser", @@ -3323,9 +3319,9 @@ dependencies = [ [[package]] name = "wasm-metadata" -version = "0.241.2" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876fe286f2fa416386deedebe8407e6f19e0b5aeaef3d03161e77a15fa80f167" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" dependencies = [ "anyhow", "indexmap", @@ -3335,9 +3331,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.241.2" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46d90019b1afd4b808c263e428de644f3003691f243387d30d673211ee0cb8e8" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ "bitflags", "hashbrown 0.15.5", @@ -3347,9 +3343,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bed680863276c63889429bfd6cab3b99943659923822de1c8a39c49e4d722c" +checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" dependencies = [ "rustls-pki-types", ] @@ -3564,24 +3560,18 @@ checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" [[package]] name = "wit-bindgen" -version = "0.48.1" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f8c2adb5f74ac9395bc3121c99a1254bf9310482c27b13f97167aedb5887138" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" dependencies = [ "wit-bindgen-rust-macro", ] [[package]] -name = "wit-bindgen" +name = "wit-bindgen-core" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" - -[[package]] -name = "wit-bindgen-core" -version = "0.48.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b881a098cae03686d7a0587f8f306f8a58102ad8da8b5599100fbe0e7f5800b" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" dependencies = [ "anyhow", "heck", @@ -3590,9 +3580,9 @@ dependencies = [ [[package]] name = "wit-bindgen-rust" -version = "0.48.1" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69667efa439a453e1d50dac939c6cab6d2c3ac724a9d232b6631dad2472a5b70" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" dependencies = [ "anyhow", "heck", @@ -3606,9 +3596,9 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.48.1" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae2e22cceb5d105d52326c07e3e67603a861cc7add70fc467f7cc7ec5265017" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" dependencies = [ "anyhow", "prettyplease", @@ -3621,9 +3611,9 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.241.2" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0c57df25e7ee612d946d3b7646c1ddb2310f8280aa2c17e543b66e0812241" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", "bitflags", @@ -3640,9 +3630,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.241.2" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ef1c6ad67f35c831abd4039c02894de97034100899614d1c44e2268ad01c91" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" dependencies = [ "anyhow", "id-arena", @@ -3687,18 +3677,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.35" +version = "0.8.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdea86ddd5568519879b8187e1cf04e24fce28f7fe046ceecbce472ff19a2572" +checksum = "db6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4a" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.35" +version = "0.8.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c15e1b46eff7c6c91195752e0eeed8ef040e391cdece7c25376957d5f15df22" +checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517" dependencies = [ "proc-macro2", "quote", @@ -3767,6 +3757,6 @@ dependencies = [ [[package]] name = "zmij" -version = "1.0.19" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff05f8caa9038894637571ae6b9e29466c1f4f829d26c9b28f869a29cbe3445" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index 185dd4c59..ef3b88ac1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,16 +100,16 @@ futures = { version = "0.3", default-features = false, features = ["executor"] } rayon = "1.11" crossbeam = "0.8" -uuid = { version = "1.20", features = ["serde", "v3", "v4"] } +uuid = { version = "1.21", features = ["serde", "v3", "v4"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -tempfile = { version = "3.24.0", default-features = false } +tempfile = { version = "3.25.0", default-features = false } proc-macro-error2 = "2" aes = "0.8" -async-compression = "0.4.39" +async-compression = "0.4.40" base64 = "0.22.1" -bitflags = "2.10.0" +bitflags = "2.11.0" cesu8 = "1.1" cfb8 = "0.8" colored = "3.1" @@ -117,7 +117,7 @@ console-subscriber = { version = "0.5.0", default-features = false } crc-fast = "1.10.0" criterion = { version = "0.8", default-features = false } crossbeam-utils = "0.8.21" -crossfire = { version = "3.0.4", features = ["compat"] } +crossfire = { version = "3.1.3", features = ["compat"] } dashmap = "6.1" ecdsa = "0.16.9" enum_dispatch = "0.3.13" @@ -136,7 +136,7 @@ num-traits = "0.2" num_cpus = "1.17.0" p384 = "0.13.1" phf = "0.13.1" -pkcs8 = "=0.11.0-rc.10" +pkcs8 = "=0.11.0-rc.11" proc-macro2 = "1.0" pumpkin-config = { path = "pumpkin-config" } pumpkin-data = { path = "pumpkin-data", default-features = false } @@ -147,7 +147,7 @@ pumpkin-protocol = { path = "pumpkin-protocol" } pumpkin-util = { path = "pumpkin-util" } pumpkin-world = { path = "pumpkin-world" } quote = "1.0" -rand = { git = "https://github.com/rust-random/rand" } +rand = "0.10.0" rsa = "=0.10.0-rc.15" rustc-hash = "2.1.1" rustyline = "17.0.2" @@ -164,10 +164,10 @@ tracing-subscriber = { version = "=0.3.19", features = [ ] } slotmap = "1.1" take_mut = "0.2.2" -temp-dir = "0.1.16" +temp-dir = "0.2.0" thread_local = "1.1.9" time = "0.3" arc-swap = "1.8" tokio-util = "0.7.18" -toml = "0.9" +toml = "1.0" ureq = "3.2.0" diff --git a/pumpkin-protocol/src/java/client/config/plugin_message.rs b/pumpkin-protocol/src/java/client/config/plugin_message.rs index 92c4d136a..89307fe3e 100644 --- a/pumpkin-protocol/src/java/client/config/plugin_message.rs +++ b/pumpkin-protocol/src/java/client/config/plugin_message.rs @@ -1,14 +1,17 @@ +use std::io::Write; + use pumpkin_data::packet::clientbound::CONFIG_CUSTOM_PAYLOAD; use pumpkin_macros::java_packet; -use serde::Serialize; +use pumpkin_util::version::MinecraftVersion; -use crate::ser::network_serialize_no_prefix; +use crate::{ + ClientPacket, + ser::{NetworkWriteExt, WritingError}, +}; -#[derive(Serialize)] #[java_packet(CONFIG_CUSTOM_PAYLOAD)] pub struct CPluginMessage<'a> { pub channel: &'a str, - #[serde(serialize_with = "network_serialize_no_prefix")] pub data: &'a [u8], } @@ -18,3 +21,17 @@ impl<'a> CPluginMessage<'a> { Self { channel, data } } } + +impl ClientPacket for CPluginMessage<'_> { + fn write_packet_data( + &self, + write: impl Write, + _version: &MinecraftVersion, + ) -> Result<(), WritingError> { + let mut write = write; + + write.write_string(self.channel)?; + + write.write_all(self.data).map_err(WritingError::IoError) + } +} diff --git a/pumpkin-protocol/src/java/client/config/registry_data.rs b/pumpkin-protocol/src/java/client/config/registry_data.rs index b156e3030..818af34f1 100644 --- a/pumpkin-protocol/src/java/client/config/registry_data.rs +++ b/pumpkin-protocol/src/java/client/config/registry_data.rs @@ -1,10 +1,14 @@ -use crate::ser::network_serialize_no_prefix; +use std::io::Write; + +use crate::{ + ClientPacket, + codec::var_int::VarInt, + ser::{NetworkWriteExt, WritingError}, +}; use pumpkin_data::packet::clientbound::CONFIG_REGISTRY_DATA; use pumpkin_macros::java_packet; -use pumpkin_util::resource_location::ResourceLocation; -use serde::Serialize; +use pumpkin_util::{resource_location::ResourceLocation, version::MinecraftVersion}; -#[derive(Serialize)] #[java_packet(CONFIG_REGISTRY_DATA)] pub struct CRegistryData<'a> { pub registry_id: &'a ResourceLocation, @@ -21,10 +25,8 @@ impl<'a> CRegistryData<'a> { } } -#[derive(Serialize)] pub struct RegistryEntry { pub entry_id: ResourceLocation, - #[serde(serialize_with = "network_serialize_no_prefix")] pub data: Option>, } @@ -34,3 +36,29 @@ impl RegistryEntry { Self { entry_id, data } } } + +impl ClientPacket for CRegistryData<'_> { + fn write_packet_data( + &self, + write: impl Write, + _version: &MinecraftVersion, + ) -> Result<(), WritingError> { + let mut write = write; + + write.write_string(&self.registry_id.clone())?; + + write.write_var_int(&VarInt(self.entries.len() as i32))?; + for entry in self.entries { + write.write_string(&entry.entry_id.clone())?; + + if let Some(data) = &entry.data { + write.write_bool(true)?; + write.write_all(data).map_err(WritingError::IoError)?; + } else { + write.write_bool(false)?; + } + } + + Ok(()) + } +} diff --git a/pumpkin-protocol/src/java/client/login/plugin_request.rs b/pumpkin-protocol/src/java/client/login/plugin_request.rs index b698a1b16..e05fc9074 100644 --- a/pumpkin-protocol/src/java/client/login/plugin_request.rs +++ b/pumpkin-protocol/src/java/client/login/plugin_request.rs @@ -1,14 +1,18 @@ +use std::io::Write; + use pumpkin_data::packet::clientbound::LOGIN_CUSTOM_QUERY; use pumpkin_macros::java_packet; -use serde::Serialize; +use pumpkin_util::version::MinecraftVersion; -use crate::{VarInt, ser::network_serialize_no_prefix}; +use crate::{ + ClientPacket, VarInt, + ser::{NetworkWriteExt, WritingError}, +}; /// Sent by the server to initiate a custom plugin messaging exchange during login. /// /// This is used by server software (like proxies or anti-cheats) to request /// information from a client-side mod before the player officially joins. -#[derive(Serialize)] #[java_packet(LOGIN_CUSTOM_QUERY)] pub struct CLoginPluginRequest<'a> { /// A unique ID for this request. The client must include this same ID @@ -18,7 +22,6 @@ pub struct CLoginPluginRequest<'a> { pub channel: &'a str, /// The raw payload data. Unlike standard plugin messages, this data /// is often serialized without a length prefix at the end of the packet. - #[serde(serialize_with = "network_serialize_no_prefix")] pub data: &'a [u8], } @@ -32,3 +35,19 @@ impl<'a> CLoginPluginRequest<'a> { } } } + +impl ClientPacket for CLoginPluginRequest<'_> { + fn write_packet_data( + &self, + write: impl Write, + _version: &MinecraftVersion, + ) -> Result<(), WritingError> { + let mut write = write; + + write.write_var_int(&self.message_id)?; + + write.write_string(self.channel)?; + + write.write_all(self.data).map_err(WritingError::IoError) + } +} diff --git a/pumpkin-protocol/src/java/client/play/block_entity_data.rs b/pumpkin-protocol/src/java/client/play/block_entity_data.rs index 602995fe2..44f665d38 100644 --- a/pumpkin-protocol/src/java/client/play/block_entity_data.rs +++ b/pumpkin-protocol/src/java/client/play/block_entity_data.rs @@ -1,15 +1,18 @@ +use std::io::Write; + use pumpkin_data::packet::clientbound::PLAY_BLOCK_ENTITY_DATA; use pumpkin_macros::java_packet; -use pumpkin_util::math::position::BlockPos; -use serde::Serialize; +use pumpkin_util::{math::position::BlockPos, version::MinecraftVersion}; -use crate::{VarInt, ser::network_serialize_no_prefix}; +use crate::{ + ClientPacket, VarInt, + ser::{NetworkWriteExt, WritingError}, +}; /// Updates the NBT data of a block entity (e.g., signs, chests, or banners). /// /// This packet is sent by the server when a block entity's state changes /// (like text on a sign) or when the block entity is loaded into the client's view. -#[derive(Serialize)] #[java_packet(PLAY_BLOCK_ENTITY_DATA)] pub struct CBlockEntityData { /// The world coordinates of the block entity. @@ -17,7 +20,6 @@ pub struct CBlockEntityData { /// The type of block entity being updated (e.g., Mob Spawner, Command Block). pub r#type: VarInt, /// The raw NBT payload containing the block's specific data. - #[serde(serialize_with = "network_serialize_no_prefix")] pub nbt_data: Box<[u8]>, } @@ -31,3 +33,21 @@ impl CBlockEntityData { } } } + +impl ClientPacket for CBlockEntityData { + fn write_packet_data( + &self, + write: impl Write, + _version: &MinecraftVersion, + ) -> Result<(), WritingError> { + let mut write = write; + + write.write_block_pos(&self.location)?; + + write.write_var_int(&self.r#type)?; + + write + .write_all(&self.nbt_data) + .map_err(WritingError::IoError) + } +} diff --git a/pumpkin-protocol/src/java/client/play/custom_payload.rs b/pumpkin-protocol/src/java/client/play/custom_payload.rs index 1473ccf3e..149868691 100644 --- a/pumpkin-protocol/src/java/client/play/custom_payload.rs +++ b/pumpkin-protocol/src/java/client/play/custom_payload.rs @@ -1,15 +1,18 @@ +use std::io::Write; + use pumpkin_data::packet::clientbound::PLAY_CUSTOM_PAYLOAD; use pumpkin_macros::java_packet; -use serde::Serialize; +use pumpkin_util::version::MinecraftVersion; -use crate::ser::network_serialize_no_prefix; +use crate::{ + ClientPacket, + ser::{NetworkWriteExt, WritingError}, +}; /// A packet used for custom communication between the server and client. -#[derive(Serialize)] #[java_packet(PLAY_CUSTOM_PAYLOAD)] pub struct CCustomPayload<'a> { pub channel: &'a str, - #[serde(serialize_with = "network_serialize_no_prefix")] pub data: &'a [u8], } @@ -19,3 +22,17 @@ impl<'a> CCustomPayload<'a> { Self { channel, data } } } + +impl ClientPacket for CCustomPayload<'_> { + fn write_packet_data( + &self, + write: impl Write, + _version: &MinecraftVersion, + ) -> Result<(), WritingError> { + let mut write = write; + + write.write_string(self.channel)?; + + write.write_all(self.data).map_err(WritingError::IoError) + } +} diff --git a/pumpkin-protocol/src/java/client/play/entity_metadata.rs b/pumpkin-protocol/src/java/client/play/entity_metadata.rs index 7c55b72a7..9ed03b0bd 100644 --- a/pumpkin-protocol/src/java/client/play/entity_metadata.rs +++ b/pumpkin-protocol/src/java/client/play/entity_metadata.rs @@ -1,15 +1,16 @@ -use std::io::Cursor; +use std::io::{Cursor, Write}; use pumpkin_data::{ block_state_remap::remap_block_state_for_version, meta_data_type::MetaDataType, packet::clientbound::PLAY_SET_ENTITY_DATA, tracked_data::TrackedId, }; use pumpkin_macros::java_packet; +use pumpkin_util::version::MinecraftVersion; use serde::Serialize; use crate::{ - VarInt, - ser::{NetworkWriteExt, WritingError, network_serialize_no_prefix, serializer}, + ClientPacket, VarInt, + ser::{NetworkWriteExt, WritingError, serializer}, }; const fn remap_metadata_type_id_for_version( @@ -47,14 +48,12 @@ const fn remap_metadata_type_id_for_version( /// Entity Metadata (or `DataWatchers`) controls persistent visual states that /// don't require a full packet to update, such as whether an entity is on fire, /// crouching, glowing, or the custom name displayed above its head. -#[derive(Serialize)] #[java_packet(PLAY_SET_ENTITY_DATA)] pub struct CSetEntityMetadata { /// The Entity ID of the entity whose metadata is being updated. pub entity_id: VarInt, /// A serialized collection of metadata entries. /// Ends with a terminal byte (0xFF). - #[serde(serialize_with = "network_serialize_no_prefix")] pub metadata: Box<[u8]>, } @@ -68,6 +67,23 @@ impl CSetEntityMetadata { } } +impl ClientPacket for CSetEntityMetadata { + fn write_packet_data( + &self, + write: impl Write, + _version: &MinecraftVersion, + ) -> Result<(), WritingError> { + let mut write = write; + + // 1. Entity ID + write.write_var_int(&self.entity_id)?; + + write + .write_all(&self.metadata) + .map_err(WritingError::IoError) + } +} + pub struct Metadata { index: TrackedId, r#type: VarInt, diff --git a/pumpkin-protocol/src/java/client/play/particle.rs b/pumpkin-protocol/src/java/client/play/particle.rs index 0a0c1eb81..9cbd903ed 100644 --- a/pumpkin-protocol/src/java/client/play/particle.rs +++ b/pumpkin-protocol/src/java/client/play/particle.rs @@ -1,9 +1,13 @@ +use std::io::Write; + use pumpkin_data::packet::clientbound::PLAY_LEVEL_PARTICLES; use pumpkin_macros::java_packet; -use pumpkin_util::math::vector3::Vector3; -use serde::Serialize; +use pumpkin_util::{math::vector3::Vector3, version::MinecraftVersion}; -use crate::{VarInt, ser::network_serialize_no_prefix}; +use crate::{ + ClientPacket, VarInt, + ser::{NetworkWriteExt, WritingError}, +}; /// Spawns a cluster of particles at a specific location. /// @@ -11,7 +15,6 @@ use crate::{VarInt, ser::network_serialize_no_prefix}; /// precise control over particle density, spread, and speed. It can also /// carry extra data for complex particles like redstone dust (color) or /// block/item breaking (textures). -#[derive(Serialize)] #[java_packet(PLAY_LEVEL_PARTICLES)] pub struct CParticle<'a> { /// If true, the particle renders even if the client's "Particles" @@ -32,7 +35,6 @@ pub struct CParticle<'a> { pub particle_id: VarInt, /// Extra data required by specific particles (e.g., block states for /// `block` particles or RGB values for `dust`). - #[serde(serialize_with = "network_serialize_no_prefix")] pub data: &'a [u8], } @@ -61,3 +63,30 @@ impl<'a> CParticle<'a> { } } } + +impl ClientPacket for CParticle<'_> { + fn write_packet_data( + &self, + write: impl Write, + _version: &MinecraftVersion, + ) -> Result<(), WritingError> { + let mut write = write; + + write.write_bool(self.force_spawn)?; + write.write_bool(self.important)?; + + write.write_f64_be(self.position.x)?; + write.write_f64_be(self.position.y)?; + write.write_f64_be(self.position.z)?; + + write.write_f32_be(self.offset.x)?; + write.write_f32_be(self.offset.y)?; + write.write_f32_be(self.offset.z)?; + + write.write_f32_be(self.max_speed)?; + write.write_i32_be(self.particle_count)?; + write.write_var_int(&self.particle_id)?; + + write.write_all(self.data).map_err(WritingError::IoError) + } +} diff --git a/pumpkin-protocol/src/ser/mod.rs b/pumpkin-protocol/src/ser/mod.rs index 6e43824fd..df8150f7c 100644 --- a/pumpkin-protocol/src/ser/mod.rs +++ b/pumpkin-protocol/src/ser/mod.rs @@ -14,16 +14,6 @@ use pumpkin_util::math::position::BlockPos; use thiserror::Error; pub mod serializer; -// TODO: This is a bit hacky -const NO_PREFIX_MARKER: &str = "__network_no_prefix"; - -pub fn network_serialize_no_prefix( - input: T, - serializer: S, -) -> Result { - serializer.serialize_newtype_struct(NO_PREFIX_MARKER, &input) -} - #[derive(Debug, Error)] pub enum ReadingError { #[error("EOF, Tried to read {0} but No bytes left to consume")] diff --git a/pumpkin-protocol/src/ser/serializer.rs b/pumpkin-protocol/src/ser/serializer.rs index ec357010c..9d73f95ba 100644 --- a/pumpkin-protocol/src/ser/serializer.rs +++ b/pumpkin-protocol/src/ser/serializer.rs @@ -2,10 +2,10 @@ use std::fmt::Display; use serde::{ Serialize, - ser::{self, Impossible}, + ser::{self}, }; -use super::{NO_PREFIX_MARKER, NetworkWriteExt, Write, WritingError}; +use super::{NetworkWriteExt, Write, WritingError}; pub struct Serializer { pub write: W, @@ -23,178 +23,6 @@ impl ser::Error for WritingError { } } -/// This serializer just writes a sequence without a varint prefix and defers the rest of the -/// serialization to the wrapped serializer -struct NonPrefixedSeqSerializer<'a, W: Write> { - wrapped: &'a mut Serializer, -} - -macro_rules! create_fail_method { - ($method: ident, $ty: ty) => { - fn $method(self, _v: $ty) -> Result { - Err(WritingError::Serde(format!( - "Expected a sequence, but found {}!", - stringify!($ty) - ))) - } - }; -} - -impl ser::SerializeSeq for NonPrefixedSeqSerializer<'_, W> { - type Ok = (); - type Error = WritingError; - - fn serialize_element(&mut self, value: &T) -> Result<(), Self::Error> { - value.serialize(&mut *self.wrapped) - } - - fn end(self) -> Result { - Ok(()) - } -} - -impl ser::Serializer for NonPrefixedSeqSerializer<'_, W> { - type Ok = (); - type Error = WritingError; - - type SerializeStructVariant = Impossible; - type SerializeStruct = Impossible; - type SerializeMap = Impossible; - type SerializeTupleVariant = Impossible; - type SerializeTuple = Impossible; - type SerializeTupleStruct = Impossible; - type SerializeSeq = Self; - - create_fail_method!(serialize_bool, bool); - create_fail_method!(serialize_bytes, &[u8]); - create_fail_method!(serialize_char, char); - create_fail_method!(serialize_f32, f32); - create_fail_method!(serialize_f64, f64); - create_fail_method!(serialize_i8, i8); - create_fail_method!(serialize_i16, i16); - create_fail_method!(serialize_i32, i32); - create_fail_method!(serialize_i64, i64); - create_fail_method!(serialize_u8, u8); - create_fail_method!(serialize_u16, u16); - create_fail_method!(serialize_u32, u32); - create_fail_method!(serialize_u64, u64); - create_fail_method!(serialize_str, &str); - - fn serialize_map(self, _len: Option) -> Result { - Err(WritingError::Serde( - "Expected a sequence but found a map!".into(), - )) - } - - fn serialize_newtype_struct( - self, - name: &'static str, - _value: &T, - ) -> Result { - Err(WritingError::Serde(format!( - "Expected a sequence but found a newtype struct {name}!" - ))) - } - - fn serialize_newtype_variant( - self, - name: &'static str, - _variant_index: u32, - _variant: &'static str, - _value: &T, - ) -> Result { - Err(WritingError::Serde(format!( - "Expected a sequence but found a newtype variant {name}!" - ))) - } - - fn serialize_none(self) -> Result { - self.wrapped.serialize_none() - } - - fn serialize_seq(self, _len: Option) -> Result { - Ok(self) - } - - fn serialize_some(self, value: &T) -> Result { - self.wrapped.serialize_bool(true)?; - value.serialize(self) - } - - fn serialize_struct( - self, - name: &'static str, - _len: usize, - ) -> Result { - Err(WritingError::Serde(format!( - "Expected a sequence but found a struct {name}!" - ))) - } - - fn serialize_struct_variant( - self, - name: &'static str, - _variant_index: u32, - _variant: &'static str, - _len: usize, - ) -> Result { - Err(WritingError::Serde(format!( - "Expected a sequence but found a struct variant {name}!" - ))) - } - - fn serialize_tuple(self, _len: usize) -> Result { - Err(WritingError::Serde( - "Expected a sequence but found a tuple!".into(), - )) - } - - fn serialize_tuple_struct( - self, - name: &'static str, - _len: usize, - ) -> Result { - Err(WritingError::Serde(format!( - "Expected a sequence but found a tuple struct {name}!" - ))) - } - - fn serialize_tuple_variant( - self, - name: &'static str, - _variant_index: u32, - _variant: &'static str, - _len: usize, - ) -> Result { - Err(WritingError::Serde(format!( - "Expected a sequence but found a tuple variant {name}!" - ))) - } - - fn serialize_unit(self) -> Result { - Err(WritingError::Serde( - "Expected a sequence but found a unit!".into(), - )) - } - - fn serialize_unit_struct(self, name: &'static str) -> Result { - Err(WritingError::Serde(format!( - "Expected a sequence but found a unit struct {name}!" - ))) - } - - fn serialize_unit_variant( - self, - name: &'static str, - _variant_index: u32, - _variant: &'static str, - ) -> Result { - Err(WritingError::Serde(format!( - "Expected a sequence but found a unit variant {name}!" - ))) - } -} - // General notes on the serializer: // // Primitives are written as-is @@ -271,8 +99,6 @@ impl ser::Serializer for &mut Serializer { value.serialize(&mut nbt_serializer).map_err(|err| { WritingError::Serde(format!("Failed to serialize TextComponent NBT: {err}")) }) - } else if name == NO_PREFIX_MARKER { - value.serialize(NonPrefixedSeqSerializer { wrapped: self }) } else { value.serialize(self) } diff --git a/pumpkin-util/src/math/vector3.rs.orig b/pumpkin-util/src/math/vector3.rs.orig deleted file mode 100644 index 7b40f59b7..000000000 --- a/pumpkin-util/src/math/vector3.rs.orig +++ /dev/null @@ -1,543 +0,0 @@ -use bytes::BufMut; -use std::ops::{Add, AddAssign, Div, Mul, Sub}; - -use num_traits::{Float, Num}; - -use super::position::BlockPos; -use super::vector2::Vector2; - -#[derive(Clone, Copy, Debug, PartialEq, Hash, Eq, Default)] -pub struct Vector3 { - pub x: T, - pub y: T, - pub z: T, -} - -#[derive(Copy, Clone, Debug, PartialEq, Eq)] - -pub enum Axis { - X, - - Y, - - Z, -} - -impl Axis { - #[must_use] - pub const fn all() -> [Self; 3] { - [Self::Y, Self::X, Self::Z] - } - - #[must_use] - pub const fn horizontal() -> [Self; 2] { - [Self::X, Self::Z] - } - - #[must_use] - pub const fn excluding(axis: Self) -> [Self; 2] { - match axis { - Self::X => [Self::Y, Self::Z], - - Self::Y => [Self::X, Self::Z], - - Self::Z => [Self::X, Self::Y], - } - } -} - -impl Vector3 { - pub const fn get_axis(&self, a: Axis) -> T { - match a { - Axis::X => self.x, - Axis::Y => self.y, - Axis::Z => self.z, - } - } - - pub const fn set_axis(&mut self, a: Axis, value: T) { - match a { - Axis::X => self.x = value, - Axis::Y => self.y = value, - Axis::Z => self.z = value, - } - } -} - -impl Vector3 { - #[must_use] - pub const fn new(x: T, y: T, z: T) -> Self { - Self { x, y, z } - } - - #[must_use] - pub fn length_squared(&self) -> T { - self.x * self.x + self.y * self.y + self.z * self.z - } - - #[must_use] - pub fn horizontal_length_squared(&self) -> T { - self.x * self.x + self.z * self.z - } - - #[must_use] - pub fn add(&self, other: &Self) -> Self { - Self { - x: self.x + other.x, - y: self.y + other.y, - z: self.z + other.z, - } - } - - #[must_use] - pub fn add_raw(&self, x: T, y: T, z: T) -> Self { - Self { - x: self.x + x, - y: self.y + y, - z: self.z + z, - } - } - - #[must_use] - pub fn sub(&self, other: &Self) -> Self { - Self { - x: self.x - other.x, - y: self.y - other.y, - z: self.z - other.z, - } - } - - #[must_use] - pub fn sub_raw(&self, x: T, y: T, z: T) -> Self { - Self { - x: self.x - x, - y: self.y - y, - z: self.z - z, - } - } - - #[must_use] - pub fn multiply(self, x: T, y: T, z: T) -> Self { - Self { - x: self.x * x, - y: self.y * y, - z: self.z * z, - } - } - - #[must_use] - pub fn lerp(&self, other: &Self, t: T) -> Self { - Self { - x: self.x + (other.x - self.x) * t, - y: self.y + (other.y - self.y) * t, - z: self.z + (other.z - self.z) * t, - } - } - - #[must_use] - pub fn sign(&self) -> Vector3 - where - T: Num + PartialOrd + Copy, - { - Vector3 { - x: if self.x > T::zero() { - 1 - } else if self.x < T::zero() { - -1 - } else { - 0 - }, - y: if self.y > T::zero() { - 1 - } else if self.y < T::zero() { - -1 - } else { - 0 - }, - z: if self.z > T::zero() { - 1 - } else if self.z < T::zero() { - -1 - } else { - 0 - }, - } - } - - #[must_use] - pub fn squared_distance_to_vec(&self, other: &Self) -> T { - self.squared_distance_to(other.x, other.y, other.z) - } - - #[must_use] - pub fn squared_distance_to(&self, x: T, y: T, z: T) -> T { - let delta_x = self.x - x; - let delta_y = self.y - y; - let delta_z = self.z - z; - delta_x * delta_x + delta_y * delta_y + delta_z * delta_z - } - -<<<<<<< HEAD - pub fn squared_distance_to_vec_xz(&self, other: Self) -> T { - self.squared_distance_to_xz(other.x, other.z) - } - - pub fn squared_distance_to_xz(&self, x: T, z: T) -> T { - let delta_x = self.x - x; - let delta_z = self.z - z; - delta_x * delta_x + delta_z * delta_z - } - -======= - #[must_use] ->>>>>>> master - pub fn is_within_bounds(&self, block_pos: Self, x: T, y: T, z: T) -> bool { - let min_x = block_pos.x - x; - let max_x = block_pos.x + x; - let min_y = block_pos.y - y; - let max_y = block_pos.y + y; - let min_z = block_pos.z - z; - let max_z = block_pos.z + z; - - self.x >= min_x - && self.x <= max_x - && self.y >= min_y - && self.y <= max_y - && self.z >= min_z - && self.z <= max_z - } -} - -impl Vector3 { - pub fn length(&self) -> T { - self.length_squared().sqrt() - } - - pub fn horizontal_length(&self) -> T { - self.horizontal_length_squared().sqrt() - } - - #[must_use] - pub fn normalize(&self) -> Self { - let length = self.length(); - Self { - x: self.x / length, - y: self.y / length, - z: self.z / length, - } - } - - pub fn rotation_vector(pitch: T, yaw: T) -> Self { - let h = pitch.to_radians(); - let i = (-yaw).to_radians(); - - let l = h.cos(); - Self { - x: i.sin() * l, - y: -h.sin(), - z: i.cos() * l, - } - } -} - -impl Mul for Vector3 { - type Output = Self; - - fn mul(self, scalar: T) -> Self { - Self { - x: self.x * scalar, - y: self.y * scalar, - z: self.z * scalar, - } - } -} - -impl Add for Vector3 { - type Output = Self; - fn add(self, rhs: Self) -> Self::Output { - Self { - x: self.x + rhs.x, - y: self.y + rhs.y, - z: self.z + rhs.z, - } - } -} - -impl Sub for Vector3 { - type Output = Self; - fn sub(self, rhs: Self) -> Self::Output { - Self { - x: self.x - rhs.x, - y: self.y - rhs.y, - z: self.z - rhs.z, - } - } -} - -impl AddAssign for Vector3 { - fn add_assign(&mut self, other: Self) { - self.x += other.x; - self.y += other.y; - self.z += other.z; - } -} - -/* -impl Neg for Vector3 { - type Output = Self; - - fn neg(self) -> Self { - Vector3 { - x: -self.x, - y: -self.y, - z: -self.z, - } - } -} -*/ - -impl From<(T, T, T)> for Vector3 { - fn from((x, y, z): (T, T, T)) -> Self { - Self { x, y, z } - } -} - -impl From> for (T, T, T) { - fn from(vector: Vector3) -> Self { - (vector.x, vector.y, vector.z) - } -} - -impl> Vector3 { - pub fn to_f64(&self) -> Vector3 { - Vector3 { - x: self.x.into(), - y: self.y.into(), - z: self.z.into(), - } - } -} - -impl> Vector3 { - pub fn to_f32(&self) -> Vector3 { - Vector3 { - x: self.x.into(), - y: self.y.into(), - z: self.z.into(), - } - } -} - -impl> Vector3 { - pub fn to_i32(&self) -> Vector3 { - let x: f64 = self.x.into(); - let y: f64 = self.y.into(); - let z: f64 = self.z.into(); - Vector3 { - x: x.round() as i32, - y: y.round() as i32, - z: z.round() as i32, - } - } - - pub fn to_vec2_i32(&self) -> Vector2 { - let x: f64 = self.x.into(); - let z: f64 = self.z.into(); - Vector2 { - x: x.round() as i32, - y: z.round() as i32, - } - } -} - -impl> Vector3 { - pub fn floor_to_i32(&self) -> Vector3 { - let x: f64 = self.x.into(); - let y: f64 = self.y.into(); - let z: f64 = self.z.into(); - Vector3 { - x: x.floor() as i32, - y: y.floor() as i32, - z: z.floor() as i32, - } - } - - pub fn floor_to_vec2_i32(&self) -> Vector2 { - let x: f64 = self.x.into(); - let z: f64 = self.z.into(); - Vector2 { - x: x.floor() as i32, - y: z.floor() as i32, - } - } -} - -impl> Vector3 { - pub fn to_block_pos(&self) -> BlockPos { - BlockPos(self.to_i32()) - } -} - -pub trait Math: - Mul - //+ Neg - + Add - + AddAssign<> - + Div - + Sub - + Sized -{ -} -impl Math for i16 {} -impl Math for f64 {} -impl Math for f32 {} -impl Math for i32 {} -impl Math for i64 {} -impl Math for u8 {} - -impl<'de> serde::Deserialize<'de> for Vector3 { - fn deserialize>(deserializer: D) -> Result { - struct Vector3Visitor; - - impl<'de> serde::de::Visitor<'de> for Vector3Visitor { - type Value = Vector3; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("a valid Vector") - } - - fn visit_seq>( - self, - mut seq: A, - ) -> Result { - if let Some(x) = seq.next_element::()? - && let Some(y) = seq.next_element::()? - && let Some(z) = seq.next_element::()? - { - return Ok(Vector3::new(x, y, z)); - } - Err(serde::de::Error::custom("Failed to read Vector")) - } - } - - deserializer.deserialize_seq(Vector3Visitor) - } -} - -impl<'de> serde::Deserialize<'de> for Vector3 { - fn deserialize>(deserializer: D) -> Result { - struct Vector3Visitor; - - impl<'de> serde::de::Visitor<'de> for Vector3Visitor { - type Value = Vector3; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("a valid Vector<32>") - } - - fn visit_seq>( - self, - mut seq: A, - ) -> Result { - if let Some(x) = seq.next_element::()? - && let Some(y) = seq.next_element::()? - && let Some(z) = seq.next_element::()? - { - return Ok(Vector3::new(x, y, z)); - } - Err(serde::de::Error::custom("Failed to read Vector")) - } - } - - deserializer.deserialize_seq(Vector3Visitor) - } -} - -impl<'de> serde::Deserialize<'de> for Vector3 { - fn deserialize>(deserializer: D) -> Result { - struct Vector3Visitor; - - impl<'de> serde::de::Visitor<'de> for Vector3Visitor { - type Value = Vector3; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("a valid Vector") - } - - fn visit_seq>( - self, - mut seq: A, - ) -> Result { - if let Some(x) = seq.next_element::()? - && let Some(y) = seq.next_element::()? - && let Some(z) = seq.next_element::()? - { - return Ok(Vector3::new(x, y, z)); - } - Err(serde::de::Error::custom("Failed to read Vector")) - } - } - - deserializer.deserialize_seq(Vector3Visitor) - } -} - -impl serde::Serialize for Vector3 { - fn serialize(&self, serializer: S) -> Result { - let mut buf = Vec::new(); - buf.put_f32(self.x); - buf.put_f32(self.y); - buf.put_f32(self.z); - serializer.serialize_bytes(&buf) - } -} - -impl serde::Serialize for Vector3 { - fn serialize(&self, serializer: S) -> Result { - let mut buf = Vec::new(); - buf.put_f64(self.x); - buf.put_f64(self.y); - buf.put_f64(self.z); - serializer.serialize_bytes(&buf) - } -} - -impl serde::Serialize for Vector3 { - fn serialize(&self, serializer: S) -> Result { - let mut buf = Vec::new(); - buf.put_i16(self.x); - buf.put_i16(self.y); - buf.put_i16(self.z); - serializer.serialize_bytes(&buf) - } -} - -impl serde::Serialize for Vector3 { - fn serialize(&self, serializer: S) -> Result { - let mut buf = Vec::new(); - buf.put_i32(self.x); - buf.put_i32(self.y); - buf.put_i32(self.z); - serializer.serialize_bytes(&buf) - } -} - -#[inline] -#[must_use] -pub const fn packed_chunk_pos(vec: &Vector3) -> i64 { - let mut result = 0i64; - // Need to go to i64 first to conserve sign - result |= (vec.x as i64 & 0x03FF_FFFF) << 42; - result |= (vec.z as i64 & 0x003F_FFFF) << 20; - result |= vec.y as i64 & 0xFFFFF; - result -} - -#[inline] -#[must_use] -pub const fn packed_local(vec: &Vector3) -> i16 { - let x = vec.x as i16; - let y = vec.y as i16; - let z = vec.z as i16; - (x << 8) | (z << 4) | y -} diff --git a/pumpkin-world/src/generation/structure/structures/buried_treasure.rs b/pumpkin-world/src/generation/structure/structures/buried_treasure.rs index ba175f890..bc855bac0 100644 --- a/pumpkin-world/src/generation/structure/structures/buried_treasure.rs +++ b/pumpkin-world/src/generation/structure/structures/buried_treasure.rs @@ -6,7 +6,6 @@ use pumpkin_util::{ math::{block_box::BlockBox, position::BlockPos}, random::RandomGenerator, }; -use serde::Deserialize; use crate::{ ProtoChunk, @@ -22,7 +21,6 @@ use crate::{ }, }; -#[derive(Deserialize)] pub struct BuriedTreasureGenerator; impl StructureGenerator for BuriedTreasureGenerator { diff --git a/pumpkin-world/src/generation/surface/mod.rs b/pumpkin-world/src/generation/surface/mod.rs index ad4df8489..236711205 100644 --- a/pumpkin-world/src/generation/surface/mod.rs +++ b/pumpkin-world/src/generation/surface/mod.rs @@ -10,7 +10,6 @@ use pumpkin_util::{ math::{lerp2, vertical_surface_type::VerticalSurfaceType}, random::{RandomDeriver, RandomDeriverImpl, RandomImpl}, }; -use serde::Deserialize; use terrain::SurfaceTerrainBuilder; @@ -199,7 +198,6 @@ pub fn test_condition( } } -#[derive(Deserialize)] pub struct HoleMaterialCondition; impl HoleMaterialCondition { @@ -236,7 +234,6 @@ pub fn test_not_material( ) } -#[derive(Deserialize)] pub struct SurfaceMaterialCondition; impl SurfaceMaterialCondition { @@ -291,7 +288,6 @@ pub fn estimate_surface_height( context.surface_min_y } -#[derive(Deserialize)] pub struct BiomeMaterialCondition; impl BiomeMaterialCondition { diff --git a/pumpkin-world/src/generation/surface/rule.rs b/pumpkin-world/src/generation/surface/rule.rs index 8309c1bde..c44a7c170 100644 --- a/pumpkin-world/src/generation/surface/rule.rs +++ b/pumpkin-world/src/generation/surface/rule.rs @@ -4,7 +4,6 @@ use pumpkin_data::{ BlockBlueprint, ConditionMaterialRule, MaterialRule, SequenceMaterialRule, }, }; -use serde::Deserialize; use super::MaterialRuleContext; use crate::{ @@ -35,7 +34,6 @@ pub fn try_apply_material_rule( } } -#[derive(Deserialize)] pub struct BadLandsMaterialRule; impl BadLandsMaterialRule { @@ -48,7 +46,6 @@ impl BadLandsMaterialRule { } } -#[derive(Deserialize)] pub struct BlockMaterialRule; impl BlockMaterialRule {