From 19e405d4f4fb17eb9c51081fdb6db9e525494b20 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Mar 2025 14:18:11 +0700 Subject: [PATCH] Use RandomGenerator methods when available --- src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt index 50130a208..6661fc996 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -660,12 +660,18 @@ fun RandomSource.nextNormalDouble(stddev: Double, mean: Double): Double { } fun RandomSource.nextFloat(min: Float, max: Float): Float { + if (this is RandomGenerator) + return nextFloat(min, max) + require(max >= min) { "Min is bigger than max: $min vs $max" } if (min == max) return min return min + nextFloat() * (max - min) } fun RandomSource.nextDouble(min: Double, max: Double): Double { + if (this is RandomGenerator) + return nextDouble(min, max) + require(max >= min) { "Min is bigger than max: $min vs $max" } if (min == max) return min return min + nextDouble() * (max - min)