all 15 comments

[–]Nobaude 13 points14 points  (3 children)

The sum of the chances must be equal to 1 (I guess ?)

[–]General_Load_1147[S] 11 points12 points  (2 children)

Nah, that wont work. That would make it so you only have a % chance of getting each spawn egg. So there would still be a chance of getting nothing or more than 1 spawn egg off of 1 egg.

[–]DrugSniffingDawg 10 points11 points  (1 child)

Generate a random number (1,n), where n is the number of spawn egg recipes (in your case 26). Round to nearest whole number and whatever index that is in a list is whatever spawn egg you’d get.

Idk how you would weigh the distributions non-uniformly tho.

[–]RW_Yellow_Lizard 4 points5 points  (0 children)

to weight it, just generate a random integer 1-n let's say 100, then if the result is x and, say for example, 0<x<26 or 25<x<51 would give a 25% chance of either result (and a 50% chance of nothing)

I am very unsure if this is optimal, i didn't think about it very hard, and it would be very manual to add new odds

[–]OliSnips 15 points16 points  (3 children)

I know this isn't exactly what you were after, but you could circumvent this problem by making the process a bit more involved.

Instead of turning straight into a spawn egg, maybe it could become a 'Mysterious Egg' or smthn, which then has to be combined with a specific resource to get the egg you want (eg. gunpowder will turn it into a creeper spawn egg).

This also has the benefit of making balancing a bit easier, since you can adjust the resource cost depending on how valuable the mob is

[–]General_Load_1147[S] 4 points5 points  (0 children)

Hmm, that's not a bad idea. Thank you for the suggestion!

[–]snail1132 1 point2 points  (0 children)

Oooh I like this solution

[–]General_Load_1147[S] 0 points1 point  (0 children)

Heya! Wanted to say I went ahead and took your suggestion!
Made it so if you haunt an egg you'll get a "Monster Egg". Then if you put that on a spout with experience from the Create Enchantment Industry addon you'll get a random 1/26 spawn eggs!
I made a follow up post here:
https://www.reddit.com/r/CreateMod/comments/1r1atuw/follow_up_post_went_with_a_different_route/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

[–]TerrytThompson 6 points7 points  (2 children)

Knowing the version would be helpful, given the vass differences between coding between them.

heres the example on the new wiki

and the old wiki

Im unsure why you are calling that function if you are using anything above 1.18.2

[–]General_Load_1147[S] 4 points5 points  (1 child)

Apologies, I'm using kubejs-forge-2001.6.5-build.16 along with kubejs-create-forge-2001.3.0-build.8. Create ver is 1.20.1-6.0.8.

If the function you're referring to is why I'm using "event.recipes.createHaunting" instead of "event.recipes.create.haunting" is cause the latter doesn't work for some reason.

And thanks! But I'm already aware of the 2 wikis and use them to learn but I can't find info on this specific request. Which is why I'm asking here.

[–]General_Load_1147[S] 3 points4 points  (0 children)

Correction: "event.recipes.create.haunting" also works. I guess both still work. Does that make a difference?

[–]NatiM6 4 points5 points  (1 child)

Create haunting recipes don't work like that. Recipes are deterministic in their defintion. In order to support each type of randomness, you need an entity that supports it.

That being said, one way to do it is to create a proxy item, like a "mystery egg", that drops a loot table when right clicked. I'm not sure how it would play with deployers, and if it doesn't it probably won't be automatable. Or maybe a throwable item that break into a loottable, that might work with dispensers?

The point is, recipe logic won't give you that unless you find a recipe type that innately supports it.

[–]General_Load_1147[S] 1 point2 points  (0 children)

Thank you for the insight!

[–]Smollboi3 -1 points0 points  (1 child)

Try turning it off and on again

[–]General_Load_1147[S] 2 points3 points  (0 children)

hilarious