[1.19.2] Issue With Priorities
Sandriell opened this issue · 7 comments
Describe the bug
I am either having an issue with priorities not working, or misunderstanding how it works.
I have two plugs feeding power into my network. Plug A is connected to a Powah solar array and Plug B is connected to a Powah reactor. Both plugs, on their own, can fully supply the network.
Plug A is set to a priority of 100.
Plug B is set to a priority of -100.
No matter the priority settings, both plugs supply ~50% of the power
If I break plug B, Plug A properly supplies all the needed power. Soon as I place Plug B back down, it goes back to 50%/50%.
To Reproduce
Steps to reproduce the behavior. (Must be detailed)
Expected behavior
Plug A, with the higher priority to supply 100% of the power until it cannot meet demand.
Screenshots
If applicable, add screenshots to help explain your problem.
It all depends on how other mods are implemented.
For example, if your network requires 800FE/t, and Plug A has a higher priority than Plug B, other mods can provide 800FE to Plug A at once in a tick, then B will no longer receive energy in that tick. But some mods may not provide 800FE at once, but instead split into multiple times within a tick to provide a total of 800FE. This may result in priorities not working as expected.
I just misunderstood this issue. I will dig into this issue later.
@BloCamLimb excuse me if I'm being too forward, but line 35 in FluxPlugHandler.java looks suspicious to me:
long op = Math.min(Math.min(getLimit(), bufferLimiter - mBuffer) - mBuffer, maxReceive);
As written, this boils down to the lowest of:
getLimit() - mBuffer, or;bufferLimiter - 2 * mBuffer, or;maxReceive
It is clear to me what 1 is meant to represent (the amount the plug is maximally allowed to receive from outside the network, minus the energy it already has), it is also clear what 3 is meant to represent (whatever amount of energy the outside world is willing to supply here), but the fact that the buffer is getting substracted twice in the second case is tripping me up.
@BloCamLimb could this be related to the way in which the plug takes/receives energy from the block it is attached to? This is the kind of behavior I'm seeing in a very simple network (looking at the plug here):
20250823-1221-02.5629422.mp4
The throughput is 'flickering' and the network statistics report nothing. The point's side looks very similar.
This is a somewhat synthetic example, because it uses just one magmatic x64 generator (from Generator Galore), and an Energy Trash Can (from the Trash Cans mod). I can smooth out the behavior by using a Mekanism Universal cable as a buffer between the magmatic generator and the plug. In which case it just reports 500 FE/t on both the plug and point's side.
In my real world example, my consumption is also slightly "erratic" - in the sense that the machines that are used are from Ex Machinies Divitae Deorum: Those machines do mostly nothing for the duration of their processing time (80 ticks, in my case), and then when the processing time finishes they take the entire power they need from their buffer. The buffer replenishes at what I eyeballed at 10k FE/t, but they are all attached to a mek cable buffer of 4.5M FE.
In that situation, there are still moments where a different plug (also with a mek cable buffer) with a lower priority gets used:
20250823-1225-35.1608613.mp4
For the life of me, I can't figure out why there are instances where the wrong plug is used. Looking at the code, as a programmer that didn't do much with Java after college and isn't all that familiar with Minecraft modding, I would assume that for some reason there are ticks where the plug on one side can't - or thinks it can't - supply enough but I have no idea why it is such irregular behavior.
If there's anything I more I can do to help you look into this, don't hesitate to let me know.
EDIT: I've changed the first video with a "cleaner" version, I had some unrelated points and a controller still connected to the network. This new video is effectively the same - the behavior certainly is - but this time it is clear there is only one attached plug and one attached point.
EDIT2: I've done a similar cleaning with the second video, that also shows some more information. As before, the actual behavior is the same, even though the network is cleaner.
Indeed, that’s a mistake; but I think the main reason is that Flux Point doesn’t try to retain the energy requested in the previous tick. The transfer logic needs some adjustments.
For example, suppose we have one Flux Point and two Flux Plugs. At the end of the first tick, this Flux Point requests 800 FE. Then in the second tick, both Flux Plugs are allowed to receive 800 FE. By the end of the second tick, the Flux Point requests 1600 FE (assuming it constantly consumes 800 FE/t), at which point all the Plugs will send their energy to the Flux Point. But in the third tick, none of the Plugs will receive energy.
In theory, only one Plug should be continuously receiving energy. But in this case, the two Plugs alternately supply 800 FE in one tick and none in the next, averaging out to 800 FE/t.
I want to ping this as an open issue, still, and add some details.
In a similar setup to OP, my lower-priority plug drains power, even though it's not contributing to the network at all.
Higher priority plug's power usage remains constant, but the lower-priority plug leeches power from the external source. Not sure where this power is going - it's not going into the network as far as I can tell.
It would be super useful to have this working as designed, allowing for a backup power source (more expensive) to satisfy short bursts in usage.
I have a similar issue. I have two plugs. one set to 1 and the other 1000. The one set to 1000 has a massive energy store over 5k rf/t possible transfer and my network only needs like 512rf/t. my flux storage is completely full at 2M rf. for some reason my lower priority plug drains power from it's source. it seems like it says 0/t most of the time but then for like 1 ticker or so spikes a bit then goes back to 0. I just want it so my fuel using generators don't get used unless my renewable sources aren't enough. This seems to be impossible wiwthout adding mods like rftools for the rf monitor, but i should be able to do it with priorities unless i'm misunderstanding something.
For example, suppose we have one Flux Point and two Flux Plugs. At the end of the first tick, this Flux Point requests 800 FE. Then in the second tick, both Flux Plugs are allowed to receive 800 FE.
Is this because the buffer limiter isn't actually updated as plugs accrue energy? I would expect the fact that the one plug can in fact receive the required amount of power means the other won't, but I'm guessing that is not possible due to reasons I'm ignorant of.
Is there a reason why power transmission is 'delayed' like this? I assume it is desirable to assess which points can output power and which plugs can receive that power in the same tick as actually performing the transfer. Is there a reason why that isn't done, is it just not feasible due to how the FE system works?
edit: P.s. I don't mean to impose with these questions, feel free to ignore me :)