Skip to content

Fix fluid network not validating FlowSource#10602

Open
Apertyotis wants to merge 1 commit into
Creators-of-Create:mc1.21.1/devfrom
Apertyotis:fix/fluid-network-fault-tolerance
Open

Fix fluid network not validating FlowSource#10602
Apertyotis wants to merge 1 commit into
Creators-of-Create:mc1.21.1/devfrom
Apertyotis:fix/fluid-network-fault-tolerance

Conversation

@Apertyotis

Copy link
Copy Markdown
Contributor

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 OpenEnded connection. 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 FlowSource inside PipeConnection.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:

network = Optional.of(new FluidNetwork(world, new BlockFace(pos, side), flowSource::provideHandler));

The sourceSupplier captures a reference to the old flowSource, meaning that it can never obtain a new FlowSource unless 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 for null and isValid. In newer versions, the validity check has been lost.

debugger

Restoring the validity check completely resolves the remaining issue.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant