port to rand 9

again
This commit is contained in:
Alexander Medvedev
2025-06-12 20:53:44 +02:00
parent c253b0902c
commit 2edb986f61
14 changed files with 162 additions and 152 deletions

249
Cargo.lock generated
View File

@@ -174,6 +174,12 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "base16ct"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
[[package]]
name = "base64"
version = "0.22.1"
@@ -207,18 +213,21 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block-buffer"
version = "0.11.0-rc.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a229bfd78e4827c91b9b95784f69492c1b77c1ab75a45a8a037b139215086f94"
dependencies = [
"hybrid-array",
]
[[package]]
name = "bumpalo"
version = "3.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
version = "1.10.1"
@@ -317,7 +326,7 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
dependencies = [
"crypto-common",
"crypto-common 0.1.6",
"inout",
]
@@ -363,9 +372,9 @@ dependencies = [
[[package]]
name = "const-oid"
version = "0.9.6"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
checksum = "0dabb6555f92fb9ee4140454eb5dcd14c7960e1225c6d1a6cc361f032947713e"
[[package]]
name = "convert_case"
@@ -534,6 +543,19 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-bigint"
version = "0.7.0-pre.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edaae5fb9dac79a07260e0b2006799ff4f1d342ab243fd7d0892215113b27904"
dependencies = [
"num-traits",
"rand_core",
"serdect",
"subtle",
"zeroize",
]
[[package]]
name = "crypto-common"
version = "0.1.6"
@@ -544,6 +566,26 @@ dependencies = [
"typenum",
]
[[package]]
name = "crypto-common"
version = "0.2.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a23fa214dea9efd4dacee5a5614646b30216ae0f05d4bb51bafb50e9da1c5be"
dependencies = [
"hybrid-array",
]
[[package]]
name = "crypto-primes"
version = "0.7.0-pre.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae744b9f528151f8c440cf67498f24d2d1ac0ab536b5ce7b1f87a7a5961bd1c1"
dependencies = [
"crypto-bigint",
"libm",
"rand_core",
]
[[package]]
name = "dashmap"
version = "6.1.0"
@@ -560,9 +602,9 @@ dependencies = [
[[package]]
name = "der"
version = "0.7.10"
version = "0.8.0-rc.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"
checksum = "0c2e6107818886eff6b71fba7a2da3dd11025ebb80f0c9b94ff961168ef629f2"
dependencies = [
"const-oid",
"pem-rfc7468",
@@ -632,9 +674,19 @@ version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"block-buffer 0.10.4",
"crypto-common 0.1.6",
]
[[package]]
name = "digest"
version = "0.11.0-rc.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "460dd7f37e4950526b54a5a6b1f41b6c8e763c58eb9a8fc8fc05ba5c2f44ca7b"
dependencies = [
"block-buffer 0.11.0-rc.4",
"const-oid",
"crypto-common",
"crypto-common 0.2.0-rc.3",
"subtle",
]
@@ -991,11 +1043,11 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hmac"
version = "0.12.1"
version = "0.13.0-rc.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
checksum = "8dc6a2fcc35ab09136c6df2cdf9ca49790701420a3a6b5db0987dddbabc79b21"
dependencies = [
"digest",
"digest 0.11.0-rc.0",
]
[[package]]
@@ -1038,6 +1090,15 @@ version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
[[package]]
name = "hybrid-array"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "891d15931895091dea5c47afa5b3c9a01ba634b311919fd4d41388fa0e3d76af"
dependencies = [
"typenum",
]
[[package]]
name = "hyper"
version = "1.6.0"
@@ -1356,9 +1417,6 @@ name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
dependencies = [
"spin",
]
[[package]]
name = "libc"
@@ -1457,7 +1515,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
dependencies = [
"cfg-if",
"digest",
"digest 0.10.7",
]
[[package]]
@@ -1510,23 +1568,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-bigint-dig"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151"
dependencies = [
"byteorder",
"lazy_static",
"libm",
"num-integer",
"num-iter",
"num-traits",
"rand 0.8.5",
"smallvec",
"zeroize",
]
[[package]]
name = "num-conv"
version = "0.1.0"
@@ -1553,17 +1594,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.19"
@@ -1571,7 +1601,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
"libm",
]
[[package]]
@@ -1635,9 +1664,9 @@ dependencies = [
[[package]]
name = "pem-rfc7468"
version = "0.7.0"
version = "1.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412"
checksum = "a8e58fab693c712c0d4e88f8eb3087b6521d060bcaf76aeb20cb192d809115ba"
dependencies = [
"base64ct",
]
@@ -1690,7 +1719,7 @@ checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0"
dependencies = [
"once_cell",
"pest",
"sha2",
"sha2 0.10.9",
]
[[package]]
@@ -1727,9 +1756,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkcs1"
version = "0.7.5"
version = "0.8.0-rc.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f"
checksum = "24e16d93c725fa250577ffdec06ebbff4cae3625b0e2881ac43a5427797ee8d3"
dependencies = [
"der",
"pkcs8",
@@ -1738,9 +1767,9 @@ dependencies = [
[[package]]
name = "pkcs8"
version = "0.10.2"
version = "0.11.0-rc.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
checksum = "3f1843d4345dfe1a55e487db747a04c01af50415b03e937410e0a41d8cc24ec7"
dependencies = [
"der",
"spki",
@@ -1868,7 +1897,7 @@ dependencies = [
"pumpkin-registry",
"pumpkin-util",
"pumpkin-world",
"rand 0.8.5",
"rand",
"rayon",
"reqwest",
"rsa",
@@ -1878,7 +1907,7 @@ dependencies = [
"serde",
"serde_json",
"sha1",
"sha2",
"sha2 0.11.0-rc.0",
"simplelog",
"tauri-winres",
"tempfile",
@@ -2014,7 +2043,7 @@ dependencies = [
"proc-macro2",
"pumpkin-nbt",
"quote",
"rand 0.9.1",
"rand",
"serde",
"serde_json",
"syn",
@@ -2054,7 +2083,7 @@ dependencies = [
"serde",
"serde_json",
"serde_json5",
"sha2",
"sha2 0.10.9",
"temp-dir",
"thiserror",
"thread_local",
@@ -2093,7 +2122,7 @@ dependencies = [
"bytes",
"getrandom 0.3.3",
"lru-slab",
"rand 0.9.1",
"rand",
"ring",
"rustc-hash 2.1.1",
"rustls",
@@ -2134,35 +2163,14 @@ version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha 0.3.1",
"rand_core 0.6.4",
]
[[package]]
name = "rand"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
dependencies = [
"rand_chacha 0.9.0",
"rand_core 0.9.3",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core 0.6.4",
"rand_chacha",
"rand_core",
]
[[package]]
@@ -2172,16 +2180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core 0.9.3",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom 0.2.16",
"rand_core",
]
[[package]]
@@ -2306,18 +2305,17 @@ dependencies = [
[[package]]
name = "rsa"
version = "0.9.8"
version = "0.10.0-rc.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b"
checksum = "f30f0ad781aea19fe741d7a901b2ad8b4271ac3516e7045b8ecff74e201968fe"
dependencies = [
"const-oid",
"digest",
"num-bigint-dig",
"num-integer",
"num-traits",
"crypto-bigint",
"crypto-primes",
"digest 0.11.0-rc.0",
"pkcs1",
"pkcs8",
"rand_core 0.6.4",
"rand_core",
"sha1",
"signature",
"spki",
@@ -2522,14 +2520,24 @@ dependencies = [
]
[[package]]
name = "sha1"
version = "0.10.6"
name = "serdect"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
checksum = "f42f67da2385b51a5f9652db9c93d78aeaf7610bf5ec366080b6de810604af53"
dependencies = [
"base16ct",
"serde",
]
[[package]]
name = "sha1"
version = "0.11.0-rc.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f9318facddf9ac32a33527066936837e189b3f23ced6edc1603720ead5e2b3d"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
"digest 0.11.0-rc.0",
]
[[package]]
@@ -2540,7 +2548,18 @@ checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
"digest 0.10.7",
]
[[package]]
name = "sha2"
version = "0.11.0-rc.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa1d2e6b3cc4e43a8258a9a3b17aa5dfd2cc5186c7024bba8a64aa65b2c71a59"
dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.11.0-rc.0",
]
[[package]]
@@ -2581,12 +2600,12 @@ dependencies = [
[[package]]
name = "signature"
version = "2.2.0"
version = "3.0.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
checksum = "b8852cecbd17ba45978bbbe43061ebe36a2ae376058c5c172e09f72888f8f7de"
dependencies = [
"digest",
"rand_core 0.6.4",
"digest 0.11.0-rc.0",
"rand_core",
]
[[package]]
@@ -2644,17 +2663,11 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "spki"
version = "0.7.3"
version = "0.8.0-rc.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
checksum = "c2f0e2bdca9b00f5be6dd3bb6647d50fd0f24a508a95f78e3bb2fe98d0403c85"
dependencies = [
"base64ct",
"der",

View File

@@ -42,7 +42,7 @@ serde_json.workspace = true
bytes.workspace = true
rand = "0.8"
rand = "0.9"
num-bigint = "0.4"
@@ -50,7 +50,7 @@ num-bigint = "0.4"
rustyline-async = "0.4.6"
# encryption
rsa = { version = "0.9", features = ["sha1"] }
rsa = { version = "=0.10.0-rc.0", features = ["sha1"] }
rsa-der = "0.3"
# authentication
@@ -61,11 +61,11 @@ reqwest = { version = "0.12", default-features = false, features = [
"rustls-tls",
] }
sha1 = "0.10"
sha1 = "=0.11.0-rc.0"
# velocity en
hmac = "0.12"
sha2 = "0.10"
hmac = "=0.13.0-rc.0"
sha2 = "=0.11.0-rc.0"
base64 = "0.22"

View File

@@ -29,7 +29,7 @@ pub struct FireBlock;
impl FireBlock {
#[must_use]
pub fn get_fire_tick_delay() -> i32 {
30 + rand::thread_rng().gen_range(0..10)
30 + rand::rng().random_range(0..10)
}
}
@@ -84,7 +84,7 @@ impl PumpkinBlock for FireBlock {
if ticks < 0 {
base_entity.fire_ticks.store(ticks + 1, Ordering::Relaxed);
} else if base_entity.entity_type == EntityType::PLAYER {
let rnd_ticks = rand::thread_rng().gen_range(1..3);
let rnd_ticks = rand::rng().random_range(1..3);
base_entity
.fire_ticks
.store(ticks + rnd_ticks, Ordering::Relaxed);

View File

@@ -98,7 +98,7 @@ impl PumpkinBlock for TNTBlock {
entity
.set_velocity(Vector3::new(-angle.sin() * 0.02, 0.2, -angle.cos() * 0.02))
.await;
let fuse = rand::thread_rng().gen_range(0..DEFAULT_FUSE / 4) + DEFAULT_FUSE / 8;
let fuse = rand::rng().random_range(0..DEFAULT_FUSE / 4) + DEFAULT_FUSE / 8;
let tnt = Arc::new(TNTEntity::new(entity, DEFAULT_POWER, fuse));
world.spawn_entity(tnt).await;
}

View File

@@ -160,9 +160,9 @@ impl LootFunctionNumberProviderExt for LootFunctionNumberProvider {
fn generate(&self) -> f32 {
match self {
Self::Constant { value } => *value,
Self::Uniform { min, max } => rand::thread_rng().gen_range(*min..=*max),
Self::Uniform { min, max } => rand::rng().random_range(*min..=*max),
Self::Binomial { n, p } => (0..n.floor() as u32).fold(0.0, |c, _| {
if rand::thread_rng().gen_bool(f64::from(*p)) {
if rand::rng().random_bool(f64::from(*p)) {
c + 1.0
} else {
c

View File

@@ -204,9 +204,9 @@ pub async fn drop_loot(
async fn drop_stack(world: &Arc<World>, pos: &BlockPos, stack: ItemStack) {
let height = EntityType::ITEM.dimension[1] / 2.0;
let pos = Vector3::new(
f64::from(pos.0.x) + 0.5 + rand::thread_rng().gen_range(-0.25..0.25),
f64::from(pos.0.y) + 0.5 + rand::thread_rng().gen_range(-0.25..0.25) - f64::from(height),
f64::from(pos.0.z) + 0.5 + rand::thread_rng().gen_range(-0.25..0.25),
f64::from(pos.0.x) + 0.5 + rand::rng().random_range(-0.25..0.25),
f64::from(pos.0.y) + 0.5 + rand::rng().random_range(-0.25..0.25) - f64::from(height),
f64::from(pos.0.z) + 0.5 + rand::rng().random_range(-0.25..0.25),
);
let entity = world.create_entity(pos, EntityType::ITEM);

View File

@@ -1,7 +1,7 @@
use async_trait::async_trait;
use pumpkin_data::sound::SoundCategory;
use pumpkin_util::text::TextComponent;
use rand::{Rng, thread_rng};
use rand::{Rng, rng};
use crate::command::{
CommandError, CommandExecutor, CommandSender,
@@ -109,7 +109,7 @@ impl CommandExecutor for Executor {
};
// Use same random seed for all targets to ensure sound synchronization
let seed = thread_rng().r#gen::<f64>();
let seed = rng().random::<f64>();
// Track how many players actually received the sound
let mut players_who_heard = 0;

View File

@@ -7,7 +7,7 @@ use std::{
};
use bytes::{BufMut, BytesMut};
use hmac::{Hmac, Mac};
use hmac::{Hmac, KeyInit, Mac};
use pumpkin_config::networking::proxy::VelocityConfig;
use pumpkin_protocol::{
Property, client::login::CLoginPluginRequest, ser::NetworkReadExt,
@@ -48,7 +48,7 @@ pub enum VelocityError {
pub async fn velocity_login(client: &Client) {
// TODO: Validate the packet transaction id from the plugin response with this
let velocity_message_id: i32 = rand::thread_rng().r#gen();
let velocity_message_id: i32 = rand::rng().random();
let mut buf = BytesMut::new();
buf.put_u8(MAX_SUPPORTED_FORWARDING_VERSION);

View File

@@ -90,7 +90,7 @@ async fn handle_packet(
match raw_packet.packet_type {
PacketType::Handshake => {
if let Ok(packet) = SHandshake::decode(&mut raw_packet).await {
let challenge_token = rand::thread_rng().gen_range(1..=i32::MAX);
let challenge_token = rand::rng().random_range(1..=i32::MAX);
let response = CHandshake {
session_id: packet.session_id,
challenge_token,

View File

@@ -1,6 +1,5 @@
use num_bigint::BigInt;
use pumpkin_protocol::client::login::CEncryptionRequest;
use rand::rngs::OsRng;
use rsa::{Pkcs1v15Encrypt, RsaPrivateKey, traits::PublicKeyParts as _};
use sha1::Sha1;
use sha2::Digest;
@@ -19,8 +18,8 @@ impl KeyStore {
let private_key = Self::generate_private_key();
let public_key_der = rsa_der::public_key_to_der(
&private_key.n().to_bytes_be(),
&private_key.e().to_bytes_be(),
&private_key.n().to_be_bytes(),
&private_key.e().to_be_bytes(),
)
.into_boxed_slice();
Self {
@@ -31,7 +30,7 @@ impl KeyStore {
fn generate_private_key() -> RsaPrivateKey {
// Found out that OsRng is faster than rand::thread_rng here
let mut rng = OsRng;
let mut rng = rand::rng();
// let pub_key = RsaPublicKey::from(&priv_key);
RsaPrivateKey::new(&mut rng, 1024).expect("Failed to generate a key")

View File

@@ -31,7 +31,7 @@ use pumpkin_world::world_info::anvil::{
AnvilLevelInfo, LEVEL_DAT_BACKUP_FILE_NAME, LEVEL_DAT_FILE_NAME,
};
use pumpkin_world::world_info::{LevelData, WorldInfoError, WorldInfoReader, WorldInfoWriter};
use rand::prelude::SliceRandom;
use rand::seq::IndexedRandom;
use rsa::RsaPublicKey;
use std::fs;
use std::net::IpAddr;
@@ -497,7 +497,7 @@ impl Server {
pub async fn get_random_player(&self) -> Option<Arc<Player>> {
let players = self.get_all_players().await;
players.choose(&mut rand::thread_rng()).map(Arc::<_>::clone)
players.choose(&mut rand::rng()).map(Arc::<_>::clone)
}
/// Searches for a player by their UUID across all worlds.

View File

@@ -1,6 +1,6 @@
use chrono::{Datelike, Local};
use pumpkin_config::advanced_config;
use rand::{seq::SliceRandom, thread_rng};
use rand::{rng, seq::SliceRandom};
// In fact Mojang also has some Seasonal Events, so we can use that later to match Vanilla :D
@@ -19,7 +19,7 @@ pub fn modify_chat_message(message: &str) -> Option<String> {
if words.is_empty() {
return None;
}
let mut rng = thread_rng();
let mut rng = rng();
words.shuffle(&mut rng);
let result = words.join(" ");
Some(result)

View File

@@ -81,7 +81,7 @@ use pumpkin_world::{
world::GetBlockError,
};
use pumpkin_world::{world::BlockFlags, world_info::LevelData};
use rand::{Rng, thread_rng};
use rand::{Rng, rng};
use scoreboard::Scoreboard;
use serde::Serialize;
use time::LevelTime;
@@ -366,7 +366,7 @@ impl World {
volume: f32,
pitch: f32,
) {
let seed = thread_rng().r#gen::<f64>();
let seed = rng().random::<f64>();
let packet = CSoundEffect::new(IdOr::Id(sound_id), category, position, volume, pitch, seed);
self.broadcast_packet_all(&packet).await;
}

View File

@@ -139,10 +139,9 @@ impl Weather {
}
} else if self.thundering {
self.thunder_time =
rand::thread_rng().gen_range(THUNDER_DURATION_MIN..=THUNDER_DURATION_MAX);
rand::rng().random_range(THUNDER_DURATION_MIN..=THUNDER_DURATION_MAX);
} else {
self.thunder_time =
rand::thread_rng().gen_range(THUNDER_DELAY_MIN..=THUNDER_DELAY_MAX);
self.thunder_time = rand::rng().random_range(THUNDER_DELAY_MIN..=THUNDER_DELAY_MAX);
}
// Handle rain timing
@@ -152,10 +151,9 @@ impl Weather {
self.raining = !self.raining;
}
} else if self.raining {
self.rain_time =
rand::thread_rng().gen_range(RAIN_DURATION_MIN..=RAIN_DURATION_MAX);
self.rain_time = rand::rng().random_range(RAIN_DURATION_MIN..=RAIN_DURATION_MAX);
} else {
self.rain_time = rand::thread_rng().gen_range(RAIN_DELAY_MIN..=RAIN_DELAY_MAX);
self.rain_time = rand::rng().random_range(RAIN_DELAY_MIN..=RAIN_DELAY_MAX);
}
}
}