Skip to content

Commit

Permalink
Combatify 1.2.0 1.20.5 Beta 4 - Armour calcs done
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra-Myers committed Apr 8, 2024
1 parent e585ebc commit cf87197
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/atlas/combatify/config/ItemConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -824,14 +824,14 @@ public void parseItemConfig(Item item, JsonObject jsonObject) {
}
public record Formula(String written) {
public float armourCalcs(float amount, DamageSource damageSource, float armour, float armourToughness) {
String armourFormula = written.split("enchMul", 2)[0];
String armourFormula = written.split("enchant:", 2)[0];
armourFormula = armourFormula.replaceAll("D", String.valueOf(amount)).replaceAll("P", String.valueOf(armour)).replaceAll("T", String.valueOf(armourToughness));
float result = solveFormula(armourFormula);
result = 1.0F - EnchantmentHelper.calculateArmorBreach(damageSource.getEntity(), result);
return amount * result;
}
public float enchantCalcs(float amount, float enchantLevel) {
String enchantFormula = written.split("enchMul", 2)[1];
String enchantFormula = written.split("enchant:", 2)[1];
enchantFormula = enchantFormula.replaceAll("D", String.valueOf(amount)).replaceAll("E", String.valueOf(enchantLevel));
float result = solveFormula(enchantFormula);
return amount * result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ private static float changeArmourCalcs(float original, @Local(ordinal = 0, argsO
if (calcs != null) {
original = calcs.armourCalcs(amount, source, armour, toughness);
Combatify.LOGGER.info("Damage: " + amount + " Result: " + original);
} else
Combatify.LOGGER.info("armour formula is null");
}
return original;
}
@ModifyReturnValue(method = "getDamageAfterMagicAbsorb", at = @At("RETURN"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void isDamageSourceBlocked(DamageSource source, CallbackInfoReturnable<Bo
hurtArmor(source, (float) (amount * (1 + piercingLevel)));
double armourStrength = getArmorValue();
double toughness = getAttributeValue(Attributes.ARMOR_TOUGHNESS);
amount = CombatRules.getDamageAfterAbsorb(amount, source, (float) (armourStrength - (armourStrength * piercingLevel)), (float) toughness);
amount = CombatRules.getDamageAfterAbsorb(amount, source, (float) (armourStrength - (armourStrength * piercingLevel)), (float) (toughness - (toughness * piercingLevel)));
}

return amount;
Expand Down

0 comments on commit cf87197

Please sign in to comment.