Group friendly fire: warn on Harmony conflicts (4/4, part of #277) - #304
Open
Zaldaryon wants to merge 1 commit into
Open
Group friendly fire: warn on Harmony conflicts (4/4, part of #277)#304Zaldaryon wants to merge 1 commit into
Zaldaryon wants to merge 1 commit into
Conversation
StratumHarmonyVisibility already logs every mod Harmony patch for triage. This adds a targeted check: when /friendlyfire is off, walk the patched methods for the ones the toggle depends on (the damage entry points, the melee interaction handler, the projectile impact path, CreateExplosion) and log a warning naming any mod that also patches one. A mod that replaces one of those and does not call the original can silently defeat the toggle. Nothing can prevent that, so the goal is just to make it visible instead of a mystery. Runs regardless of the Diagnostics.LogModHarmonyPatches flag, since it is one short feature warning rather than the full patch dump, and stays silent when the toggle is on or nothing patches those methods. Part of #277
Zaldaryon
marked this pull request as ready for review
September 7, 2026 21:42
This was referenced Sep 7, 2026
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.
Summary
Fourth of four follow-ups to #300, and independent of PRs 1 to 3. Adds a targeted Harmony-conflict warning for the group friendly fire toggle.
Base branch is
feat/issue-277-group-friendly-fire(#300). Rebases ontoindevafter #300.Change
StratumHarmonyVisibilityalready logs every mod Harmony patch at boot for triage. This addsWarnFriendlyFireConflicts: when/friendlyfireis off, it walks the patched methods for the ones the toggle depends on (Entity.ReceiveDamage/ShouldReceiveDamage,EntityAgent.OnInteract,EntityBehaviorHealth.OnEntityReceiveDamage,ServerMain.CreateExplosion,ServerSystemEntitySimulation.HandleEntityInteraction,EntityProjectileBase.CanDealDamage/DealDamage/ImpactOnEntity) and logs a warning naming any mod that also patches one.sources/VintagestoryLib/Vintagestory.Server/StratumHarmonyVisibility.cs: the watchlist and the walk.sources/VintagestoryLib/Vintagestory.Server/ServerSystemStratum.cs: calls it fromOnBeginRunGame, right afterLogPatchedMethods, which is after mod Harmony patching.It runs regardless of
Diagnostics.LogModHarmonyPatches(one short feature warning, not the full dump) and stays silent when the toggle is on or nothing patches those methods.Why only a warning
There is no Harmony-safe seam. A prefix that returns
falseand applies damage itself defeats any single check, and no platform solves this (Paper cannot stop a plugin callingLivingEntity.damage()outside the event system either). The friendly fire stack enforces the rule at four independent points across three assemblies to narrow it; this makes the residual risk visible instead of a mystery.Gates
NU1904.bash scripts/smoke-test.sh:PASS ... 13 console command(s) verified.WarnFriendlyFireConflictsruns at boot with no output (toggle default on, no conflicting mods).scripts/extract-patches.sh: no patch or vanilla-source change (both files aresources/).Type
Checklist
scripts/extract-patches.shran clean (no patch touched).dotnet build VintageStory.slnx -c Release -p:EmbedPatchedFiles=trueis green.// Stratummarker (none in this PR).Related issues
Part of #277