Started by
titanicslimeocean
on
Topic category: Help with Minecraft modding (Java Edition)
Im trying to make a Pokemon Pack mod with you crafting packs and then opening them with a right click which gives you a random rare card but I don't know how to generate a random item (with probabilties) and I'm still fairly new so I would like a detailed explanation
bump
Create a new procedure for your item with the "when right-clicked" trigger.
Check if the world is client-side. If it isn’t, the procedure continues. This check is necessary to prevent the procedure from triggering multiple times per right-click.
Perform the probability checks. The condition 'if random number between 0 and 1 < X' acts as our probability check, where X represents an X% chance of the player receiving the item.
(For example: 0.2 gives a 20% chance, 0.3 gives a 30% chance, 0.4 gives a 40% chance, and so on.)
In this example, I set the probability of the player receiving a copper ingot to 70%, by checking if the random number generated is less than 7.
Next, I set the probability of the player receiving an iron ingot to 50%, by checking if the number generated is less than 5.
The same goes for the gold ingot and diamond... Gold ingot has a 30%, and diamond has 10%.
ptpl file: https://www.mediafire.com/file/izibekncnp7tthi/GiveRandomItemWithProbabilties.ptpl/file