Random (0, 1) doesnt really work

Started by Pepper on

Topic category: Help with modding (Java Edition)

Last seen on 23:12, 13. Aug 2023
Joined Nov 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Random (0, 1) doesnt really work
Sat, 05/08/2021 - 21:43 (edited)

I have been trying to make every mob drop these hearts that heal you (and that works) and i made the possibility to drop 1 or 2 hearts (which also works) BUT for some reason, i cant make it drop NO hearts. its always either a heart or the golden heart. please help me.heres the image

Edited by Pepper on Sat, 05/08/2021 - 21:43
Last seen on 07:12, 23. Jun 2021
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Don't know if it's the cause…
Fri, 05/07/2021 - 17:14

Don't know if it's the cause, but the golden heart's "Else If" you put tells the game to drop the golden heart when the number is above 0.01, which is common enough to happen once in 100 kills, shouldn't be the other way around? instead of > it should be <.

Last seen on 00:59, 19. Oct 2022
Joined Feb 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I will tell you 3 things: -…
Fri, 05/07/2021 - 20:38

I will tell you 3 things:
- every time you use random give it a different value, if you want the whole procedure to use the same value of "random" use local variable.
- The delay time is how long the gem will be on the ground, if you set it to one it will disappear very fast.
- do not use "if" inside "if" because it causes errors.

Last seen on 23:12, 13. Aug 2023
Joined Nov 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Donagao, can you clarify?…
Fri, 05/07/2021 - 21:10

Donagao, can you clarify? also the delay time is how long it takes before you can pick it up, and the ifs inside of ifs work just fine for me.

Last seen on 04:19, 17. Apr 2024
Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Every time the procedure…
Fri, 05/28/2021 - 14:18

Every time the procedure runs into a Random (0, 1] block, it picks an entirely new value for it. It does not save the value for the first random block it found. So essentially each drop possibility is being tested from a different number. What you need to do instead is create a variable, call it whatever you want. Then at the beginning of the procedure, set it to Random (0, 1]. Then use the variable itself instead of the regular Random blocks in your conditions.

Last seen on 09:42, 5. Sep 2023
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
  Some of those random…
Sat, 05/29/2021 - 06:54

 

Some of those random blocks are probable not even firing off.