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

Started by tryunt on Sun, 05/09/2021 - 08:19

Topic category: Help with modding (Java Edition)

Last seen on 05:03, 11. Jun 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How to toggle (on/off) potion effect when a player hits a keybind
Sun, 05/09/2021 - 08:19

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!

Last seen on 19:45, 12. Jun 2021
Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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

Last seen on 05:03, 11. Jun 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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!