Started by
gewtet
on
Topic category: Help with MCreator software
Hello i need help for my mod i have the problem with sword effect because i not want it be 2 effect or 1 i know that might be hard to do but if any one know how to make sword do random effect after it hit mob/player
Try using an RNG procedure to determine which effect the sword inflicts, then attach that procedure to the 'When Hits Living Entity' option for your custom sword.
For the simplest sort of RNG, you can just use the 'Do with 70% Chance' procedure template- this will randomly select between two outcomes, and you can customize the likelihood.
For a more complex method, add a custom number variable to your procedure, then set that custom variable to a random number between 1 and whatever your maximum number of outcomes is. (You can find a bunch of the randomizer stuff in the 'Math' tab.) Then, make a bunch of 'If' blocks that bestow the effect on the target entity if the custom variable is a specific number.
Bruh, I didn't even know there were templates.
Yeah, they're really helpful, especially if you're just starting out- or if you don't want to build a procedure to search a 6*6 cube for a specific block from scratch. There should be a 'procedure templates' option in the upper left hand corner when you're making a procedure.
I got say thank you for helping but i did not get how to do rng soo search in google and found an video where show how rng works but i see that it's not connect to "do if" i don't know maybe it's problem of version that i use 2022.1 or there some think else can you send photo how to connect each other or what version need to do rng
In the math section in procedures theres random numbers
This is the most basic sort of RNG- this procedure will drop a diamond with a seventy percent chance, and otherwise drops coal. You can adjust the percentage by changing the first number- this is usually fine for anything with only two outcomes.
This is a slightly more complicated procedure- it uses a custom variable that it sets to a random number between 1 and 3, (though you can have as many outcomes as you want.) All outcomes will be equally likely, though you can make some more likely by adding more results- such as making it drop a diamond if the random variable = 1 or 2.