Skip to content

Refactor combat defense formula, add per-type buffs/penetration to damage calc#336

Open
Travja wants to merge 2 commits into
split/09-stat-foundation-buffs-penetrationfrom
split/10-combat-formula-refactor
Open

Refactor combat defense formula, add per-type buffs/penetration to damage calc#336
Travja wants to merge 2 commits into
split/09-stat-foundation-buffs-penetrationfrom
split/10-combat-formula-refactor

Conversation

@Travja

@Travja Travja commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Split out of #320 (piece 11/12 — stacked on #335, review that one first).

Adds two new defense-formula modes alongside the existing legacy 1:1 mode: FACTOR (vanilla Minecraft armor formula, now the default) and CUSTOM (a configurable formula string evaluated per-hit, summing all matching defenses with individual defense_<id> placeholders). The main damage calculation loop now also applies the damage/defense % buffs and per-type penetration stats added in #335, including an optional flat-penetration "overflow" mechanic that can amplify damage past a fully-penetrated defense (CUSTOM mode only).

Separates SKILL_CRITICAL_RATE/DAMAGE (applied only to Fabled skill damage) from the existing CRITICAL_RATE/DAMAGE (auto-attacks only), via new DamageMeta.isIgnoreCrit/isIgnoreSkillCrit flags that external hooks can set to suppress either crit source per-hit.

Merges the standalone GrindstoneListener into VanillaWrapperListener (same PrepareGrindstoneEvent handling) and gates VanillaWrapperListener registration behind !LEGACY_COMBAT.

Note for reviewers: EngineCfg.FULL_LEGACY is declared and checked in several listeners (EntityManager, DynamicStatListener, ItemUpdaterListener, ItemStats#updateVanillaAttributes) as a "disable everything" escape hatch, but nothing in this change (or the upstream PR it's split from) ever loads or sets it from config — it's a static boolean defaulting to false, so all the FULL_LEGACY guards are currently permanent no-ops. A config loader needs to be added for this flag to do anything.

This diff was rebased to preserve unrelated fixes that landed on dev after PR #320 was originally opened (the anti-weapon-damage-bug removal and main-hand-override plumbing in VanillaWrapperListener) — only the hunks actually introduced by #320 are included here.


Generated by Claude Code

claude added 2 commits July 23, 2026 05:36
…mage calc

Adds two new defense-formula modes alongside the existing legacy
1:1 mode: FACTOR (vanilla Minecraft armor formula, now the default)
and CUSTOM (a configurable formula string evaluated per-hit, summing
all matching defenses with individual defense_<id> placeholders).
The main damage calculation loop now also applies the damage/defense
% buffs and per-type penetration stats added in the preceding PR,
including an optional flat-penetration "overflow" mechanic that can
amplify damage past a fully-penetrated defense (CUSTOM mode only).

Separates SKILL_CRITICAL_RATE/DAMAGE (applied only to Fabled skill
damage) from the existing CRITICAL_RATE/DAMAGE (auto-attacks only),
via new DamageMeta.isIgnoreCrit/isIgnoreSkillCrit flags that external
hooks can set to suppress either crit source per-hit.

Merges the standalone GrindstoneListener into VanillaWrapperListener
(same PrepareGrindstoneEvent handling) and gates VanillaWrapperListener
registration behind !LEGACY_COMBAT.

Note for reviewers: EngineCfg.FULL_LEGACY is declared and checked in
several listeners (EntityManager, DynamicStatListener,
ItemUpdaterListener, ItemStats#updateVanillaAttributes) as a "disable
everything" escape hatch, but nothing in this change (or the
upstream PR it's split from) ever loads or sets it from config —
it's a static boolean defaulting to false, so all the FULL_LEGACY
guards are currently permanent no-ops. A config loader needs to be
added for this flag to do anything.
Relaxes evaluateDefenseFormula/evaluateOverflowFormula from private
to package-private so DefenseFormulaEvaluationTest can exercise the
formula string substitution directly, without needing a full combat
event simulation. Covers the shipped default formulas, the
individual defense_<id> vs bare "defense" placeholder substitution
order (defense_physical must be replaced before the "defense" prefix
match), and the overflow formula's negative-result clamping.

Note: written against the existing MockBukkit-based test patterns in
this repo but not run here — this environment can't resolve the
private parent POM (repo.travja.dev) needed to build/test at all.
Please run `mvn test` locally/in CI before merging.
@Travja
Travja force-pushed the split/10-combat-formula-refactor branch from b004641 to 2315fec Compare July 23, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants