Started by
sn4p
on
Topic category: Help with Minecraft modding (Java Edition)
Hi,
I want to create a system where opening a pack gives the player 6 random items from a pool of 20 available ones. Duplicates should sometimes occur, but not always I want the randomness to feel balanced.
I suggest you use a local variable and have it when you open the pack it randomizes it 6 times. Then use 20 if statements for each item. Example would be: when player opens pack, set local variable to (random integer 1-20 included). Then "if variable1 = 1, give event/target entity diamond 1"
" variable1 = 2, give event/target entity coal 1" etc...
here is an example with 6 items in a pool of 5:
https://imgur.com/a/wQZAdE6
okey thank you
what variable type?
number
hello again
How do I set the drop rate so that 5 items each have a 50% chance, but one special item has only a 0.01% chance?
You can increase the chances of certain items by assigning more than one number value to them. I'm assuming you don't actually want 50 % because it is impossible to have 5 items all with 50 % chance. Regardless, If you want 5 items to be common with 1 item being rare, this is how you would do it:
https://imgur.com/a/OeLyNIA Set it up so the variable is much larger and the 5 common items are ranges, but the one rare item is not a range. You can adjust the numbers to decrease or increase rarity.
How to combine this with the previous procedure so that it works with those 20 items and drops 6 items from one pack?
I am not exactly sure what you mean, but the increasing the repeat block will increase the number of items given. Adding more actual "if variable = /give @s" statements will add more items to the pool of items. Just make sure to keep the random integer variable range in respect to the items in the pool. It's a little complicated, but if you want to adjust the rarity of each item increase the number range of the "if variable = /give @s" statements.
If I want to add more rare items, do I have to set the same single number? because when I give a higher number to each rare item, suddenly the package drops 3 or 4 items instead of 6
I don't know exactly your procedure and you may add changes so I will show you how the mechanism works:
https://imgur.com/a/rTUezVb
This is a graph of the basic idea of how the random number and pool system works. Your basically dividing the range of the number into fractions. Keep in mind that when actually implementing this, the number should be 1 number off and along with item ranges. Like this instead: random integer 1-101. and the items would have ranges like "if variable >0 and <11". that will give it a 1-10 range.
thank you so much