Repository navigation
Combat 4.2b: Stop treating vanilla Thorns as a weapon swing - #384
Merged
Merged
Conversation
A hit with cause THORNS (or, on 1.20.4+, vanilla damage type thorns) and no damage request reports the Thorns wearer as its damager. The wrapper took that for a weapon swing and applied the wearer's weapon damage, crit and on-hit effects to the attacker. Such a hit now takes the path environmental damage takes: the event's own damage, typed by attached-damage-types, attached-damage-causes or the default type, reduced by the victim's defenses. Hits that carry a damage request are unchanged: the request's origin decides. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEyTt5JAkynCUVt6Z3jZK
Look the vanilla damage type up at most once per event and reuse it for the attached-damage-types fallback. Reword the plan paragraph on Thorns and add a note, now that 4.2b fixes it. Correct the javadoc of the new Thorns test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FaEyTt5JAkynCUVt6Z3jZK
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.
Part of #365.
Problem
When a mob or player wearing vanilla Thorns is hit, the attacker takes damage through an
EntityDamageByEntityEventwhose damager is the wearer and whose cause isTHORNS. With no damage request for that event,VanillaWrapperListener.onVanillaDamagetook it for a weapon swing by the wearer: the wearer's full weapon damage, crit and on-hit effects were applied to the attacker. Thorns is not a swing.Path chosen, and why
A hit with no damage request whose cause is
THORNS(every version), or whose vanilla damage type isminecraft:thorns(1.20.4+, through the existingDamageSources.get().getDamageType(e)lookup), now doesbreak labelFullDamageright after thecanFightscheck. That is the exact path environmental damage takes, and the path every hit takes whenisFullDamageis false:attached-damage-types, thenattached-damage-causes, then the default typeDamageMeta, as for environmental damage. Bukkit's own kill credit comes from the event, so it is untouchedNothing new was added to the pipeline. The change is one guard and a small helper. The vanilla damage type is read at most once per event and reused by the
attached-damage-typesfallback. It is not read for a hit with a request, and not for a hit whose cause isTHORNS, where the cause already decides.Before and after (from the tests)
Wearer's weapon: 20 physical, 100% crit chance, crit damage stat 2. Reflected Thorns hit with event damage 2.
physical60, critical, damager = wearer_vanilla_generic2, not critical, no damagerTHORNSmoved tofireinattached-damage-causesphysical60fire2.72 against fire armor 10 (event damage 4), so defenses still applythornsinattached-damage-typesoffire(1.20.4+)physical60fire4The shipped
item_stats/damage.ymllistsTHORNSunderattached-damage-causesof_vanilla_generic, and no damage type hasattached-damage-types. A default install therefore reaches the generic type, as it already did for Thorns hits with no living damager.Deliberately unchanged
EFFECT) already use requests and behave exactly as before. A test pins anEFFECT-origin hit with causeTHORNS: still physical 60, critical, damager = wearer.THORNSinattached-damage-causes, or ofthornsinattached-damage-types, goes through the same lookup as before and takes precedence over the default type.Other causes that look like non-swings treated as swings (not changed)
This list is not exhaustive. It is a list for a follow-up, and nothing here changes behaviour. Read from the code, not tested. Each reaches the wrapper with a living damager (or a projectile with a living shooter) and no request, so it takes that damager's weapon stats:
ENTITY_EXPLOSIONwhere the damager is a Creeper (or another living entity)SONIC_BOOM(Warden)MAGICfrom a Guardian's beamDRAGON_BREATHwhere the damager is the Ender DragonMAGICthrough the projectile branch, so the thrower's weapon stats applyA Guardian's own thorns-style retaliation uses cause
THORNS, so it is covered by this PR.Docs
doc/COMBAT_RESTRUCTURE_PLAN.md: the paragraph that said Thorns is treated as a swing and "left for Phase 4" now says what 4.2b did.doc/COMBAT_RESTRUCTURE_NOTES.md: one line under "Things about the code that are easy to get wrong". It has no per-item status for 4.2b, so no status line changed.Tests
CombatCharacterizationTest. The first test was written before the change and passed on the old code (a Thorns hit carries the wearer's weapon damage and crit). After the change it was rewritten to the new expectation, so the Thorns test in the PR is a new test, not an edit of an existing one:thorns_reflectedHit_isNotAWeaponSwing_onADefaultInstall. It is one of six new tests:thornsalone, with a different causeTHORNSmapped inattached-damage-causes, with defenses still appliedthornsmapped inattached-damage-typesEFFECTrequest with causeTHORNS: unchangedThe last two also pass with the production change removed, which shows they are unchanged.
Phase 0 characterization tests touched: none. Only the new Thorns tests were added, and the test file also gained a few helpers.
Full suite (
mvn test, output to a file, real exit code 0), re-run after the lookup change and the doc edits: 190 run, 0 failures, 0 errors, 2 skipped (the two trident tests inVanillaWrapperListenerTest, as expected). That is 184 existing tests plus 6 new ones.Break-it checks (run on the first commit, each reverted afterwards)
!isThornsHit)ENTITY_ATTACKrequest == nullguardEFFECT-request test failsThe follow-up commit only moved where the damage type is read. The suite above was re-run on it and passes.
Notes
build:major): Thorns damage numbers change.🤖 Generated with Claude Code
https://claude.ai/code/session_01FaEyTt5JAkynCUVt6Z3jZK