Zenith Attributes

Zenith Attributes

5M Downloads

Armor calculation inconsistent with Apothic Attributes.

pufmat opened this issue ยท 1 comments

commented

When testing the armor shred attribute from Pufferfish's Attributes mod, I noticed weird behavior in Zenith Attributes. After more investigation, I found inconsistencies in armor calculations compared to Apothic Attributes.

Iron chestplate has 6 armor, so I expect it to be completely bypassed when modifier 6 addition of the armor shred attribute from my mod is applied to the player. Below are the test results:

  • With no other mods:
    • Dummy with no armor: 9
    • Dummy with iron chestplate: 8.46
    • Dummy with iron chestplate, armor shred modifier 5 addition on player: 8.93
    • Dummy with iron chestplate, armor shred modifier 6 addition on player: 9
    • Dummy with iron chestplate, armor shred modifier 7 addition on player: 9
  • With Apothic Attributes:
    • Dummy with no armor: 9
    • Dummy with iron chestplate: 5.6
    • Dummy with iron chestplate, armor shred modifier 5 addition on player: 8.2
    • Dummy with iron chestplate, armor shred modifier 6 addition on player: 9
    • Dummy with iron chestplate, armor shred modifier 7 addition on player: 9
  • With Zenith Attributes:
    • Dummy with no armor: 9
    • Dummy with iron chestplate: 3.52
    • Dummy with iron chestplate, armor shred modifier 5 addition on player: 5.11
    • Dummy with iron chestplate, armor shred modifier 6 addition on player: 5.62
    • Dummy with iron chestplate, armor shred modifier 7 addition on player: 5.62

It can be seen that armor wasn't fully bypassed with Zenith Attributes. After looking at the code I think it is caused by that mixin.

@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/damagesource/CombatRules;getDamageAfterAbsorb(FFF)F"), method = "getDamageAfterArmorAbsorb", require = 1)
public float zenith_attributes$applyArmorPen(float amount, DamageSource src) {
return ALCombatRules.getDamageAfterArmor(ths(), src, amount, ths().getArmorValue(), (float) (ths()).getAttributeValue(Attributes.ARMOR_TOUGHNESS));
}

The amount parameter, according to the @ModifyExpressionValue documentation, is set to the value of the original target expression. In this case, it is the amount of damage after applying the vanilla armor calculation. It means that both the vanilla armor formula and the new armor formula are applied together. This explains why damage is much lower with Zenith Attributes than with Apothic Attributes.

I haven't checked, but this mixin may also cause incorrect calculations in different cases:

@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/damagesource/CombatRules;getDamageAfterMagicAbsorb(FF)F"), method = "getDamageAfterMagicAbsorb", require = 1)
public float zenith_attributes$applyProtPen(float amount, DamageSource src) {
return ALCombatRules.getDamageAfterProtection(ths(), src, amount, EnchantmentHelper.getDamageProtection((ths()).getArmorSlots(), src));
}

This issue is very likely related to: #25