Skip to content

Fix cable throughput readout and show it in Waila - #7914

Open
Elyspio wants to merge 4 commits into
GTNewHorizons:masterfrom
Elyspio:fix/cable-throughput-readout
Open

Fix cable throughput readout and show it in Waila#7914
Elyspio wants to merge 4 commits into
GTNewHorizons:masterfrom
Elyspio:fix/cable-throughput-readout

Conversation

@Elyspio

@Elyspio Elyspio commented Sep 1, 2026

Copy link
Copy Markdown

I hit this while debugging a power network in game: I scanned a cable carrying 35 A at 8192 V and the Portable Scanner told me Voltage Out: 24,576 / 786,432 EU/t. 24,576 is 8192 x 3, and the real throughput should be 35 x 8192 = 286,720 EU/t.

What was wrong

PowerNodePath.applyVoltage fed its counter through AveragePerTickCounter.addValue, which sums every value recorded in the same tick. applyVoltage runs once per hop and per packet, so that counter was piling up voltages, never energy. The number I saw was just "8192 V, three packets this tick".

The right-hand side of the same line, (mVoltage - mCableLossPerMeter) * mAmperage, is a power. So the two halves of Voltage Out: 24,576 / 786,432 EU/t were not even the same unit. That max is also wrong on its own: it uses one cable block's mCableLossPerMeter instead of the loss accumulated over the whole path segment.

While I was in there I noticed mLoss accumulates with += in processPipes() without being reset first, unlike mMaxAmps and mMaxVoltage two lines above.

What I changed

Energy gets its own counter, fed in addAmps with amps times the post-loss voltage of the packet being pushed. applyVoltage always runs on a path right before addAmps on that same path (PowerNodes#processNextNode and #processNodeInject), so the voltage is the one those amps are travelling at.

The voltage counter now uses a new AveragePerTickCounter.addMaxValue, which keeps the highest value of the tick instead of the sum, since a voltage does not add up when several packets share a tick.

The displayed maximum comes from the path's cumulated loss and its amp/voltage minimums, so it is right on long runs too.

Scanner and Waila both read PowerNodePath.getReadout(), so they cannot drift apart.

Cables will have a Waila throughput display , (ew client toggle Show Cable Throughput (on by default).

Behaviour change worth flagging

PowerNodePath.getVoltage() also feeds GTUtility.applyElectricityDamage from MTECable.onEntityCollidedWithBlock. It used to hand it the summed voltage, The current change will reduce the damage taken during electrocution

Lang

GT5U.infodata.cable.voltage_out and .avg_output are gone, replaced by .voltage, .throughput and .avg.

PowerNodePath fed its voltage counter through AveragePerTickCounter.addValue,
which sums everything recorded in a tick. applyVoltage runs once per hop and per
packet, so the counter piled up voltages instead of energy. Scanning a cable
carrying 35 A at 8192 V printed "Voltage Out: 24,576" (8192 x 3 packets) next to
a maximum expressed in EU/t, so the two halves of the line were not even the same
unit.

Energy now has its own counter, fed with amps times the post-loss voltage. The
voltage counter uses a new addMaxValue, since a voltage does not add up when
several packets share a tick. The displayed maximum comes from the path's
cumulated loss and its minimums instead of one cable block's own fields, which
was also wrong on long runs. While in there, mLoss is reset in processPipes; it
accumulated with += while mMaxAmps and mMaxVoltage were reinitialised.

Scanner and Waila go through the same PowerNodePath.getReadout so they cannot
drift apart. getWailaNBTData does not call reloadLocks, unlike getInfoData:
reloadLocks mutates shared lock state and walks the whole segment, and Waila
polls several times a second for every player looking at a cable. The Waila lines
sit behind a new client toggle, Show Cable Throughput, on by default.

Heads up on a behaviour change: getVoltage also feeds
GTUtility.applyElectricityDamage. It used to pass the summed voltage, so
electrocution damage scaled with the number of hops. It now passes the real
post-loss voltage, which lowers shock damage on multi-hop networks.

GT5U.infodata.cable.voltage_out and .avg_output are replaced by .voltage,
.throughput and .avg. I dropped the stale ru_RU lines rather than guess at a
translation; the keys fall back to English until a Russian speaker fills them in.
@Elyspio

Elyspio commented Sep 1, 2026

Copy link
Copy Markdown
Author

Waila :
image

image

Portable scanner :
image

@Nana-Sakura

Copy link
Copy Markdown
Contributor

Throughput is different from voltage, Voltage here should be good but I cannot agree with the change for throughput.

@boubou19

boubou19 commented Sep 4, 2026

Copy link
Copy Markdown
Member

Throughput is different from voltage, Voltage here should be good but I cannot agree with the change for throughput.

Could you elaborate a bit more please, so the author can adjust his PR?

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.

4 participants