How do I make a mob do different types of damage on contact, without making the damage happen every tick?

Started by AwesomeSavage777 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make a mob do different types of damage on contact, without making the damage happen every tick?

I am trying to use the "player collides with entity" procedure to add another damage type to an enemy (right now magic damage), but when I touch the mob, I take constant magic damage, and only sometimes take normal damage.

This has also happened in the past with other mobs I made in past mods, and Idk how to fix it.

Supposedly I need to make a cooldown for the damage, but how would I do that (especially for a procedure that does things every tick that it can)?

In the past I made a music looping procedure, which was in the "on tick update" slot of most of my mobs procedures in the last mod I made (with modifications for different music), but when the song tried to loop, it would loop, but also play on top of itself infinitely (so I resorted to just playing the music at certain points in the bossfights). I don't have that procedure anymore, as it is older than the final, unfinished, deleted update of the last mod I made (which I removed from Curseforge and my computers), but it is still confusing, and potentially related to this issue. Technically it wasn't the "last mod I made" but the "last mod I worked on and enjoyed making", which was the second to last one that I made before now.

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try making a global variable…
Fri, 06/27/2025 - 23:42

Try making a global variable clock and check every tick if the clock has reached a certain time, and if it has, then reset the clock.

for reference 1 second = 20 ticks