How to toggle (on/off) potion effect when a player hits a keybind

Started by tryunt on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to toggle (on/off) potion effect when a player hits a keybind

Hello, I am looking for help with my superhero mod!

I want to make a shazam set and want it to be when a player hits a keybind (example "k") it will strike them with lighting and give them certain potion effects.

Any help, examples or downloads would be fantastic.

Thank you!

Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The simplest way is to make…
Sun, 05/09/2021 - 09:50

The simplest way is to make a variable, and when keybind is pressed,:

If [variable] = 0 (default)

 strike the player with lightning

 set variable to 1

Else (if [variable] = 1)

 set variable to 0

 

Then make a procedure on player tick:

When Variable = 1 (means when the keybind was toggled on)

 Apply potion effect

Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi, Can you please send a…
Sun, 05/09/2021 - 10:49

Hi, Can you please send a visual of the code if you can!

Thanks!