TFMG Electricity Performance Patch

Quick rating

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.

Bug Fixes
Performance & Optimization
Mod Loaders
NeoForge
Minecraft

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

About

Project Details

Type
Mod
Latest Version
TFMG Electricity Performance Patch 1.0.0
Authors

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.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

CurseForge ID

Resources

External Links

Source Issues Wiki Discord

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

  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 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.
  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, 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.
  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. 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

This project has no gallery images yet.

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

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

<1,000
Downloads
Last Updated
Created
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works