Refactor combat defense formula, add per-type buffs/penetration to damage calc#336
Open
Travja wants to merge 2 commits into
Open
Conversation
This was referenced Jul 23, 2026
Travja
force-pushed
the
split/10-combat-formula-refactor
branch
from
July 23, 2026 05:26
eae315b to
b004641
Compare
…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
force-pushed
the
split/10-combat-formula-refactor
branch
from
July 23, 2026 05:38
b004641 to
2315fec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) andCUSTOM(a configurable formula string evaluated per-hit, summing all matching defenses with individualdefense_<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 existingCRITICAL_RATE/DAMAGE(auto-attacks only), via newDamageMeta.isIgnoreCrit/isIgnoreSkillCritflags that external hooks can set to suppress either crit source per-hit.Merges the standalone
GrindstoneListenerintoVanillaWrapperListener(samePrepareGrindstoneEventhandling) and gatesVanillaWrapperListenerregistration behind!LEGACY_COMBAT.Note for reviewers:
EngineCfg.FULL_LEGACYis 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 tofalse, so all theFULL_LEGACYguards 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
devafter PR #320 was originally opened (the anti-weapon-damage-bug removal and main-hand-override plumbing inVanillaWrapperListener) — only the hunks actually introduced by #320 are included here.Generated by Claude Code