BukkitOldCombatMechanics
BukkitOldCombatMechanics copied to clipboard
Fix protection enchant for armor
Current Armor Strength Module heals players who have a high protection enchant on armor (they take negative damage). This happens because the module fails to clear the vanilla damage reduction from the MAGIC modifer before checking if the MAGIC damage reduction for the module should be calculated.
This commit fixes the issue by correctly setting the vanilla MAGIC reduction to zero before the final damage check.
To be completely fair, there's something very broken about the DamageModifier system. I encountered a similar issue with Resistance effects while I was investigating #499. I wonder if it'd be better to just override the system completely? Would it make a difference to other plugins?
If you want to avoid using the damage modifier api then this module could calculate the expected damage after determining the the protection from armor points and protection enchantments and skip to adjusting the final damage for the event. This means that the damage value in the BASE damage modifier would not match the damage value in the ATTACK_DAMAGE attribute how ever the final effect should be the same. This change will certainly have some effect other plugins that try to implement their own damage system like MCMMO.
Fixed in a similar way in the testing branch.