Skip to content

Fix item drops sometimes being rejected - #3295

Open
lost-werewolf wants to merge 1 commit into
Pryaxis:general-develfrom
lost-werewolf:fix-item-drop
Open

Fix item drops sometimes being rejected#3295
lost-werewolf wants to merge 1 commit into
Pryaxis:general-develfrom
lost-werewolf:fix-item-drop

Conversation

@lost-werewolf

Copy link
Copy Markdown
Contributor

Fixes player item drops being rejected when Main.item[Main.maxItems] is somehow active. I couldn't replicate this myself, but I have seen it can occur after a long play time without restarting the server. Appears to be a vanilla issue we now have to work around.

Clients always drop items in slot 400 (Main.maxItems) and then allow the server to assign it a slot, so this item slot being active caused the Bouncer to reject them when it shouldn't have.

I considered if I should also have the Bouncer reject new items being dropped outside of slot 400, but I worry this may have other unknown issues. Feedback appreciated on this decision.

Text for the changelog:

  • Fixed item drops sometimes being incorrectly rejected after extended server uptime (lost-werewolf)

@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a single guard condition (id < Main.maxItems) to the item-drop type-change check in Bouncer.OnItemDrop to prevent legitimate drops from being incorrectly rejected when Terraria's vanilla bug causes slot 400 (Main.maxItems) to become active after extended uptime.

  • Clients always initiate drops using slot Main.maxItems (400), then receive an assigned slot from the server; when that placeholder slot is erroneously active, the prior check would read Main.item[400].active == true and wrongly reject the drop.
  • The fix is minimal and surgical: it preserves all existing type-change enforcement for slots 0–399 while skipping the check only for the new-drop placeholder slot.

Confidence Score: 5/5

Safe to merge; the change is a one-line guard that fixes an observable drop-rejection regression without weakening any other Bouncer check.

The fix adds id < Main.maxItems before the existing Main.item[id].active test, correctly isolating the vanilla slot-400 bug without touching any other enforcement path. All other type-change, range, stack, and ban checks are unchanged. The author's acknowledged trade-off — that slot 400 now bypasses the type-change guard — is the intended behaviour and is consistent with how Terraria's drop protocol works.

No files require special attention.

Important Files Changed

Filename Overview
TShockAPI/Bouncer.cs One-line guard added to OnItemDrop; correctly prevents false rejections when the vanilla game bug leaves slot 400 active, with no impact to existing type-change enforcement for all other item slots.

Reviews (1): Last reviewed commit: "fix item drops sometimes being rejected" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants