how can i make an enchantment occur once every second

Started by milkycashews on

Topic category: Help with modding (Java Edition)

Last seen on 13:17, 4. Jul 2024
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how can i make an enchantment occur once every second

i have an enchantment that takes a heart, 2 , or 3 off of a mob and heals them to the player depending on the level. while making it, i realized a sweep attack could heal the player back to full health thus making it too op. is there any way to make it occur once every second or two, or anything else i can do to make it less op? here's the enchant

Last seen on 17:16, 4. Jul 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ive got an idea, i hope thatā€¦
Wed, 07/03/2024 - 19:24

ive got an idea, i hope that i understood everything correctly.
you can create a variable for a player, that would work like some sort of a cooldown. for example: when you attack an entity, the game will check if the cooldown is at 0, the bleed enchantment will activate and the cooldown will be added so you wouldnt be able to abuse the mechanic.
the cooldown itself will go down by 1 every player tick update in other procedure. you need to also make game check the cooldown to not go lower than 0 (ex: if get number global:cooldown < 0, do set number global:cooldown to 0 for entity: event/target entity).
this way the bleed effect will activate not at all the times, making some hits normalšŸ‘ (also maybe you wouldnt want the effect to take away hp in %, cuz it can be veeeery op against high hp entities)
i hope I have formulated it right

Last seen on 13:17, 4. Jul 2024
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ill try this, thanks! (alsoā€¦
Thu, 07/04/2024 - 13:17

ill try this, thanks! (also for the % points i realized that which is why i made it in percentages of the player's max hp so for example set the enderman's health to current health - 0.1 x the players max hp so it minuses one heart since that is 10% of the player's max hp)

Last seen on 17:16, 4. Jul 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh damn, didnt see that oneā€¦
Thu, 07/04/2024 - 17:19

oh damn, didnt see that one srry. thats very cool actually