Skip to content

Add legacy vanilla stats mode and fix damage modifier handling#340

Merged
MaksyKun merged 2 commits into
divinity-custom-usecase-maksykunfrom
claude/pr-339-explanation-fpuec4
Jul 25, 2026
Merged

Add legacy vanilla stats mode and fix damage modifier handling#340
MaksyKun merged 2 commits into
divinity-custom-usecase-maksykunfrom
claude/pr-339-explanation-fpuec4

Conversation

@Travja

@Travja Travja commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces legacy vanilla stats configuration options and fixes critical issues with damage modifier calculations in the combat system. It also improves item attribute flag handling and adds comprehensive test coverage for the new functionality.

Key Changes

Legacy Vanilla Stats Mode

  • Added LEGACY_VANILLA_ENTITY_STATS and LEGACY_VANILLA_ITEM_STATS configuration flags to allow servers to opt-out of custom stat systems
  • When enabled, these flags bypass custom stat processing in:
    • Entity death, join, quit, and health regeneration events
    • Equipment change handling
    • Item pickup validation
    • Entity stat updates
  • Added corresponding configuration entries in engine.yml

Damage Modifier Fixes

  • Fixed resistance modifier handling: Resistance is now preserved in damage calculations instead of being zeroed out
  • Fixed absorption modifier calculation:
    • Absorption is now calculated based on damage after resistance is applied
    • Absorption is properly capped to the victim's available absorption amount
    • Absorption is no longer subtracted from BASE damage (preventing double application)
    • Represented correctly as a negative modifier in the final damage calculation
  • Added comprehensive test cases validating all damage modifier scenarios

Item Attribute Flag Handling

  • Added ATTRIBUTES_HIDE_FLAGS configuration option to control whether item flags are automatically hidden
  • When disabled, item flags are now intelligently preserved by copying flags from the original item template instead of blindly adding all flags
  • Improved ItemUpdaterListener to respect the new configuration and maintain item integrity

Vanilla Item Attributes

  • Added updateVanillaItemAttributes() method to EntityManager to apply vanilla item attribute updates on equipment changes
  • Integrated vanilla attribute updates into the equipment change event handler

Testing

  • Added VanillaWrapperListenerTest test cases for resistance and absorption modifier handling
  • Added EntityManagerTest to verify legacy vanilla entity stats behavior
  • Added ItemStatsTest to verify legacy vanilla item stats behavior
  • All tests validate both default and legacy mode behavior

Implementation Details

  • Damage calculations now properly account for the order of modifier application (resistance before absorption)
  • The absorption modifier is represented as a negative value in Bukkit's damage event system and is now handled correctly
  • Legacy mode checks are placed at the beginning of event handlers for early exit optimization
  • Item flag preservation uses the CodexEngine's item manager to fetch original item templates

https://claude.ai/code/session_01Kxixg1aALhv5G8V1FEw8Sb

Covers the changes in PR #339: unit tests exercising the
VanillaWrapperListener damage-modifier math directly (resistance no
longer zeroed out, absorption capped to the victim's available amount
and applied only once), plus tests confirming the new
LEGACY_VANILLA_ENTITY_STATS and LEGACY_VANILLA_ITEM_STATS flags
correctly no-op the entity/item stat pipelines when enabled.
@Travja
Travja changed the base branch from dev to divinity-custom-usecase-maksykun July 25, 2026 01:25
This Bukkit version's EntityDamageByEntityEvent constructor expects
com.google.common.base.Function rather than java.util.function.Function.
@MaksyKun
MaksyKun merged commit f1b26dd into divinity-custom-usecase-maksykun Jul 25, 2026
2 checks passed
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.

3 participants