Progressing potion effect

Started by Tarfer54 on

Topic category: Help with modding (Java Edition)

Last seen on 16:25, 4. Jun 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Progressing potion effect

I am new in the modding game and I would like to do a custom effect that does damage more frequently while you have it, the only thing I know is that I need to do a procedure but I don't know which one.

Last seen on 20:43, 20. Aug 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Depends on what exactly you…
Fri, 12/29/2023 - 13:13

Depends on what exactly you're trying to do? If you want it to do occasional damage like poison, and you've made your custom effect, you can amke a player-update-tick procedure that checks the current duration of the potion, and, if it's cleanly divisible by a certain number, deals damage. (If, for example, you check if dividing a number by ten is equal to dividing a number by ten rounded down, it will only return true every tenth tick, and thus trigger every half second.) 

If you also want an effect to deal more damage the longer you have it, you could scale it based on the remaining ticks of the effect. (Which will decrease the longer the player has it.) The issue here is that if the player gets a very short duration of the effect, then it will deal high amounts of damage immedieately, which probably isn't what you want. So you could instead make a custom player-lifetime number variable, (in the variables tab), and have your update-tick procedure increase this variable by one every tick. (So now you'll have a second number that goes up every tick the player has the potion.) You could then make an else-if bracket that checks if the number is above a certain threshold to determine the amount of damage dealt. (Or use some math to make it actually scale with damage.)