The player shouldnt get hit / it shoulnt repeat

Started by Mcreator_noob on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The player shouldnt get hit / it shoulnt repeat

I want a "shockwave" to release when the player gets hit, but right now, the player also gets damage from the shockwave and the ability will just keep repeating over and over again as long as the player is missing 1 HP. Please help make it stop doing damage to the player and make it only blast once when getting the player is damaged, then after the cooldown it does it again when (and only when) the player is damaged damaged.

 

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you could make a new damage…
Tue, 02/18/2025 - 20:48

you could make a new damage type(e.g. Force) and make a procedure that on entity hurt/damaged and if player and was from Force, cancels it and if the entity dies, cancel it too.

Here's some images:

If damage is Force, cancel

code

If entity dies, cancel

code

Shockwave code

code

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use the "on entity attacked…
Wed, 02/19/2025 - 16:59

Use the "on entity attacked/hurt" event, check if the entity is wearing your chestplate and then run your code.

In the entity iterator, check that "Entity iterator != Event/target entity" so the player isn't damaged.

This last suggestion is just a quality thing but I would check that the Entity iterators y coordinates aren't more than 3 or so blocks off the players y coordinates. That's just to make the shockwave more flat and to stop things above and below getting hurt in annoying ways.