Skip to main content
1 of 7
MrLemon
  • 17.4k
  • 6
  • 60
  • 83

The simplest solution is not to use an actual random generator at all, because it's not really needed. The randomness can come from a user input instead.

What I mean by that is that you can have a rapidly changing scoreboard objective, and evaluate the score at the moment a button is pressed. Using a fill clock, the randomness

First set up your randomness objective using

scoreboard objectives add RNG stat.playOneMinute

Using stat.playOneMinute will automatically increase it by 1 every single game tick without another command needed, and it will not be the same for every player (if that is not desired, resetting it for everyone works).

Now create a fill/setblock clock and have it run

scoreboard players set @a[score_RNG_min=9] 0

and you're done. To use your random numbers, make one command block for every single outcome and include [score_RNG=X,score_RNG_min=X] with your target selector arguments, where X is the score to use, running from 0 to 8(!). Trigger all of these at the same time. For example

...
/give @a[score_RNG=4,score_RNG_min=4,team=PlayingTheGame] diamond_sword 
/give @a[score_RNG=5,score_RNG_min=5,team=PlayingTheGame] dirt
...

If your command does not use a target selector argument, you can (ab)use execute for that, e.g.

/execute @a[score_RNG=4,score_RNG_min=4] ~ ~ ~ setblock 1 2 3 stone
MrLemon
  • 17.4k
  • 6
  • 60
  • 83