diff --git a/Cargo.lock b/Cargo.lock index b681717e1..9d45e5709 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,22 +99,22 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.10" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -161,9 +161,9 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "axum" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18ed336352031311f4e0b4dd2ff392d4fbb370777c9d18d7fc9d7359f73871" +checksum = "5b098575ebe77cb6d14fc7f32749631a6e44edbef6b796f89b020e99ba20d425" dependencies = [ "axum-core", "bytes", @@ -264,9 +264,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.11.0-rc.5" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ef36a6fcdb072aa548f3da057640ec10859eb4e91ddf526ee648d50c76a949" +checksum = "96eb4cdd6cf1b31d671e9efe75c5d1ec614776856cefbe109ca373554a6d514f" dependencies = [ "hybrid-array", ] @@ -297,9 +297,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.45" +version = "1.2.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe" +checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36" dependencies = [ "find-msvc-tools", "shlex", @@ -326,6 +326,17 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "chacha20" +version = "0.10.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99cbf41c6ec3c4b9eaf7f8f5c11a72cd7d3aa0428125c20d5ef4d09907a0f019" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core 0.10.0-rc-2", +] + [[package]] name = "ciborium" version = "0.2.2" @@ -359,24 +370,24 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "crypto-common 0.1.6", + "crypto-common 0.1.7", "inout", ] [[package]] name = "clap" -version = "4.5.51" +version = "4.5.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" +checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.51" +version = "4.5.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" +checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" dependencies = [ "anstyle", "clap_lex", @@ -690,12 +701,12 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.7.0-rc.9" +version = "0.7.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4b0fda9462026d53a3ef37c5ec283639ee8494a1a5401109c0e2a3fb4d490c" +checksum = "6715836b4946e8585016e80b79c7561476aff3b22f7b756778e7b109d86086c6" dependencies = [ "num-traits", - "rand_core 0.9.3", + "rand_core 0.10.0-rc-2", "serdect", "subtle", "zeroize", @@ -703,9 +714,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -713,22 +724,22 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.2.0-rc.4" +version = "0.2.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8235645834fbc6832939736ce2f2d08192652269e11010a6240f61b908a1c6" +checksum = "919bd05924682a5480aec713596b9e2aabed3a0a6022fab6847f85a99e5f190a" dependencies = [ "hybrid-array", ] [[package]] name = "crypto-primes" -version = "0.7.0-pre.3" +version = "0.7.0-pre.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f2523fbb68811c8710829417ad488086720a6349e337c38d12fa81e09e50bf" +checksum = "fdd9b2855017318a49714c07ee8895b89d3510d54fa6d86be5835de74c389609" dependencies = [ - "crypto-bigint 0.7.0-rc.9", + "crypto-bigint 0.7.0-rc.10", "libm", - "rand_core 0.9.3", + "rand_core 0.10.0-rc-2", ] [[package]] @@ -758,12 +769,12 @@ dependencies = [ [[package]] name = "der" -version = "0.8.0-rc.9" +version = "0.8.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d8dd2f26c86b27a2a8ea2767ec7f9df7a89516e4794e54ac01ee618dda3aa4" +checksum = "02c1d73e9668ea6b6a28172aa55f3ebec38507131ce179051c8033b5c6037653" dependencies = [ "const-oid 0.10.1", - "pem-rfc7468 1.0.0-rc.3", + "pem-rfc7468 1.0.0", "zeroize", ] @@ -832,19 +843,19 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "const-oid 0.9.6", - "crypto-common 0.1.6", + "crypto-common 0.1.7", "subtle", ] [[package]] name = "digest" -version = "0.11.0-rc.3" +version = "0.11.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac89f8a64533a9b0eaa73a68e424db0fb1fd6271c74cc0125336a05f090568d" +checksum = "ea390c940e465846d64775e55e3115d5dc934acb953de6f6e6360bc232fe2bf7" dependencies = [ - "block-buffer 0.11.0-rc.5", + "block-buffer 0.11.0", "const-oid 0.10.1", - "crypto-common 0.2.0-rc.4", + "crypto-common 0.2.0-rc.5", "subtle", ] @@ -957,7 +968,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -978,9 +989,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "flate2" @@ -1104,9 +1115,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.9" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -1191,9 +1202,9 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", @@ -1245,11 +1256,11 @@ dependencies = [ [[package]] name = "hmac" -version = "0.13.0-rc.2" +version = "0.13.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3fd4dc94c318c1ede8a2a48341c250d6ddecd3ba793da2820301a9f92417ad9" +checksum = "f1c597ac7d6cc8143e30e83ef70915e7f883b18d8bec2e2b2bce47f5bbb06d57" dependencies = [ - "digest 0.11.0-rc.3", + "digest 0.11.0-rc.4", ] [[package]] @@ -1315,9 +1326,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ "atomic-waker", "bytes", @@ -1351,9 +1362,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" +checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" dependencies = [ "bytes", "futures-channel", @@ -1485,7 +1496,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "serde", "serde_core", ] @@ -1540,22 +1551,22 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jiff" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49" +checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35" dependencies = [ "jiff-static", "log", "portable-atomic", "portable-atomic-util", - "serde", + "serde_core", ] [[package]] name = "jiff-static" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" +checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" dependencies = [ "proc-macro2", "quote", @@ -1639,7 +1650,7 @@ version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96051b46fc183dc9cd4a223960ef37b9af631b55191852a8274bfef064cda20f" dependencies = [ - "hashbrown 0.16.0", + "hashbrown 0.16.1", ] [[package]] @@ -1891,9 +1902,9 @@ dependencies = [ [[package]] name = "pem-rfc7468" -version = "1.0.0-rc.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8e58fab693c712c0d4e88f8eb3087b6521d060bcaf76aeb20cb192d809115ba" +checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9" dependencies = [ "base64ct", ] @@ -2028,7 +2039,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.9", + "der 0.8.0-rc.10", "spki 0.8.0-rc.4", ] @@ -2044,11 +2055,11 @@ dependencies = [ [[package]] name = "pkcs8" -version = "0.11.0-rc.7" +version = "0.11.0-rc.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93eac55f10aceed84769df670ea4a32d2ffad7399400d41ee1c13b1cd8e1b478" +checksum = "77089aec8290d0b7bb01b671b091095cf1937670725af4fd73d47249f03b12c0" dependencies = [ - "der 0.8.0-rc.9", + "der 0.8.0-rc.10", "spki 0.8.0-rc.4", ] @@ -2082,15 +2093,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - [[package]] name = "primeorder" version = "0.13.6" @@ -2175,7 +2177,7 @@ dependencies = [ "dhat", "flate2", "futures", - "hmac 0.13.0-rc.2", + "hmac 0.13.0-rc.3", "libloading", "log", "num-bigint", @@ -2197,7 +2199,7 @@ dependencies = [ "serde", "serde_json", "sha1", - "sha2 0.11.0-rc.2", + "sha2 0.11.0-rc.3", "signature 2.2.0", "simplelog", "tempfile", @@ -2405,22 +2407,13 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rand" -version = "0.9.2" +version = "0.10.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +checksum = "be866deebbade98028b705499827ad6967c8bb1e21f96a2609913c8c076e9307" dependencies = [ - "rand_chacha", - "rand_core 0.9.3", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core 0.9.3", + "chacha20", + "getrandom 0.3.4", + "rand_core 0.10.0-rc-2", ] [[package]] @@ -2434,12 +2427,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.3" +version = "0.10.0-rc-2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" -dependencies = [ - "getrandom 0.3.4", -] +checksum = "104a23e4e8b77312a823b6b5613edbac78397e2f34320bc7ac4277013ec4478e" [[package]] name = "rayon" @@ -2525,19 +2515,19 @@ dependencies = [ [[package]] name = "rsa" -version = "0.10.0-rc.9" +version = "0.10.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8955ab399f6426998fde6b76ae27233cce950705e758a6c17afd2f6d0e5d52" +checksum = "e499c52862d75a86c0024cc99dcb6d7127d15af3beae7b03573d62fab7ade08a" dependencies = [ "const-oid 0.10.1", - "crypto-bigint 0.7.0-rc.9", + "crypto-bigint 0.7.0-rc.10", "crypto-primes", - "digest 0.11.0-rc.3", + "digest 0.11.0-rc.4", "pkcs1", - "pkcs8 0.11.0-rc.7", - "rand_core 0.9.3", + "pkcs8 0.11.0-rc.8", + "rand_core 0.10.0-rc-2", "sha1", - "signature 3.0.0-rc.4", + "signature 3.0.0-rc.5", "spki 0.8.0-rc.4", "subtle", "zeroize", @@ -2580,7 +2570,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -2758,13 +2748,13 @@ dependencies = [ [[package]] name = "sha1" -version = "0.11.0-rc.2" +version = "0.11.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e046edf639aa2e7afb285589e5405de2ef7e61d4b0ac1e30256e3eab911af9" +checksum = "aa1ae819b9870cadc959a052363de870944a1646932d274a4e270f64bf79e5ef" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.11.0-rc.3", + "digest 0.11.0-rc.4", ] [[package]] @@ -2780,13 +2770,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.11.0-rc.2" +version = "0.11.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1e3878ab0f98e35b2df35fe53201d088299b41a6bb63e3e34dada2ac4abd924" +checksum = "19d43dc0354d88b791216bb5c1bfbb60c0814460cc653ae0ebd71f286d0bd927" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.11.0-rc.3", + "digest 0.11.0-rc.4", ] [[package]] @@ -2846,12 +2836,12 @@ dependencies = [ [[package]] name = "signature" -version = "3.0.0-rc.4" +version = "3.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc280a6ff65c79fbd6622f64d7127f32b85563bca8c53cd2e9141d6744a9056d" +checksum = "2a0251c9d6468f4ba853b6352b190fb7c1e405087779917c238445eb03993826" dependencies = [ - "digest 0.11.0-rc.3", - "rand_core 0.9.3", + "digest 0.11.0-rc.4", + "rand_core 0.10.0-rc-2", ] [[package]] @@ -2944,7 +2934,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8baeff88f34ed0691978ec34440140e1572b68c7dd4a495fd14a3dc1944daa80" dependencies = [ "base64ct", - "der 0.8.0-rc.9", + "der 0.8.0-rc.10", ] [[package]] @@ -2967,9 +2957,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.109" +version = "2.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" dependencies = [ "proc-macro2", "quote", @@ -3014,7 +3004,7 @@ dependencies = [ "fastrand", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3589,7 +3579,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3812,18 +3802,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.27" +version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +checksum = "43fa6694ed34d6e57407afbccdeecfa268c470a7d2a5b0cf49ce9fcc345afb90" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.27" +version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26" dependencies = [ "proc-macro2", "quote", diff --git a/pumpkin-protocol/src/codec/velocity.rs b/pumpkin-protocol/src/codec/velocity.rs index 861c0923e..566ae0cc5 100644 --- a/pumpkin-protocol/src/codec/velocity.rs +++ b/pumpkin-protocol/src/codec/velocity.rs @@ -6,11 +6,15 @@ use serde::{Serialize, ser::Serializer}; #[derive(Clone, Copy)] pub struct Velocity(pub Vector3); +const MAX_VELOCITY_CLAMP: f64 = 1.7179869183E10; +const MIN_VELOCITY_MAGNITUDE: f64 = 3.051944088384301E-5; +const MAX_15_BIT_VALUE: f64 = 32766.0; + fn clamp_value(value: f64) -> f64 { if value.is_nan() { return 0.0; } - value.clamp(-1.7179869183E10, 1.7179869183E10) + value.clamp(-MAX_VELOCITY_CLAMP, MAX_VELOCITY_CLAMP) } fn abs_max(a: f64, b: f64) -> f64 { @@ -18,7 +22,7 @@ fn abs_max(a: f64, b: f64) -> f64 { } fn to_long(value: f64) -> i64 { - ((value * 0.5 + 0.5) * 32766.0).round() as i64 + ((value * 0.5 + 0.5) * MAX_15_BIT_VALUE).round() as i64 } impl Serialize for Velocity { @@ -30,35 +34,41 @@ impl Serialize for Velocity { let f = clamp_value(velocity.z); let g = abs_max(d, abs_max(e, f)); - if g < 0.00003051944088384301 { + if g < MIN_VELOCITY_MAGNITUDE { buf.push(0u8); return serializer.serialize_bytes(&buf); } + // l is the scale factor let l = g.ceil() as i64; - + // bl is true if the scale factor is > 3 and needs VarInt extension let bl = l > 3; + // m is the first byte of the packed data (low 3 bits of l + 4 if bl is true) let m = if bl { l & 3 | 4 } else { l }; - let n: i64 = to_long(d / l as f64) << 3; - let o: i64 = to_long(e / l as f64) << 18; - let p: i64 = to_long(f / l as f64) << 33; + // Quantize and shift the velocity components (15 bits each) + let n: i64 = to_long(d / l as f64) << 3; // X shifted 3 + let o: i64 = to_long(e / l as f64) << 18; // Y shifted 18 + let p: i64 = to_long(f / l as f64) << 33; // Z shifted 33 + // q is the packed 48-bit value (m + X + Y + Z) let q: i64 = m | n | o | p; + // 1. Write first byte (low 8 bits) buf.push(q as u8); + + // 2. Write second byte (bits 8-15) buf.push((q >> 8) as u8); - // This writes 4 bytes (an i32) for the remaining 48 bits of the i64 (q) - // Note: The Java logic is slightly unusual here, using only 6 bytes total (1+1+4) - // We write the remaining 32 bits of the 64-bit value 'q' as an i32 (4 bytes). - // Since we already used 2 bytes (0-15), we need 4 more bytes (16-47) - buf.extend_from_slice(&((q >> 16) as i32).to_le_bytes()); + // 3. Write remaining 4 bytes (bits 16-47) as a Big Endian i32 (Java's writeInt) + buf.extend_from_slice(&((q >> 16) as i32).to_be_bytes()); + // 4. Write VarInt for scale factor tail if needed if bl { VarInt::encode(&VarInt((l >> 2) as i32), &mut buf).unwrap(); } + serializer.serialize_bytes(&buf) } } diff --git a/pumpkin-protocol/src/java/client/play/explode.rs b/pumpkin-protocol/src/java/client/play/explode.rs index 48f9b3cd0..75181437b 100644 --- a/pumpkin-protocol/src/java/client/play/explode.rs +++ b/pumpkin-protocol/src/java/client/play/explode.rs @@ -9,23 +9,31 @@ use crate::{IdOr, SoundEvent, codec::var_int::VarInt}; #[packet(PLAY_EXPLODE)] pub struct CExplosion { pub center: Vector3, + pub radius: f32, + pub block_count: i32, pub knockback: Option>, pub particle: VarInt, pub sound: IdOr, + pub block_particles_pool_size: VarInt, } impl CExplosion { pub fn new( center: Vector3, + radius: f32, + block_count: i32, knockback: Option>, particle: VarInt, sound: IdOr, ) -> Self { Self { center, + radius, + block_count, knockback, particle, sound, + block_particles_pool_size: VarInt(0), } } } diff --git a/pumpkin-protocol/src/lib.rs b/pumpkin-protocol/src/lib.rs index 0581540f7..ae7594a5b 100644 --- a/pumpkin-protocol/src/lib.rs +++ b/pumpkin-protocol/src/lib.rs @@ -5,8 +5,6 @@ use std::{ task::{Context, Poll}, }; -// TODO: Wait for aes/crypto-common to update generic array -#[expect(deprecated)] use aes::cipher::{BlockDecryptMut, BlockEncryptMut, BlockSizeUser, generic_array::GenericArray}; use bytes::Bytes; use codec::var_int::VarInt; @@ -265,9 +263,6 @@ impl AsyncWrite for StreamEncryptor { // This should never panic out[0] = out_to_use; } else { - // This is a stream cipher, so this value must be used - // TODO: Wait for aes/crypto-common to update generic array - #[expect(deprecated)] let out_block = GenericArray::from_mut_slice(&mut out); cipher.encrypt_block_b2b_mut(block.into(), out_block); } diff --git a/pumpkin-world/Cargo.toml b/pumpkin-world/Cargo.toml index 32d7f7403..8c5a7749f 100644 --- a/pumpkin-world/Cargo.toml +++ b/pumpkin-world/Cargo.toml @@ -45,7 +45,7 @@ thread_local = "1.1.9" lru = "0.16.2" tokio-util = { version = "0.7.17", features = ["rt"] } -rand = "0.9.2" +rand = "=0.10.0-rc.5" num_cpus = "1.17.0" slotmap = "1.0.7" intrusive-collections = "0.9.7" diff --git a/pumpkin-world/src/level.rs b/pumpkin-world/src/level.rs index 55fb064ab..1b2489220 100644 --- a/pumpkin-world/src/level.rs +++ b/pumpkin-world/src/level.rs @@ -490,7 +490,7 @@ impl Level { block_entities: Vec::new(), }; - let mut rng = SmallRng::from_os_rng(); + let mut rng = SmallRng::from_rng(&mut rand::rng()); let chunks = self .loaded_chunks .iter() diff --git a/pumpkin/Cargo.toml b/pumpkin/Cargo.toml index a28b01f7e..48116707c 100644 --- a/pumpkin/Cargo.toml +++ b/pumpkin/Cargo.toml @@ -42,7 +42,7 @@ serde_json.workspace = true bytes.workspace = true -rand = "0.9" +rand = "=0.10.0-rc.5" num-bigint = "0.4" @@ -50,7 +50,7 @@ num-bigint = "0.4" rustyline-async = "0.4.7" # encryption -rsa = { version = "=0.10.0-rc.9", features = ["sha1"] } +rsa = { version = "=0.10.0-rc.10", features = ["sha1"] } rsa-der = "0.3" # authentication @@ -58,11 +58,11 @@ ureq = { version = "3.1.4", features = [ "json", ] } -sha1 = "=0.11.0-rc.2" +sha1 = "=0.11.0-rc.3" # velocity en -hmac = "=0.13.0-rc.2" -sha2 = "=0.11.0-rc.2" +hmac = "=0.13.0-rc.3" +sha2 = "=0.11.0-rc.3" base64 = "0.22.1" diff --git a/pumpkin/src/world/explosion.rs b/pumpkin/src/world/explosion.rs index 7f8243e59..dad0c1930 100644 --- a/pumpkin/src/world/explosion.rs +++ b/pumpkin/src/world/explosion.rs @@ -73,16 +73,17 @@ impl Explosion { map } - pub async fn explode(&self, world: &Arc) { + /// Returns the removed block count + pub async fn explode(&self, world: &Arc) -> u32 { let blocks = self.get_blocks_to_destroy(world).await; // TODO: Entity damage, fire - for (pos, (block, state)) in blocks { + for (pos, (block, state)) in &blocks { if state.is_air() { continue; } let pumpkin_block = world.block_registry.get_pumpkin_block(block); - world.set_block_state(&pos, 0, BlockFlags::NOTIFY_ALL).await; + world.set_block_state(pos, 0, BlockFlags::NOTIFY_ALL).await; if pumpkin_block.is_none_or(|s| s.should_drop_items_on_explosion()) { let params = LootContextParameters { @@ -90,17 +91,18 @@ impl Explosion { explosion_radius: Some(self.power), ..Default::default() }; - drop_loot(world, block, &pos, false, params).await; + drop_loot(world, block, pos, false, params).await; } if let Some(pumpkin_block) = pumpkin_block { pumpkin_block .explode(ExplodeArgs { world, block, - position: &pos, + position: pos, }) .await; } } + blocks.len() as u32 } } diff --git a/pumpkin/src/world/mod.rs b/pumpkin/src/world/mod.rs index 93ce5c532..df1f086ba 100644 --- a/pumpkin/src/world/mod.rs +++ b/pumpkin/src/world/mod.rs @@ -1768,7 +1768,7 @@ impl World { pub async fn explode(self: &Arc, position: Vector3, power: f32) { let explosion = Explosion::new(power, position); - explosion.explode(self).await; + let block_count = explosion.explode(self).await; let particle = if power < 2.0 { Particle::Explosion } else { @@ -1783,6 +1783,8 @@ impl World { .client .enqueue_packet(&CExplosion::new( position, + power, + block_count as i32, None, VarInt(particle as i32), sound.clone(),