promotional bannermobile promotional banner

TFMG Electricity Performance Patch

Fixes the per-tick electrical network rebuild loop and the quadratic network update in Create: The Factory Must Grow.
Back to Files

tfmgfix-1.2.0

File nametfmgfix-1.2.0.jar
Uploader
mzgmzg
Uploaded
Aug 8, 2026
Downloads
136
Size
8.2 KB
Mod Loaders
NeoForge
File ID
8604131
Type
R
Release
Supported game versions
  • 1.21.1

Curse Maven Snippet

NeoForge

implementation "curse.maven:tfmg-electricity-performance-patch-1624822:8604131"

Learn more about Curse Maven

What's new

1.2.0 — fixes a regression this patch itself introduced in 1.0.0

If you are running 1.0.0 or 1.1.0, update. Those versions can leave transformers with no output.

What was wrong

Fix 1 removed the electric motor's updateNextTick() call from onNetworkChanged, on the grounds that asking for a network recalculation from inside the notification of a recalculation that has just finished is redundant. That is true — but only while nothing changed. Removing the call outright removed the propagation along with the loop.

It matters because of how TFMG moves changes between networks. A network recalculates only when something has set ElectricBlockValues.updateNextTick, and a transformer pushes to the network in front of it only from updateInFront(), which runs in the third pass of ElectricalNetwork.updateNetwork():

no recalculation of the input network
  -> updateInFront() never runs
    -> the transformer's output network is never poked
      -> no output voltage

On a grid with other sources of change — accumulators filling and emptying, switches, generation that varies — something else keeps setting the flag and nothing is visibly wrong. On a quiet grid where the motor was the only thing repeatedly disturbing the network, the chain stops. The symptom is a transformer that works intermittently, or shows no output current at all until something else happens to disturb the network.

What 1.2.0 changes

The call is restored, behind the guard TFMG uses everywhere else. VoltageAlteringBlockEntity.onNetworkChanged already does:

if (oldVoltage != getData().getVoltage() || oldPowerUsage != getPowerUsage())
    updateInFront = true;

and the motor is now held to the same test. A motor on an unchanging grid still asks for nothing, so the 20-per-second rebuild loop stays fixed; a motor whose voltage or power draw actually moved asks for one recalculation, which is what the original code was for.

IElectric.setVoltage writes data.voltage immediately rather than next tick — verified in the bytecode, because a deferred write would have made this guard never fire and turned the fix back into the deletion it replaces.

Also re-verified, and unchanged

Fix 2 (caching getCableCurrent across one updateNetwork() call) was checked again against the same bytecode and is sound. getCurrent() depends only on data.voltage and resistance(); the pass that calls getCableCurrent writes neither, and updateInFront() does not touch the network it is called from. The cached value is bit-for-bit what the original code computes, at O(n) instead of O(n²).

Fixes 3 and 4 (empty accumulator, large switch) and the three goggle tooltip crash guards from 1.1.0 are unchanged.

Compatibility

TFMG 1.2.0, Minecraft 1.21.1, NeoForge 21.1.x. Mixins only. Needed on both server and clients.

This mod has no related projects