How can I stop an explosion from hurting the player?

Started by ryden on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I stop an explosion from hurting the player?
Sat, 06/07/2025 - 03:27 (edited)

I've created a custom enchantment that summons an explosion when blocking enemy attacks with a shield, but the player usually dies from said explosion. I'm looking for a way to make the explosion not hurt the player. I've heard of a global trigger called "Before Entity is Hurt", yet I cannot find it and I've just assumed it's been removed.

Edited by ryden on Sat, 06/07/2025 - 03:27
Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have an idea! Make a…
Sat, 06/07/2025 - 04:42

I have an idea! Make a procedure that gives the player some kind of OP resistance for 1 or 2 ticks which stops you from taking damage, and then when the explosion ends, you don't have resistance anymore and mobs can attack you.

Well, I am not a MCreator pro or anything, but I hope this will work for you, and if you want I can test out a prototype of my own and send over an image!

Joined Jun 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks. I was thinking of…
Sat, 06/07/2025 - 04:55

Thanks. I was thinking of something like this but unsure of how to go about it. I tested it and it works flawlessly.

Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You're welcome for the help,…
Sat, 06/07/2025 - 06:59

You're welcome for the help, glad I could come in handy!