Skip to content

Commit a57d69e

Browse files
committed
Fixed ClosedRange random
1 parent 0fca8d6 commit a57d69e

File tree

1 file changed

+2
-1
lines changed
  • src/main/kotlin/com/lambda/util/math

1 file changed

+2
-1
lines changed

src/main/kotlin/com/lambda/util/math/Linear.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import net.minecraft.util.math.Vec3d
2323
import java.awt.Color
2424
import kotlin.math.max
2525
import kotlin.math.min
26+
import kotlin.random.Random
2627
import kotlin.random.Random.Default.nextDouble
2728

2829
/**
@@ -46,7 +47,7 @@ fun ClosedRange<Float>.step(step: Float) = object : FloatIterator() {
4647
/**
4748
* Returns a random number within the range.
4849
*/
49-
fun ClosedRange<Double>.random() = nextDouble(start, endInclusive)
50+
fun ClosedRange<Double>.random(random: Random = Random) = start + (endInclusive - start) * random.nextDouble()
5051

5152
/**
5253
* Converts a value from one range to a normalized value between 0 and 1.

0 commit comments

Comments
 (0)