Blood Magic

Blood Magic

90M Downloads

Fluid routing issues

AbdielKavash opened this issue ยท 1 comments

commented

Issue Description:

Hello,

I have encountered a problem when using Routing Nodes to transfer fluids. Specifically, the system does not handle multiple inputs and outputs within the same routing network correctly.

This is a minimal problematic setup:
Create a routing network with one Master Routing Node, one Input Routing Node, and two Output Routing Nodes. Place a fluid tank next to each of the I/O nodes. Place a Fluid Filter in each of the I/O nodes, configured in the right direction and with the same fluid.

Test 1:
Start adding fluid to the "input" tank, one bucket at a time.

Expected behavior:
Well ideally I would love for the fluid to be split evenly between both output tanks; although I can see that the system is not set up to handle this well.
Either way, I would expect that after adding enough fluid to the input tank, both output tanks will be filled.

Actual behavior:
Only the first output tank ("first" in priority order) ever receives any fluid. Even after the first output tank is full, the second tank never receives any fluid at all, even if there is enough fluid in the input tank.

Test 2:
Add multiple buckets of fluid to the input tank at once (right-clicking with another filled tank, or using a transfer method that can push more than 1000 mB at once.

Expected behavior:
The network transports a maximum of 1000 mB per operation.

Actual behavior:
The network transports up to 1000 mB per operation per connection. In the two outputs case, both output tanks receive 1000 mB of fluid with every operation.

Where the problem is:

I have looked at the source, and I believe I have figured out the issue:

The transferThroughInputFilter method returns the amount of fluid remaining in the fluid stack being transferred; while the call of this method in

maxTransfer -= inputFilter.transferThroughInputFilter(outputFilter, maxTransfer);

expects to get the amount of fluid that was actually transferred.

Therefore, if the transfer of fluid to the first output fails (for example, because the output tank is full, or the output filter is set to accept a different type of fluid), RoutingFluidFilter.transferThroughInputFilter returns 1000 (the maximum transfer amount), which then TileMasterRoutingNode reads as "everything was transferred, we are done", and it stops looking for other possible outputs.

This makes setting up any non-trivial network (basically anything other than single input - single output) impossible; as when one transfer fails, all other transfers are abandoned.

Conversely, if the entire fluid stack is successfully transferred, transferThroughInputFilter returns 0, and TileMasterRoutingNode continues looking for more connections, possibly exceeding the maximum transfer rate.

Note that the item transfer code is correct; it returns the number of items that were transferred. The problem is only with the transfer of fluids (or rather, the inconsistency between the two -- I believe the item transfer is working as intended).

Proposed fix:

Change

to

return drained;

This fixes the expected return value of that function.

Affected Versions

Testing was done in the FTB Interactions modpack:

  • BloodMagic: 1.12.2-2.4.1-103
  • Minecraft: 1.12.2
  • Forge: 14.23.5.2838

However the issue is present in the current source code (branch 1.12) as it is now on github. (See above.)

commented

I have also noticed these issues in 1.12.2-2.4.1-103