Fixed factory gauge unlinking from display links when moved#10168
Open
LIUKRAST wants to merge 1 commit intoCreators-of-Create:mc1.21.1/devfrom
Open
Fixed factory gauge unlinking from display links when moved#10168LIUKRAST wants to merge 1 commit intoCreators-of-Create:mc1.21.1/devfrom
LIUKRAST wants to merge 1 commit intoCreators-of-Create:mc1.21.1/devfrom
Conversation
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.
This pull request tries to solve a simple issue happening with factory gauges & display links:
Steps to reproduce
The display link will still be connected to the gauge, but it will not update anymore unless you open the screen again
The solution
I'll first show the pipeline of what happens to then explain my solution
attachBehaviourLate(this)behaviour.initialize(), which inFactoryPanelBehaviourcallsnotifyRedstoneOutputs()linkAt.notifyLink()onNotify.run()which in our display link calls updateGatheredData()getSourcePosition, which will NOT return our factory panel position because as we said before, it's now unlinked. Now the display link is successfully unlinked from our panel, and it will be re-linked later, but this resets all the information, requiring, as said before, to setup everything again from the screen.The Solution, now for real
My solution was simple, we store all the connection with display links inside a map, remove them from the
targetedByLinksmap of the moving factory panel, so that on behaviour initialize it will not broadcast his update to display links, thinking he is not connected to any. Finally, after initializing, we re-add all the connections from the map to our gauge, successfully tricking the display link into thinking he never disconnectedMoral of the story
I know this is a small issue, but working on my addons I find myself in these small edge-situations and being scared this was my code's problem, I solved it. Hope this PR can help!