Topic category: Feature requests and ideas for MCreator
I have been using a piece of code for a while, and I'm starting to get a lot of locked code elements, making me worried for when Mcreator moves to 1.16 or 1.17 that I will have to re-do everything.
Could you add a 'choose random number from _ to _' procedure block?
Code looks like this:
import java.util.concurrent.ThreadLocalRandom;
ThreadLocalRandom var1 = ThreadLocalRandom.current();
var2 = (int) var1.nextInt(3, 6); //pick random number from 3 to 5
I have used this code in so many different things. Like item spawning amount, structure height offset (I don't expect this one to be added), Spawning location, picking a random block to place, etc... I feel as if this would be very useful for modders. We already have the Math.random() function but we have to use a lot of if/else if statements, and are restricted to 0 - 1.
There is also the other random.nextInt() function, but that always starts at 0 to set number. (We can't set negatives with this)
Along with this, can we decide when creating a NUMBER variable to choose whether it is an Integer or a Double?
You can use existing random block for this.
RANDOM * A + B
Where B = min. value and A = max. value - min. value
Thank you! I didn't think of that
Like this?
Picture
Actually ignore that last post, I did some testing and just did RANDOM * Number then rounded it to remove the decimals.
(omg, I'm spamming now)
Every time I post I run into a problem and have to post again
When I do RANDOM * min + (max - min) I still get values like 0 or 1 even when min is set to 2.
FINAL POST I SWEAR
I fixed it after extensive testing and a little bit of researching. Initially I had trouble getting the values in the range I wanted. I did that but they were unbalanced. I then fixed that and ta-da! A probably inefficient but working piece of code!
Here it is for any future people in need