How do I make a sword have a chance of aplying a potion effect?

Started by half glaceon on

Topic category: Help with modding (Java Edition)

Last seen on 22:05, 7. May 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make a sword have a chance of aplying a potion effect?

Hello! So uhhh, I really am kinda new on the variables and procedures stuff, and haven't been here for a while.

So I want to do a weapon (melee sword to be more specific) that has a CHANCE to trigger a potion effect on whoever it hits.

Again, what I'm looking for is for it to have a chance but not always do the effect.

So, anybody knows how to help me with this?

Last seen on 05:10, 3. Dec 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Definitely! When you create…
Sat, 09/30/2023 - 13:18

Definitely! When you create your weapon, on the "living entity is hit with weapon" trigger, set up a procedure that says "if [random: 0,1] >= 0.9 do apply potion effect.

This means there is a 10% chance to apply potion effect. (1.0 - 0.9 = 0.1)

You can find the [random 0,1] block under math tab

>= is located under the logic, you need to use the math equal sign and then use the drop down to select >=