
Parallel API A tiny shared API that lets machine mods and accelerator mods boost each other without ever depending on one another.
English What this is Parallel API is a small library mod. It adds no blocks, no items, and no recipes. It exists to solve one specific problem: letting an accelerator know how to speed up a machine, without the accelerator having to know which machine mod it is talking to.
If you are a player, you probably installed this because another mod requires it. That is expected — this mod does nothing on its own.
The problem it solves Say you have a machine mod and an accelerator mod.
If the accelerator depends directly on the machine mod, three things go wrong:
The accelerator can only ever boost that one machine mod. Any machine mod released later gets nothing. Every time the machine mod updates, the accelerator has to be rebuilt and re-released. The accelerator becomes an addon of a specific machine mod rather than a standalone accelerator. There is a worse failure, too. If both mods define their own copy of the same interface, the accelerator registers with one and the machine queries the other. The result:
The acceleration silently does nothing, and no error is reported. The game starts, the machine runs, and the multiplier is simply always 1.
That kind of bug is extremely hard to track down, because nothing appears broken.
How this mod fixes it Parallel API holds the interface in one place, and both sides depend on it:
复制 machine mod ─┐ ├─→ Parallel API ←─ accelerator mod machine mod ─┘ A machine mod never needs to know an accelerator exists. An accelerator never needs to change a single line for a new machine mod. Any machine mod that adopts this API is automatically boosted by every accelerator that supports it.
For players
Requires no configuration. Install it and forget it.
Adds nothing to the game on its own. No blocks, no items, no recipes, no world generation.
Safe to add or remove from an existing world, subject to the mods that depend on it.
Requirements
Mod Version Notes
Minecraft 1.21.1 NeoForge only
NeoForge 21.1+
Flux Networks Ultimate Addon 1.0.0+ Required — see below
Flux Networks 8.0.0+
Why Flux Networks Ultimate Addon is required: parallelism values are multiplied together and grow extremely fast, so ordinary integers are not wide enough to hold them. The large-number type this API uses comes from Flux Networks Ultimate Addon's embedded overlay, not from Flux Networks itself. Because that type appears directly in this API's public interface, a missing mod is a crash at load rather than a graceful fallback.
Numbers can get very large Parallelism is multiplicative. Several accelerators stack by multiplying, not adding.
As a concrete example: the top tier of a compressed-torch accelerator contributes 172,186,884x. Two of them together are that number squared — about 2.96e16 — which is far beyond what a 32-bit integer can hold (about 2.1e9).
Parallel API therefore carries these values in an unbounded representation throughout, and narrows only once, at the few boundaries that genuinely require an ordinary integer.
What to expect: placing a single top-tier accelerator should show a multiplier of exactly 172,186,884 in the machine's interface. If you see its square (about 2.96e16) instead, the accelerator registered twice — please report that to its author.
For mod developers Declare the dependency:
toml 复制 [[dependencies.${mod_id}]] modId="parallelapi" type="required" versionRange="[1.0.0,)" ordering="AFTER" side="BOTH" Machine mods publish their parallel count and let the API fold in every registered source:
java 复制 AbsoluteInteger result = ParallelismRegistry.apply(machine, baseParallelism); Accelerator mods implement one method and register it:
java 复制 private static final ParallelismProvider PROVIDER = MyAccelerator::multiplier; ParallelismRegistry.registerProvider(PROVIDER); Two mistakes that fail silently Both of these produce a mod that loads, runs, and is quietly wrong.
- Registering an inline method reference. The registry de-duplicates providers by object identity, and Java evaluates a method reference to a new object every time the expression runs. If the registration code ever runs twice — a development hot-reload is enough — an inline reference registers a second provider and the multiplier is applied twice. A 4x accelerator silently becomes 16x.
Store the provider in a static final field, and guard registration with a flag.
- Handing out a cached value. The large-number type is mutable: several of its operations modify the object in place. If a provider returns its own cached instance, any caller that mutates it corrupts the multiplier that every machine on the server sees, permanently.
Return a fresh instance per call, and copy before exposing any cached value.
One more thing to be aware of Your provider will be called on the client, not only on the server — a machine's screen asks for the multiplier while rendering. The block entity's level field can also be null during menu construction. Handle both.
中文 这是什么 Parallel API 是一个很小的库模组。它不添加任何方块、物品或配方。
它只解决一个问题:让加速件知道如何加速一台机器,而加速件不需要知道自己在和哪个机器模组打交道。
如果你是玩家,你多半是因为别的模组需要它才装上的。这是正常的——它本身不产生任何游戏内容。
它解决的问题 假设你有一个机器模组和一个加速件模组。
如果加速件直接依赖机器模组,会出现三个问题:
加速件只能加速这一个机器模组。之后出现的其它机器模组它一个都帮不上。 机器模组每次更新,加速件都得跟着重新构建、重新发布。 加速件变成了"某个特定机器的附属",而不是一个独立可用的加速件。 还有更糟的情况。如果两个模组各自定义了一份同名接口,就会出现:加速件注册到其中一份,机器去另一份里查询。结果是:
加速完全不生效,而且不报任何错误。游戏能启动,机器能运行,倍率永远是 1。
这类问题极难排查,因为表面上一切正常。
这个模组如何解决 Parallel API 把接口集中在一处,双方都依赖它:
复制 机器模组 ─┐ ├─→ Parallel API ←─ 加速件模组 机器模组 ─┘ 机器不需要知道加速件的存在,加速件也不需要为新机器改一行代码。任何接入本接口的机器模组,都会自动获得所有支持它的加速件的加成。
对玩家而言
无需配置,装上即可。
本身不向游戏添加任何内容:没有方块、没有物品、没有配方、没有世界生成。
对已有存档可以安全地添加或移除(取决于依赖它的模组)。
前置要求
模组 版本 说明
Minecraft 1.21.1 仅 NeoForge
NeoForge 21.1+
Flux Networks Ultimate Addon 1.0.0+ 必需,见下方说明
Flux Networks 8.0.0+
为什么必需 Flux Networks Ultimate Addon: 并行数是相乘关系,增长极快,普通整数装不下。本 API 使用的大数类型来自 Flux Networks Ultimate Addon 的内嵌 overlay,不在 Flux Networks 本体中。由于该类型直接出现在本 API 的公开接口里,缺少这个前置会导致加载阶段崩溃,而不是功能降级。
数值可能非常大 并行数是相乘的,多个加速件叠加是乘法而非加法。
举一个具体的例子:压缩火炬类加速件的最高档提供 172,186,884 倍。两个叠加就是它的平方,约 2.96e16,远超 32 位整数的范围(约 21 亿)。
因此 Parallel API 全程使用无上限的数值表示,只在少数真正必须使用普通整数的边界处收窄一次。
你应该看到什么: 放置一个最高档加速件后,机器界面显示的倍率应当恰好是 172,186,884。如果你看到的是它的平方(约 2.96e16),说明该加速件被重复注册了,请向其作者反馈。
模组开发者说明 声明依赖:
toml 复制 [[dependencies.${mod_id}]] modId="parallelapi" type="required" versionRange="[1.0.0,)" ordering="AFTER" side="BOTH" 机器模组公开自身的并行数,由 API 乘入所有已注册来源:
java 复制 AbsoluteInteger result = ParallelismRegistry.apply(machine, baseParallelism); 加速件模组实现一个方法并注册:
java 复制 private static final ParallelismProvider PROVIDER = MyAccelerator::multiplier; ParallelismRegistry.registerProvider(PROVIDER); 两个会静默失败的错误 这两种写法都会让模组正常加载、正常运行,而结果是错的。
一、内联写方法引用。 注册表按对象身份去重,而 Java 每次求值方法引用都会产生新对象。如果注册代码执行两次(开发时热重载就足够了),内联引用会注册出第二个加速件,倍率被应用两遍——4 倍的加速件悄悄变成 16 倍。
请把 provider 存到 static final 字段,并用标志位保证只注册一次。
二、交出缓存的数值对象。 大数类型是可变的:它的若干运算会就地修改对象。如果 provider 返回自己缓存的那个实例,任何调用方改一下,就会永久污染服务器上所有机器看到的倍率。
请每次返回新实例,对外暴露缓存值前先复制。
还有一点需要注意 你的 provider 会在客户端被调用,不只在服务端——机器界面渲染时会查询倍率。同时,菜单构造期间机器的世界字段可能为空。这两种情况都要处理。
