Back to mods
TFMG Electricity Performance Patch project artwork

CurseForge · Minecraft mod

TFMG Electricity Performance Patch

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

Choose a version Pick your version below, then grab the matching file.

Quick answer

Which TFMG Electricity Performance Patch release should I use?

Updated 18 days ago
Latest stable file tfmgfix-2.1.0
Game version 1.21.1
Loader NeoForge

TFMG Electricity Performance Patch tfmgfix-2.1.0 targets 1.21.1 with NeoForge. The project page does not say whether this file belongs on the client, dedicated server, or both. No extra mods listed for this file.

Where it goes

Is TFMG Electricity Performance Patch required on the client, server, or both?

The project page does not say whether this file belongs on the client, dedicated server, or both.

Client Source doesn’t say
Dedicated server Source doesn’t say
Loader for this release NeoForge
Required install it here Optional supported, not mandatory Not supported do not install here Source doesn’t say do not assume

The source does not explicitly classify this release as client-only or server-only.

What else does TFMG Electricity Performance Patch tfmgfix-2.1.0 need?

tfmgfix-2.1.0. Change the file and its required mods may change too.

No extra mods listed for this file

This file does not list any required mods. Do not add a library just because a different file uses it.

This file does not list any required or optional mods.

Before you install it

Add TFMG Electricity Performance Patch without breaking your instance.

Built for TFMG Electricity Performance Patch tfmgfix-2.1.0. Pick another file and the loader, install side or required mods may change.

  1. 01

    Stick to this file

    Use tfmgfix-2.1.0. It targets 1.21.1 with NeoForge; another release may have different loader, side or dependency requirements.

  2. 02

    Bring the mods it needs

    This file does not list any required mods. Do not add a library just because a different file uses it.

  3. 03

    Put it on the correct side

    The project page does not say whether this file belongs on the client, dedicated server, or both.

  4. 04

    Pick the file you checked

    Use the “Get this file” button beside tfmgfix-2.1.0. It opens that exact file at the source.

About this project

What does TFMG Electricity Performance Patch add?

What this is

An unofficial performance and crash patch for Create: The Factory Must Grow (TFMG) 1.2.0 on NeoForge 21.1.x / Minecraft 1.21.1.

Mixins only. TFMG itself is not modified or redistributed — no content, recipes, registries or worldgen are touched. Install it next to TFMG, remove it any time; nothing is written to your world.

The performance problem

If you have an electric motor on your grid, TFMG recalculates that entire electrical network 20 times per second, forever — even when nothing changes. And a single recalculation is written in a way that costs O(n²) in the size of the grid, so doubling your wiring quadruples the cost of every tick.

That combination is why long power lines and electric motors tank TPS and FPS.

What it fixes

1. Infinite network update loop on the electric motor. ElectricalNetwork.updateNetwork() notifies every member via onNetworkChanged(..). ElectricMotorBlockEntity answers that notification with updateNextTick(), which makes tickElectricity() call updateNetwork() again next tick, which notifies the motor again — forever.

Every other consumer guards its reaction with a change check:

if (voltage != getData().getVoltage() || powerUsage != getPowerUsage())

The motor is the only one that reacts unconditionally. It is now held to the same guard, so an unchanging grid asks for nothing while a real change still propagates. delayedUpdate, notifyUpdate() and updateGeneratedRotation() behave exactly as before.

1.0.0 and 1.1.0 removed this call outright rather than guarding it, which could leave a transformer with no output on a grid where the motor was the only repeated source of change. Fixed in 1.2.0 — update if you are on an earlier version.

2. Quadratic cost of a single network update. The last loop of updateNetwork() calls getCableCurrent(member) once per cable, and that method sums the current over all members — the same value every time, since it ignores its argument. It is now computed once per update and reused. Nothing in that loop changes voltages or resistances, so the reused value is identical to what the original code would produce. O(n²) → O(n).

This matters even more with transformers and switches on the grid, because getCurrent() calls resistance(), and VoltageAlteringBlockEntity.resistance() is itself O(n) — the original update degrades towards O(n³).

3. Empty accumulator: a second per-tick rebuild loop. AccumulatorBlockEntity.tick() calls updateNextTick() on every tick while the bank is empty, which is a completely normal state. Throttled to once per 20 ticks — the network still learns the bank ran dry, at most a second later.

4. Large switch rebuilding the whole graph on an overloaded grid. LargeSwitchBlockEntity.lazyTick() calls onPlaced() while notEnoughPower is set, which re-runs checkForLoops() and onConnected() — a recursive flood over the entire grid through getBlockEntity() lookups. Throttled to one attempt per 10 lazy ticks (~5 s).

The crash it fixes

Looking at a steel tank through Engineer's Goggles and breaking a block of it takes the client down:

NullPointerException: Cannot invoke "SteelTankBlockEntity.getBlockPos()" because
the return value of "SteelTankBlockEntity.getControllerBE()" is null
  at SteelTankBlockEntity.addToGoggleTooltip(SteelTankBlockEntity.java:423)
  at GoggleOverlayRenderer.renderOverlay(GoggleOverlayRenderer.java:111)

getControllerBE() returns null for the frames between a block of a multiblock being broken and connectivity being recomputed, and the tooltip dereferences it without a check. It runs on the render thread, so the NPE is fatal. TFMG guards against exactly this in FireboxBlockEntity, VatBlockEntity and BlastStoveBlockEntity, all of which open their tooltip with if (getControllerBE() == null) return false; the steel tank is missing that line.

5. The guard is restored on the steel tank, and on the two other tooltips with the identical defect: the distillation controller (tank.getControllerBE().activeHeat, which falls back to the tank's own value) and the regular engine (getControllerBE().addToGoggleTooltip(..) on a non-controller block).

Install

Drop the jar into mods/ alongside TFMG.

Needed on both the server and the clients. The client builds electrical networks too and runs the same loop, so without the patch client-side you keep the FPS drop. displayTest = "IGNORE_ALL_VERSION" is set, so it can be installed on one side only without a mod-list mismatch.

If you update TFMG

The mixin config uses "defaultRequire": 1, so if a target method changes in a future TFMG version the game will fail to start with a clear Mixin error instead of silently doing nothing and bringing the lag back. If that happens, remove this patch.

Notes

Not affiliated with the TFMG author. Findings are from decompiling tfmg-1.2.0.jar; the intent is that these fixes end up upstream, at which point this patch becomes unnecessary.

Project description from CurseForge.

Pick your setup

TFMG Electricity Performance Patch by Minecraft version and loader

Choose the version and loader you play, then open the matching release.

1 available setups

Check the dependencies, then try the file in a copied instance before changing a world you care about.

Recent files

TFMG Electricity Performance Patch versions and loaders

5 of 5 releases match

Looking for an older file? The official CurseForge project page is in Resources.