[SOLVED] How to make a potion effect last as long as you can hold a key?

Started by FireElla5 on Sat, 09/12/2020 - 01:14

Topic category: Help with modding (Java Edition)

Last seen on 15:21, 17. Sep 2020
Joined Aug 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
[SOLVED] How to make a potion effect last as long as you can hold a key?
Sun, 09/13/2020 - 21:56 (edited)

So I am making a mod, which includes an invisibility cloak. I want to make it so that holding the "I" key makes you invisible, and releasing it takes away your potion effects. So I made the procedures, and for whatever reason the invisibility only lasts 4 seconds when I press the key, no matter how much I change the potion effect time.

 

How do I make it so that holding the I key will make you invisible for however long, as long as you don't release the key?

Edited by FireElla5 on Sun, 09/13/2020 - 21:56
Last seen on 15:21, 17. Sep 2020
Joined Aug 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
The version I am using is…
Sat, 09/12/2020 - 01:17

The version I am using is 2020.4

Last seen on 01:38, 23. Oct 2020
Joined Nov 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
on key pressed give potion…
Sat, 09/12/2020 - 05:07

on key pressed give potion effect invisibility for 999999 seconds, on key release clear invisibility effect.

Last seen on 15:21, 17. Sep 2020
Joined Aug 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Thank you! It turns out I…
Sun, 09/13/2020 - 21:54

Thank you! It turns out I had the procedures in the triggers tab of the invisiblity cloak, I just removed the procedures from there and put them in keybinds, but I never thought about changing the duration to that. For those of you who have a similar problem: 

 

Key pressed code:

Event trigger - No additional trigger

         if Get item from armor slot 2 of Event/target entity = <choose your armor>

(armor slot 3 is helmet, 2 is chestplate, 1 is leggings, and 0 are boots)

     do Add potion with level 1 and duration 999999 to Event/target entity type <whatever potion effect you want>

Key released code: 

Event trigger - No additional trigger

     Clear all potion effects of Event/target entity

 

--------------------------------------------------------------------------------------------------------------------------------------------------