Started by
Sagicraft
on
Topic category: Help with Minecraft modding (Java Edition)
hello! i need some help with my lootbags. Right now it works BUT it gives me more than one item at a time. How to I make it so it only gives me ONE random item instead of 1-3 random item each time.
( all the items and black orb are placeholders)
Edited by Sagicraft on Tue, 05/03/2022 - 23:57
Set in your Random number into a local number variable (vNum).
If vNum < 0.10 do ~
Else If vNum < 0.15 do ~
Else If vNum < 0.24 do ~
Else If vNum < 0.34 do ~
i dont quite understand. what should i replace ?
he means to set the random value to a local variable and from there compare the probabilities
You want to use a single [Random] to choose which item is selected. Using a local variable "locks in" the roll so you can use the same value for all your comparisons. If you don't do that, each time you do a check, a different random number would be generated.
Alternatively, you can use a loot table instead and execute the /summon loot command. It would allow easier alteration of the loot bag for use with other mods.
Use IF / ELSE not only IF / DO and you're done