Random variable value generation within mining blocks

Started by ScareCrow1226 on Wed, 11/09/2016 - 20:30

Topic category: Help with modding (Java Edition)

Last seen on 21:09, 9. Nov 2016
Joined Dec 2015
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Random variable value generation within mining blocks
Wed, 11/09/2016 - 20:30

Okay, So i have a basic level of programing knowledge but am new to the software. 

What im trying to do is have a "random" chance of obtaining a new item called a "Jewel" when mining for coal. So i have two varriables set ... first i have JewelRarity which has a default value of 10. I also have a JewelChance which has a default value of 1. 

Number JewelRarity = 10 

Number JewelChance = 1 

So when a player mines coal, they get coal but i also want it to generate a random number between 1 and 10 (JewelRarity.) If this number equals 1 (Jewel Chance.) then the player will also get  an Item a "Jewel."

I understand that i will probably need a third varriable for the random value to be assinged to before it can be compared to JewelChance. Im struggling with finding a way to have a varriable be a random number that is generated unique with each block of coal mined. 

Any Advice would be very much appreciated 

Last seen on 08:29, 18. Sep 2019
Joined Dec 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I do not know if you want a
Wed, 11/09/2016 - 20:41

I do not know if you want a specific response to what you have. But, you could use the event "When block destroyed by player" then use a stack event and use "RandomPossibility X%" then add another stacked "Spawn Gem" and choose the jewel.

This will make it so each time you break the block there will be x% chance to also drop a jewel. Very similiar to what you want, but not the exact same.

Last seen on 21:09, 9. Nov 2016
Joined Dec 2015
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
RE:I do not know if you want a
Wed, 11/09/2016 - 20:55

@#1 That should work fine, I understand the first process ive been playing with "When block is destroyed by player" and i understand the "Spawn Gem" ... its the "RandomPossibility x%" that i am not sure how to accomplish

Thank you for your prompt response 

Last seen on 08:29, 18. Sep 2019
Joined Dec 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Here is a Video I just
Wed, 11/09/2016 - 22:10

Here is a Video I just uploaded to help you. If you have any more question feel free to ask. :)
https://youtu.be/veF5QOzVTd4