Damage Percentage Reduction

Started by aoooodi2 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Damage Percentage Reduction

Im trying to make an armor that reduces certain type of damage taken by a percentage. I have tried multiple methods and haven't find a correct way to do it, is this possible?

Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
While I haven't done this…
Wed, 03/25/2026 - 14:55

While I haven't done this myself, I think this would work:

  • Entity damaged global event
  • If entity is wearing armor then
    • Cancel global event
    • Set local variable dmg to original damage times (1 minus the resistance factor)
    • Damage the entity by the same damage type for local variable dmg damage

The resistance factor is the percentage of damage reduction (e.g. 10%) divided by 100. For example, 10% resistance would become 0.1, 80% resistance would become 0.8, etc. By first canceling the original damage, then scaling the damage by that factor, it will be as if the damage was reduced by that percentage. Then you simply have to damage the entity by that new damage value that was reduced in order for it to work.

Hope this works! :)