"Random number between two values" procedure block

Published by aidanete on
Status
Works as designed
Issue description

I searched for this in the tracker, but I didn't find anything. I also tried to find somehow to do this, but most ways are inefficient.

My idea is a procedure block that returns a value between two selected values. For example, in a 10% chance, a sound is played from 3 different sounds, to select the sound, a variable is set to a random number from 1 to 3. Depending on the result, the sound is selected.

Issue comments

MCreator generates numbers between 0 and 1 as any number generator. If you multiply this random value by 3, you get the values between 0 and 3. To split this in three cases, check if this new multiplied value is between 0 and 1 for the first value, 1 and 2 for the second and 2 and 3 for the third.