TFMG Electricity Performance Patch
No reviews yet
Fixes the per-tick electrical network rebuild loop and the quadratic network update in Create: The Factory Must Grow.
Neoforge is a fork of the Minecraft Forge available for versions 1.20.1+ of Minecraft. Many Forge mods are compatible with Neoforge and vice versa.
Community voices
Reviews
Click once to include, again to exclude, again to clear
No reviews yet. Be the first to review this project!
Get it on
Available Platforms
About
Project Details
For authors
Embed Badge
If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.
Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.
Identifiers
Platform IDs
Resources
External Links
About
Description
What this is
An unofficial performance 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 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
- 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 on voltage and power usage; the motor is the only one that reacts unconditionally. The redundant re-request is removed; delayedUpdate, notifyUpdate() and updateGeneratedRotation() behave exactly as before.
- 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, because getCurrent() calls resistance(), and VoltageAlteringBlockEntity.resistance() is itself O(n) — the original update degrades towards O(n³).
- 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.
- 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. Throttled to one attempt per 10 lazy ticks (~5 s).
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 is set to IGNORE_ALL_VERSION, 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.
Screenshots
Gallery
Versions
Files
Relations
Project Relations
More like this
Similar Mods
Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.
On ModDex
Community snapshot
By the numbers
Statistics
Want to reach Minecraft players?
We're looking for a server hosting partner to feature here and other parts of the site. Interested? Send us a message!
Get in touchGet it on
Available Platforms
On ModDex
Community snapshot
By the numbers
Statistics
Resources