server/player: Resync the inventory when a released item consumes nothing - #1289
Open
root-nat wants to merge 1 commit into
Open
server/player: Resync the inventory when a released item consumes nothing#1289root-nat wants to merge 1 commit into
root-nat wants to merge 1 commit into
Conversation
…hing When a player releases an item such as a bow, the client predicts the result and removes the arrow it expects to be fired. If the release consumes nothing (it is cancelled, the bow is not drawn long enough, or there are no arrows) no inventory slot changes server-side, so the client is never corrected and shows a phantom missing item. Resend the inventory only on those no-consume paths in ReleaseItem. A successful release already updates the client through the inventory slot change of the consumed item, so the common path is untouched and does not flicker. Closes df-mc#1001. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Reworked fix for #1001 (the previous attempt, #1281, was closed after review).
Problem
When a bow is released the client predicts removing an arrow. Server-side the arrow is consumed through
inventory.RemoveItem, whose slot-change callback already resends the affected slot on every successful shot. The desync happens only on the paths that consume nothing — the release is cancelled, drawn for < 3 ticks, force < 0.1, or there are no arrows — where no slot changes and the client's predicted removal is never reverted.Fix
Resync the inventory (main + off-hand) only on those no-consume paths in
Player.ReleaseItem, leaving a successful release to the existing slot-change callback. This avoids the redundant full resend / one-frame flicker that resending before the release caused on every shot (the concern raised on #1281 by @FDUTCH).Closes #1001.
🤖 Generated with Claude Code