Fix simulated recipe matching causing visible side effects - #5299
Open
Archengius wants to merge 2 commits into
Open
Fix simulated recipe matching causing visible side effects#5299Archengius wants to merge 2 commits into
Archengius wants to merge 2 commits into
Conversation
screret
reviewed
Aug 16, 2026
| listeners[i] = storages[i].getOnContentsChanged(); | ||
| storages[i].setOnContentsChanged(() -> {}); | ||
| Runnable[] listeners = null; | ||
| if (!simulate) { |
Contributor
There was a problem hiding this comment.
I'm fairly certain this should always be done regardless of simulated status? Don't quote me on that, though.
Author
There was a problem hiding this comment.
It being done means the state is modified, which makes it unsafe to call from multiple threads. Why should it be done? In a simulated path, no change listeners will fire since no contents will be changed, and as such, that logic is not necessary.
| for (int i = 0; i < storages.length; i++) { | ||
| storages[i].setOnContentsChanged(listeners[i]); | ||
| if (changed && action.execute()) listeners[i].run(); | ||
| if (listeners != null && !simulate) { |
| Runnable listener = storage.getOnContentsChanged(); | ||
| storage.setOnContentsChanged(() -> {}); | ||
| Runnable listener = null; | ||
| if (!simulate) { |
|
|
||
| storage.setOnContentsChanged(listener); | ||
| if (changed && !simulate) listener.run(); | ||
| if (!simulate) { |
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.
What
Fixes simulated recipe matching causing visible side effects, making it unsafe to run in parallel and violating semantics of simulated == true family of functions.
Implementation Details
Just gating of some functionality behind !simulated, clarifying contracts in IRecipeHandler interface in regards to purity and side effects, and changing ME hatch item/fluid list caching to avoid assigning the list before it is finished being built.
AI Usage
Claude Sonnet 5 was used to review the code.
Outcome
A certain subset of recipe search APIs is now safe to run in parallel.
How Was This Tested
Checked that recipe matching still works as expected.
Potential Compatibility Issues
None expected.