Fix fluid network not validating FlowSource#10602
Open
Apertyotis wants to merge 1 commit into
Open
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.
The following content is machine-translated and may contain inaccuracies.
In the Forge 1.20.1 version of Create, I noticed that placing a Fluid Tank adjacent to an existing tank does not trigger a block update, while current versions no longer exhibit this behavior.
As shown in the first video, placing a tank in this way leaves the fluid network unchanged, causing the connected pipe to continue treating that position as an
OpenEndedconnection. Even on the latest version, the same issue can still be reproduced by placing tanks with the Schematic Cannon, since it bypasses the expected network update.first.mp4
This reveals a weakness in the fluid network implementation: it relies heavily on block updates while performing very little validation of the current
FlowSource. The scenario above is only one example of many situations that can leave the network in an inconsistent state.To improve the robustness of the fluid network, this PR validates the
FlowSourceinsidePipeConnection.manageSource(). If the cached source is no longer valid, it is discarded and rediscovered, allowing the network to recover automatically instead of depending entirely on external updates.There is, however, another issue that appears superficially similar but has a different root cause.
If part of a multi-block Fluid Tank is broken and immediately replaced, the behavior shown in the second video can occur. Although the symptoms resemble the previous issue, these two problems are actually independent: each fix resolves its own issue without affecting the other. I decided to include both changes in the same PR to keep the issue complete.
second.mp4
The first issue comes from
PipeConnection:Create/src/main/java/com/simibubi/create/content/fluids/PipeConnection.java
Line 148 in 87b3c6a
The
sourceSuppliercaptures a reference to the oldflowSource, meaning that it can never obtain a newFlowSourceunless the entire network is rebuilt. Updating this logic fixes the issue on 1.20.1.However, this alone is insufficient for 1.21.1. Looking further into FluidNetwork#L163, older versions used
!source.isPresent(), which implicitly checked both fornullandisValid. In newer versions, the validity check has been lost.Restoring the validity check completely resolves the remaining issue.