Fix deadlock when crafting job with reusable ingredient depends on crafting that ingredient#186
Merged
rubensworks merged 2 commits intofix/182from Mar 2, 2026
Merged
Conversation
…endencies Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add game test to reproduce bug and implement proposed fix
Fix deadlock when crafting job with reusable ingredient depends on crafting that ingredient
Mar 2, 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.
When a crafting job required a reusable ingredient (e.g., shears) that itself needed to be crafted as a dependency, the system would deadlock: the reusable ingredient ended up in
lastMissingIngredientsduring buffer fill, and the update loop conditionif (lastMissingIngredients.isEmpty() || true)(the|| truewas a temporary workaround) gated the lazy extraction that would have unblocked the job.Changes
CraftingHelpersskipReusableIngredientsflag (defaultfalse) togetIngredientRecipeInputs(new 9-param overload, 8-param delegates) andgetRecipeInputs(new 8-param overload, 7-param delegates). Whentrue, reusable ingredient slots are emitted as empty placeholders — not extracted from storage, not reported as missing.CraftingJobHandlerfillCraftingJobBufferFromStorage: passesskipReusableIngredients=truewhen the job has pending dependencies, so reusable ingredients stay in storage and are extracted lazily once dependencies complete. Removes the debugSystem.out.println.if (lastMissingIngredients.isEmpty() || true)wrapper so the reusable-ingredient handling always runs when the buffer is missing a reusable ingredient — regardless of prior fill state.Game test
testItemsCraftDeadBushTagReusableNeedsCrafting: reproduces the deadlock scenario — no shears in initial storage, 2 iron ingots available to craft them, requests 10 dead bushes via a reusable-shears recipe. Asserts 10 dead bushes produced and 1 shears returned.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.