|
2 | 2 |
|
3 | 3 | import me.ryleu.armornerf.ArmorFormula;
|
4 | 4 | import me.ryleu.armornerf.ArmorNerf;
|
| 5 | +import net.minecraft.entity.LivingEntity; |
| 6 | +import net.minecraft.entity.damage.DamageSource; |
5 | 7 |
|
6 | 8 | public class VanillaFormula extends ArmorFormula {
|
7 | 9 | @Override
|
8 |
| - public float calculate(float damage, float armor, float armorToughness) { |
9 |
| - float armorReduction = damage / (2F + armorToughness / 4F); |
10 |
| - float adjustedArmor = Math.min(Math.max( |
11 |
| - armor * 0.2F, // large damage amounts cannot lower the armor below 20% efficacy |
12 |
| - (armor - armorReduction) |
13 |
| - ) * ArmorNerf.CONFIG.armorPercentage() / 20F, 1F); |
14 |
| - return damage * (1F - adjustedArmor); |
| 10 | + public float calculate(LivingEntity armorWearer, float damageAmount, DamageSource damageSource, float armor, float armorToughness) { |
| 11 | + float finalArmorFraction; |
| 12 | + |
| 13 | + float adjustedToughness = 2.0F + armorToughness / 4.0F; |
| 14 | + |
| 15 | + // calculate armor toughness effectiveness reduction\ |
| 16 | + float armorValue = Math.max(armor - damageAmount / adjustedToughness, armor * 0.2F); |
| 17 | + |
| 18 | + // whether to cap armor at a full bar -- will make many modded armors far more effective |
| 19 | + if (!ArmorNerf.CONFIG.removeArmorLimit()) { |
| 20 | + armorValue = Math.min(armorValue, 20.0F); |
| 21 | + } |
| 22 | + |
| 23 | + // apply the config numbers |
| 24 | + float adjustedArmorFraction = (armorValue / 20.0F) * ArmorNerf.CONFIG.armorPercentage(); |
| 25 | + |
| 26 | + finalArmorFraction = applyEnchantments(damageSource, armorWearer, adjustedArmorFraction); |
| 27 | + |
| 28 | + return damageAmount * (1.0F - finalArmorFraction); |
15 | 29 | }
|
16 | 30 | }
|
0 commit comments