# Foundation notes Paths in citations are relative to `gt5-2.9.0/src/main/java` (GT5-Unofficial 5.09.54.265, GTNH 2.9.0). ## Engine (`assets/engine.js`) - `OverclockCalculator` is a line-by-line port of `gregtech/api/util/OverclockCalculator.java` (whole class, :1-537), with Java setter names. - `ParallelHelper` ports the numeric path of `ParallelHelper.determineParallel` (`ParallelHelper.java:375-534`). Item/fluid matching is replaced by an input limit (total parallels the inputs allow), void protection by an optional cap. Recipe locking is not modelled. - `ProcessingLogic` ports `ProcessingLogic.java:455-590` (validate, createParallelHelper, createOverclockCalculator, applyRecipe, calculateDuration). Machines override methods on an instance, as Java multiblocks override them in `createProcessingLogic()`. - Java long math uses BigInt where truncation or overflow matters (`getTiersAbove` ×100 scaling and long division, `(long)` casts, `availableEUt / tRecipeEUt`, `voltage / 8` in the voltage-tier check, `log2/log4` on longs). `(int)` casts of doubles saturate, as in Java. - Batch duration multiplier is float: `1.0f + (float) extra / current` (`ParallelHelper.java:525`), ported with `Math.fround`. - `powInt` keeps Java's exact powers for bases 2 and 4 and the squaring loop for other bases (`GTUtility.java:3570-3618`), so non-2/4 OC factors round like Java. - Power model `hatchPower`: `MTEMultiBlockBase.setProcessingLogicPower` (`MTEMultiBlockBase.java:1171-1176`): one regular energy hatch and no exotic hatch → 1 A at the hatch voltage; otherwise average voltage (long division) and summed working amps. Regular hatch 2 A (`MTEHatchEnergy.java:86-88`), multi-amp and laser hatches `Amperes` (`tectech/.../MTEHatchEnergyMulti.java:147-149`). `MTEExtendedPowerMultiBlockBase` (`:116-133`) includes exotic hatches in the sums; `MTEMultiBlockBase` sums only `mEnergyHatches`. `getMaxInputVoltage` is a sum of voltages, not a maximum (`ExoticEnergyInputHelper.java:67-74`). - Laser hatch amperage is adjustable with a screwdriver (`MTEHatchEnergyTunnel.java:107-122`), so the engine accepts any amperage. ## Java reference fixtures `tools/java-ref/run.sh` compiles the unmodified 2.9.0 `OverclockCalculator.java` with a stub `GTUtility` (helpers copied verbatim) and `RefMain.java` (copy of the numeric lines of `determineParallel` and `applyRecipe`), and writes 3000 seeded random cases to `tests/fixtures/java-ref.jsonl`. The node test suite compares every case against the JS engine: overclock count, consumption, duration, sub-tick multiplier, process result, parallel, final duration, batch duration multiplier. Coverage of the current fixture set: 498 laser, 980 heat, 1407 with sub-tick multiplier > 1, 400 with batch extra parallels, 103 with a duration-under-one-tick supplier, 614 insufficient power, 271 insufficient voltage, 567 without amperage OC. All 3000 match. Dead end: the first RefMain wrote `128 / calculator.getDuration()` (int division); the real code divides the double constant `MAX_BATCH_MODE_TICK_TIME`. The JS was right; RefMain fixed. ## EBF examples (`machines/ebf.js`) - Heat capacity: `coilHeat + 100 × (getTier(getMaxInputVoltage()) − 2)` (`MTEElectricBlastFurnace.java:227-228`). `getMaxInputVoltage()` is overridden in `MTEExtendedPowerMultiBlockBase.java:116-118` and sums the voltages of all hatches (`ExoticEnergyInputHelper.java:67-74`). Two IV hatches therefore count as LuV (+400 K), and four UV hatches (Σ 2,097,152 V) as UHV. - Only `HatchElement.Energy` is accepted in the structure (`MTEElectricBlastFurnace.java:104`). That element registers `MTEHatchEnergy` only (`HatchElement.java:110`, `MTEMultiBlockBase.java:2274-2289`), so the page offers regular hatches only. - The values for "Tungstensteel, HSS-G, 2× IV", "Single IV hatch" and "Naquadah, Trinium, batch, 4× UV" come from `tools/java-ref/run.sh "" case ...` with the heat computed by hand from the lines above. - Recipe defaults come from the 2.9.0 dump: Tungstensteel with nitrogen, 1920 EU/t, 2500 t, 4000 K; naquadah with nitrogen, 7680 EU/t, 600 t, 5000 K. ## LCR (`machines/lcr.js`) - Perfect OC (`MTELargeChemicalReactor.java:155-158`), max parallel 1, batch supported (`:299-301`), regular energy hatches only (`:77`). - Sub-tick parallels apply to max-parallel-1 machines. `ParallelHelper` multiplies `maxParallel` by `calculateMultiplierUnderOneTick()` (`ParallelHelper.java:413-421`). `setCurrentParallel` then caps the calculator's `parallel` at the original max parallel (`OverclockCalculator.java:289-293`), so EU/t does not grow with the extra parallels. Java reference: 30 EU/t, 480 t, 2× IV gives 3 parallels at 30,720 EU/t, 1 t. - Recipe default (sulfuric acid, 30 EU/t, 480 t) comes from the 2.9.0 dump, `gt.recipe.largechemicalreactor`. ## Curation findings - Mega EBF and Mega Vacuum Freezer exist in 2.9.0 only as bartworks `*Legacy` classes. Assembler recipes convert them to the Exothermic Hearth and the Endothermic Fridge (`gregtech/loaders/load/MTERecipeLoader.java:1952-1968`). - The former GT++ industrial multis (centrifuge, electrolyzer, mixer, macerator, wire mill, sifter, …) are in `gregtech/common/tileentities/machines/multi/` in 2.9.0. - Volcanus = `MTEAdvEBF`, Dangote Distillus = `MTEAdvDistillationTower` (names from `src/main/resources/assets/miscutils/lang/en_US.lang:4187-4188`). ## Framework decisions - Specs register via `GTCalc.register(spec)`. Under node, `tools/lib/load.mjs` runs engine, ui and each machine file in a `vm` context with no DOM, so build and tests use the same files as the browser. - `assets/catalog.js` is generated with one machine per line and no timestamp, so regenerating it is deterministic. - Chart series colors are slots 1–4 of the dataviz reference categorical palette (validated light/dark steps). A chart shows at most 4 series in fixed order, with a legend when there are 2 or more series, a crosshair or per-bar tooltip, and a data table under each chart. - Rendered and inspected in headless Chromium: EBF, LCR and index (light, 1280 px), EBF dark at 420 px, and a custom `mount()` page. ## Unverified - JS `Math.log` and Java `Math.log` can differ by 1 ulp. They feed `⌈log(d)/log(k)⌉` in `calculateMultiplierUnderOneTick`. The 3000-case fixture comparison found no difference on this machine's JVM (GraalVM 21). Other JVMs were not checked. - `ParallelHelper` item/fluid matching, recipe locking and void protection are not ported (input limit and void cap stand in for them). ## Verification Independent review of the foundation against the 2.9.0 source (`gt5-2.9.0/src/main/java`). ### Engine - `assets/engine.js` was read line by line against `OverclockCalculator.java` (:1-537), `ParallelHelper.java:375-534`, `ProcessingLogic.java:455-590`, `GTUtility.java` (safeInt :230, getTier :443-453, powInt/log helpers :3570-3682), `GTValues.java:92-95`, `HeatingCoilLevel.java`, `ExoticEnergyInputHelper.java:54-98` and `MTEMultiBlockBase.java:1171-1176, 1671-1696`. No numeric deviation found. `tools/java-ref/GTUtilityStub.java` matches the GTUtility source; `RefMain.process` matches `determineParallel` apart from the documented input-limit stand-in. - The 3000-case fixtures never reach `getTiersAbove`'s unscaled branch (machine power ≥ Long.MAX_VALUE/100, i.e. ≥ 9.2e16 EU/t), `Long.MAX_VALUE` consumption saturation, long wraparound of voltage × amperage, `noOverclock`, a custom heat-discount exponent, or the duration supplier above 1 t. Section "1b" of `tests/run.mjs` covers these with values from an independent driver around the unmodified `OverclockCalculator.java` (scratch build, not `tools/java-ref`). Batch, input-limit and INT_MAX-parallel cases came from `RefMain` single cases and were checked by hand. - Defect fixed: with laser OC and recipe power ≤ 0 (recipe EU/t 0), `calculateLaserOCs` loops forever in Java (`OverclockCalculator.java:376-380`, `eutOverclock` stays 0), and the JS port hung the page with it. The port now throws a `RangeError` in exactly the cases where the Java loop does not terminate. The page then shows "Calculation failed". - Dead end: the first batch-boundary test assumed 127 t gets batch parallels. `floor(1 × (128/127 − 1)) = 0` (`ParallelHelper.java:514-517`), so batching only adds parallels at ≤ 64 t for parallel 1. The test was corrected; the engine was right. ### Reference machines - EBF: heat `coil.getHeat() + 100 × (getTier(getMaxInputVoltage()) − MV)` (`MTEElectricBlastFurnace.java:227-228`), `getMaxInputVoltage` summed over normal and exotic hatches (`MTEExtendedPowerMultiBlockBase.java:116-118`) via `MTEAbstractMultiFurnace`. The structure accepts only `HatchElement.Energy` (`:104`, `HatchElement.java:110` → `MTEHatchEnergy`, 2 A; `MTEWirelessEnergy` inherits 2 A). Heat OC and heat discount via `createOverclockCalculator`, heat check in `validateRecipe` (`:190-207`), batch 128 (`MTEMultiBlockBase.java:1365-1367`). All four examples were rederived by hand and match. - LCR: `new ProcessingLogic().enablePerfectOverclock()` (`MTELargeChemicalReactor.java:156-157`) = `setOverclock(4, 4)` (`ProcessingLogic.java:283-285`). The examples match. One example was named "IV recipe on 1× EV" for a 480 EU/t (HV) recipe; it is now "HV recipe on 1× EV". ### Framework - Defect fixed: build and tests loaded every machine file into one shared vm context. Two specs with the same top-level `const` failed with "Identifier has already been declared" after a merge, although each page works alone in a browser. `tools/lib/load.mjs` now gives each machine file its own context. - `tests/lib/dom-stub.mjs` is a small DOM (no dependencies). The tests render the EBF and LCR pages through `ui.js` and `charts.js`. They check the header, controls, tiles, two SVG sweeps, notes, footer and index link. They check that URL hash state round-trips (read, write on input, reload gives the same tiles; invalid values fall back to defaults), that example and reset buttons work, that the theme toggle persists to `localStorage`, and that a `mount()` custom page gets `ctx`. The index inline script is run against `assets/catalog.js` to test cards, text, tier and mod filters, the empty state and the hash. Expectations are derived from the catalog so they hold after more machines are merged. - The test suite runs `tools/build.mjs --validate` on a scratch copy with invalid specs: wrong mod and tier, id/file mismatch, unknown example input, missing shell, TODO left in, `register` called twice, and `compute()` throwing on defaults. Every error is reported and the exit status is 1. - A test of catalog freshness (`build.mjs --check`) was deliberately left out: machine worktrees must not commit `catalog.js`, so it would fail there. - Not verified: real browser layout, pointer and tooltip behaviour, focus order. There is no headless browser in this run; the earlier Chromium check in "Framework decisions" was not repeated. CSS token contrast: text tokens are ≥ 4.5:1 on `--bg` and `--surface` in both themes. `--ink-3` on `--surface-2` is 4.36:1 (light), used only for disabled inputs. ### CURATED.md - All 65 class paths exist in 2.9.0, declare the named class, and none is `*Legacy`. The only `@Deprecated` hit is a field (`MTECircuitAssemblyLine.java:117`). Every concrete class is instantiated by a loader; abstract bases (`MTEFusionComputer`, `MTELargeFusionComputer`, `MTELargeTurbineBase`, `MTEXLTurbineBase`, `MTEBaseModule`) have registered subclasses. `TileEntityModuleAssembler` is registered through its inner `T1`-`T3` classes (`gtnhintergalactic/loader/MachineLoader.java:72-86`). The page spec's `controller` must name the inner class; the build's class regex accepts inner classes. - Spot-checked driver lines (Volcanus :254-260, HILE :358, sifter/PA/BHC/lathe/TPM/multi-smelter `getMaxParallelRecipes`) match. Most "Drivers" line numbers point at the method declaration, with the formula on the next lines. - The 10 existing calculators are all present (AAL, CAL, CoAL, PCB, HILE in batch 5; Waterline in 2; NFR in 7; Horus and Space Assembler in 8; LSC now in 1). - Batches were balanced by page count but not by effort: batch 4 (nine fixed-constant industrial multis, self-rated "low") against batch 8 (EoH, Forge of the Gods, DTPF, Horus, QC, Research Station, "very high"). Moved: LSC Wireless Balancer 7 → 1, Precise Auto-Assembler 5 → 3, Research Station and Quantum Computer 8 → 4. Effort points are rough estimates, not measurements.