Repository navigation
Hand the bucket empty result to its caller through a ThreadLocal - #513
Open
lewisgibson wants to merge 2 commits into
Open
lewisgibson wants to merge 2 commits into
lewisgibson wants to merge 2 commits into
Conversation
BucketItem handed the PlayerBucketEmptyEvent result to getEmptySuccessItem through a static field shared by every region. See the patch for details.
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.
BucketItemkeeps the item that aPlayerBucketEmptyEventlistener left in the hand in a static field, written byemptyContentsand read and cleared bygetEmptySuccessItema few calls later. With regions ticking in parallel, two players emptying buckets at the same time can overwrite each other's field, so one of them gets the other's item, or the default bucket, back in their hand.This makes the hand-off a
ThreadLocal, since both calls always run on the same region thread. The change is folded into0001-Region-Threading-Base.patch.Tested on
ver/26.2.xwith a small test plugin and two players 3000 blocks apart, so in different regions. The plugin'sPlayerBucketEmptyEventlistener gives BotA a diamond and BotB an emerald as the result item, and aGenericGameEventlistener holds both region threads afteremptyContentshas stored its value and beforegetEmptySuccessItemreads it, so the overlap is certain rather than a matter of timing. Unpatched, BotB ended up with a plain bucket; with this change BotA has the diamond and BotB has the emerald.This was done with AI (Claude Opus 5.5 and GPT Astra, high effort). I've reviewed it and tested it myself.