Conversation
… exceptions When an external mod behavior throws an unhandled exception during item damage (such as Toolsmith's NRE when an untracked tinkered tool breaks), the exception previously escaped ServerSystemBlockSimulation into DispatchClientPacket_mainthread, causing the dedicated server to forcibly kick the player with an unhandled exception notice while leaving block and inventory state unfinalized. Wrap Collectible.WalkBehaviors and Collectible.OnBlockBrokenWith in try-catch blocks so faulty mod behaviors log their error to the server logger while allowing vanilla default actions (item damage and break handling) to proceed. In addition, wrap TryModifyBlockInWorld item and block break callbacks with a fallback block removal if unhandled exceptions occur, ensuring dedicated servers do not disconnect players when third-party mod item breaking logic fails. Add regression Atlas scenarios covering both failure modes. Fixes #282
Zaldaryon
marked this pull request as ready for review
September 17, 2026 00:33
Zaldaryon
requested review from
Pixnop,
pizza2004 and
trevorftp
as code owners
September 17, 2026 00:33
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
Safeguard block breaking and tool damage against unhandled exceptions thrown by collectible behaviors, resolving #282.
When an external mod behavior throws an unhandled exception during item damage (such as Toolsmith's
NullReferenceExceptioninTinkeringUtility.HandleBrokenTinkeredToolwhen an untracked tinkered tool breaks), the exception escapedServerSystemBlockSimulation.TryModifyBlockInWorlddirectly intoServerMain.DispatchClientPacket_mainthread. On dedicated servers, any unhandled exception in client packet dispatch forcibly kicks the player with "Threw an exception at the server" ("An action you or your client did caused an unhandled exception"), aborting block removal and leaving player inventory dirty states out of sync.This change introduces defensive handling across the breaking pipeline:
Collectible.WalkBehaviorswraps behavior invocations in try-catch blocks. If a mod'sOnDamageItemthrows, the exception is logged to the server logger while allowing vanilla default actions (item damage reduction and slot clearing on zero durability) to complete cleanly.Collectible.OnBlockBrokenWithwraps behavior callbacks in try-catch blocks so third-party mod failures log rather than crashing the breaking sequence.ServerSystemBlockSimulation.TryModifyBlockInWorldwrapsOnBlockBrokenWithandblock4.OnBlockBrokenin a try-catch block. If an exception occurs and the target block was not yet removed, a fallback block break runs so the block is not left in an inconsistent state, and the player is not disconnected.ItemBreakResilienceScenarios.csreproducing both failure modes under dedicated server conditions (IsDedicatedServer == true).Type
Checklist
.\scripts\extract-patches.ps1ran clean.dotnet build VintageStory.slnx -c Release -p:EmbedPatchedFiles=trueis green.// Stratummarker.Related issues
Fixes #282