Potion Effects Stacking on eachother

Started by FreezieYT on

Topic category: Help with modding (Java Edition)

Last seen on 02:25, 12. Dec 2023
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Potion Effects Stacking on eachother

I'm trying to make it so each time you use the item, (right click) it will give you potion effects, (already did that part) but my issue comes in when I try to make it add time. How do i make it add to the duration of the potion effect each time I use it item?

Last seen on 21:55, 20. Feb 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Since potion effects only…
Wed, 11/22/2023 - 20:43

Since potion effects only override eachother if the duration is longer, you would need a special procedure, in which the duration of the potion is the duration you want, added to the existing duration of that potion. (Make an if bracket that checks if the player already has the potion, and, if they do, add the potion, but replace the duration with the duration + the existing duration of the potion.)

The 'get ticks remaining of potion' function should be helpful here.

Last seen on 02:25, 12. Dec 2023
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Do you know how to make that…
Thu, 11/23/2023 - 03:17

Do you know how to make that procedure?

Last seen on 21:55, 20. Feb 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Normally you would use the …
Thu, 11/23/2023 - 04:02

Normally you would use the 'apply potion to entity' function. But in your case, you need to replace the duration, (the part where it asks you for a number), with the current duration of the potion, plus the duration you want to add. It should just be a single procedure block, but with a plus function where you would normally put the duration.

Last seen on 02:25, 12. Dec 2023
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm still confused on how to…
Thu, 11/23/2023 - 14:22

I'm still confused on how to make the function so each time it is used, you get the effects longer

Last seen on 21:55, 20. Feb 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It should probably look…
Thu, 11/23/2023 - 15:51

It should probably look something like this. You may not even need the if bracket, it should probably just work with the first part, but this way you could make the initial duration longer, if you wanted.