Random Number From 2 Set Values

Started by eithanz on

Topic category: Help with Minecraft modding (Java Edition)

Joined May 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Random Number From 2 Set Values

hey so i have a code for when you break a block with a certain tool, you get instead of the block a random number of another item, but i cant seem to get a code of

a random number so i can give the player 1-3 of the other item

if someone could help me by sending a code example of how to make a random number from 1-X it would be AMAZING

ty 

Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you want it to drop 1-3…
Sat, 11/02/2019 - 12:10

If you want it to drop 1-3 of the item then you will need to use random[0,1]. Make a local variable and set it to random[0,1], Then make 3 if statements with if the local variable is over a certain amount (0, 0.333, 0.666 should work) then spawn a 'gem' of the specified item for each of them.

Joined May 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ty  
Sat, 11/02/2019 - 15:17

ty

 

Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You're welcome.
Mon, 11/04/2019 - 08:45

You're welcome.

Joined Dec 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have another method…
Mon, 11/04/2019 - 12:01

I have another method

Imagine _i is the resulting value

set _i to (round up ((random 0,1)*3))

Then check for _i if its 1 or 2 or 3.