pub struct LegacyRandom {
seed: i64,
next_gaussian: Option<f64>,
}Expand description
Legacy Minecraft random number generator based on a Linear Congruential Generator (LCG).
This implementation mirrors Java’s java.util.Random which Minecraft originally used.
Fields§
§seed: i64§next_gaussian: Option<f64>Implementations§
Source§impl LegacyRandom
impl LegacyRandom
Sourcepub const fn from_seed(seed: u64) -> Self
pub const fn from_seed(seed: u64) -> Self
Creates a new LegacyRandom instance from the given seed.
The seed is XORed with the LCG multiplier and masked to 48 bits, matching Java’s behavior.
Sourcepub const fn set_seed(&mut self, seed: i64)
pub const fn set_seed(&mut self, seed: i64)
Re-seeds this generator, matching Java’s Random.setSeed.
Sourcepub fn set_large_feature_seed(&mut self, seed: i64, chunk_x: i32, chunk_z: i32)
pub fn set_large_feature_seed(&mut self, seed: i64, chunk_x: i32, chunk_z: i32)
Matches vanilla’s WorldgenRandom.setLargeFeatureSeed.
Sourcepub fn set_large_feature_with_salt(
&mut self,
seed: i64,
x: i32,
z: i32,
salt: i32,
)
pub fn set_large_feature_with_salt( &mut self, seed: i64, x: i32, z: i32, salt: i32, )
Matches vanilla’s WorldgenRandom.setLargeFeatureWithSalt.
const fn next(&mut self, bits: u64) -> i32
const fn next_random(&mut self) -> i64
Trait Implementations§
Source§impl From<LegacyRandom> for RandomSource
impl From<LegacyRandom> for RandomSource
Source§fn from(v: LegacyRandom) -> RandomSource
fn from(v: LegacyRandom) -> RandomSource
Converts to this type from the input type.
Source§impl MarsagliaPolarGaussian for LegacyRandom
impl MarsagliaPolarGaussian for LegacyRandom
Source§fn stored_next_gaussian(&self) -> Option<f64>
fn stored_next_gaussian(&self) -> Option<f64>
Gets the stored next gaussian.
Source§fn set_stored_next_gaussian(&mut self, value: Option<f64>)
fn set_stored_next_gaussian(&mut self, value: Option<f64>)
Sets the stored next gaussian.
Source§fn calculate_gaussian(&mut self) -> f64
fn calculate_gaussian(&mut self) -> f64
Calculates the next gaussian.
Source§impl Random for LegacyRandom
impl Random for LegacyRandom
fn fork(&mut self) -> Self
fn next_i32(&mut self) -> i32
fn next_i32_bounded(&mut self, bound: i32) -> i32
fn next_i64(&mut self) -> i64
fn next_f32(&mut self) -> f32
fn next_f64(&mut self) -> f64
fn next_bool(&mut self) -> bool
fn next_gaussian(&mut self) -> f64
fn next_positional(&mut self) -> RandomSplitter
fn next_i32_between(&mut self, min: i32, max: i32) -> i32
fn next_i32_between_exclusive(&mut self, min: i32, max: i32) -> i32
fn triangle(&mut self, min: f64, max: f64) -> f64
fn triangle_f32(&mut self, min: f32, max: f32) -> f32
fn consume_count(&mut self, count: i32)
Source§impl TryInto<LegacyRandom> for RandomSource
impl TryInto<LegacyRandom> for RandomSource
Auto Trait Implementations§
impl Freeze for LegacyRandom
impl RefUnwindSafe for LegacyRandom
impl Send for LegacyRandom
impl Sync for LegacyRandom
impl Unpin for LegacyRandom
impl UnsafeUnpin for LegacyRandom
impl UnwindSafe for LegacyRandom
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more