Skip to content

Reworked optical computation transfer logic to correctly handle simulated case. - #5296

Open
Archengius wants to merge 2 commits into
GregTechCEu:1.20.1from
Archengius:fix-optical-computation-simulated-transfer
Open

Reworked optical computation transfer logic to correctly handle simulated case.#5296
Archengius wants to merge 2 commits into
GregTechCEu:1.20.1from
Archengius:fix-optical-computation-simulated-transfer

Conversation

@Archengius

@Archengius Archengius commented Aug 15, 2026

Copy link
Copy Markdown

What

Reworked optical computation transfer logic to correctly handle simulated case. Simulated case is important for recipe matching logic since it is not supposed to mutate the state or consume any optical power.

Implementation Details

Replaced seen element set with a map that maps element to an opaque context object used by the element to store its modified state without touching the live data on the instance.

AI Usage

  • No AI driven tools were used for this pull request.
  • Yes AI driven tools were used for this pull request.

Claude Sonnet 5 was used to review the code. All of the code was written by hand.

Outcome

Recipe search logic no longer mutates the state of the computation power transfer related machines.

How Was This Tested

Built research station and other computation-related multiblocks and made sure computation transfer still works.

Potential Compatibility Issues

IOpticalComputationProvider API has changed in a breaking way, so any mods dependant on that part of the GTM API will need to be updated and recompiled against the new version.

…ated case. Replaced visited set with a map of element to its context to support transfer without mutating the element state.
@Archengius
Archengius requested a review from a team as a code owner August 15, 2026 22:52
@gustovafing gustovafing added type: refactor Suggestion to refactor a section of code Release: Patch - 0.0.X Smaller changes that either are bug fixes or very minor tweaks. labels Aug 16, 2026
@Archengius

Copy link
Copy Markdown
Author

Adjusted the changes to separate visited set and simulation state, since if they are combined simulation state cannot be reused across multiple simulations.

*/
default boolean canBridge() {
Collection<IOpticalComputationProvider> list = new ArrayList<>();
list.add(this);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe readd this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be necessary since all implementations are supposed to add themselves to the visited set upon receiving the call. Adding them in advance might actually cause problems due to some of them (like network switch) checking if seen set already contains themselves, and bailing out if it does.

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

Labels

1.20.1 Release: Patch - 0.0.X Smaller changes that either are bug fixes or very minor tweaks. type: refactor Suggestion to refactor a section of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants