AE2 Lightning Tech (AE2LT) 的插件 API 和运行时桥接库。让你的模组能够深度集成到 AE2LT 的闪电能量网络中,且无需直接访问其内部类。
Thunderbolt_lib 是任何扩展、修改或钩入 AE2LT 闪电系统的第三方插件的必需依赖项。它自身不附带任何物品、方块或配方——仅提供冻结的公共 API、NeoForge 能力合约(capability contracts)、配方构建器,以及在 AE2LT 缺失时能优雅降级(degrades gracefully)的反射运行时桥接器。
为什么下载这个?
- 玩家 / 整合包作者 — 如果某个模组或整合包将
ae2lt_api 列为依赖项,请将其与 AE2 Lightning Tech 一同安装。
- 插件开发者 — 依赖此库以访问 AE2LT 的机器、配方类型和闪电能量能力,且不与 AE2LT 的内部类耦合。
重要提示: 只有当 Minecraft 实例中也安装了 AE2 Lightning Tech 时,Thunderbolt_lib 才会发挥实际作用。两个模组必须同时存在。
目标平台
|
|
| Minecraft |
1.21.1 |
| 加载器 |
NeoForge 21.1.x |
| Java |
21 |
| 目标 |
AE2 Lightning Tech(自 AE2LT 引入其闪电网络以来向后兼容) |
| 运行时模组 ID |
ae2lt_api |
该项目名为 Thunderbolt_lib,但注册为 ae2lt_api,因此现有的插件依赖声明不受影响。
提供的内容
闪电能量能力
让你的方块和物品成为 AE2LT 闪电网络中的“一等公民”。ILightningEnergyHandler 通过两个 NeoForge 能力暴露出来——LIGHTNING_ENERGY_BLOCK(分侧 sided)和 LIGHTNING_ENERGY_ITEM(全局 void)——实现该接口并注册即可参与读写操作。所有数量均以 long 类型表示,可从单个机器平滑扩展到整个网络的账目计算。
闪电能量层级
一种统一的二层电压定义,可在 API 表面无损传输。LightningEnergyTier 是一个双值枚举(HIGH_VOLTAGE / EXTREME_HIGH_VOLTAGE),并提供:
CODEC — Mojang Codec<LightningEnergyTier>
STREAM_CODEC — 原版 StreamCodec<RegistryFriendlyByteBuf, LightningEnergyTier>
fromOrdinal(int) — 基于序数的静态解码器
它与 AE2LT 自身的 LightningTier 共享其在线格式,因此数据包和 NBT 在这两个 API 之间可以干净地往返转换,无需任何手写适配器。
反射运行时桥接
当 AE2LT 缺失时不会崩溃——而是优雅降级。而不是在加载时硬引用 AE2LT 的类,此库在运行时通过反射探测它们,并将闪电能量能力连接到 AE2LT 公开注册的五个网格连接实体上:
ae2lt:lightning_collector
ae2lt:lightning_simulation_room
ae2lt:lightning_assembly_chamber
ae2lt:overload_processing_factory
ae2lt:tesla_coil
ae2lt:crystal_catalyzer 仅运行于 FE(Forge Energy),不参与闪电能量网络,因此被有意排除。
冻结的 ID 常量
在不将 AE2LT 主 jar 拖入编译路径的情况下引用 AE2LT 的注册表 ID。两组 ResourceLocation 常量将所有内容收集在一处:
AE2LTBlockEntityIds — AE2LT 的方块实体 ID,以及 LIGHTNING_GRID_MEMBERS(上述五个网格连接机器的列表)
AE2LTRecipeIds — AE2LT 的配方类型 ID
两者均位于 com.qianchang.ae2lt_api.api.ids 中。如果 AE2LT 将来重命名任何内部资源,补丁将在此处落地,这样插件就不必去追逐这些变化。
原生 API 检测桥接
让你的模组中两种 API 表面共存,由你决定调用哪一个。com.qianchang.ae2lt_api.api.bridge.AE2LTNativeBridge 会在运行时检查 AE2LT 的官方 API 包(com.moakiee.ae2lt.api,命名空间 ae2lt)是否已加载。
| 表面 |
本库 |
AE2LT 官方 |
| Java 包 |
com.qianchang.ae2lt_api.api.* |
com.moakiee.ae2lt.api.* |
| 命名空间 |
ae2lt_api |
ae2lt |
| 能力 ID |
ae2lt_api:lightning_energy |
ae2lt:lightning_energy |
这两个 API 表面故意区分命名空间;本库不对它们执行隐式转换,因此调用者需显式选择使用哪一侧。
事件
拦截闪电收集过程并应用你自己的条件逻辑。当 AE2LT 收集器拾取闪电能量时,会触发 LightningCollectedEvent。该事件可取消,并提供 isNaturalWeather()(用于区分真正的雷暴和机器诱导的电击)以及匹配的 5 参数构造函数;保留原始的 4 参数构造函数,其中 naturalWeather 默认为 false,从而确保迁移无痛。
配方构建器
为所有六种 AE2LT 配方类型生成符合模式的 JSON —— 直接放入你的数据生成管道中:
| 构建器 |
配方类型 |
LightningAssemblyRecipeBuilder |
ae2lt:lightning_assembly |
LightningTransformRecipeBuilder |
ae2lt:lightning_transform |
LightningSimulationRecipeBuilder |
ae2lt:lightning_simulation |
OverloadProcessingRecipeBuilder |
ae2lt:overload_processing |
CrystalCatalyzerRecipeBuilder |
ae2lt:crystal_catalyzer |
LightningStrikeRecipeBuilder |
ae2lt:lightning_strike |
CrystalCatalyzerRecipeBuilder 额外支持 dustMode() 和 outputTag(...),以匹配 AE2LT 的 crystal_catalyzer/dust/*.json 模式。
插件加载与 API 外观
统一的注册回调,无需手动编写 NeoForge 生命周期接线。插件发现通过 @AE2LTPlugin、IAE2LTPlugin 和 Java ServiceLoader 运行;静态外观类 AE2LTAPI 将 API 版本、能力句柄和桥接工具收集到一个单一入口点,你可以只需一个 import static 即可引入,并在整个代码库中以极少的样板代码使用它。
作为依赖添加
插件开发者 — 请在您的 neoforge.mods.toml 中将 ae2lt_api(本库)和 ae2lt(主模组)都声明为必需依赖:
[[dependencies.your_mod_id]]
modId = "ae2lt_api"
type = "required"
versionRange = "[1.0.0,)"
ordering = "AFTER"
side = "BOTH"
[[dependencies.your_mod_id]]
modId = "ae2lt"
type = "required"
versionRange = "[1.0.0,)"
ordering = "AFTER"
side = "BOTH"
请将 versionRange 的下限设置为您的插件实际支持的最低版本。
反馈
欢迎在 项目问题追踪器 提交错误报告和建议。报告问题时,请附上您正在运行的 Minecraft、NeoForge、AE2 Lightning Tech 和 Thunderbolt_lib 的版本信息——这将大大加快复现和分类处理的速度。
源码、更新日志与发布记录
致谢
由 QianChang 维护并开发。
特别感谢 AE2 Lightning Tech 团队 —— MOAKIEE、CystrySU、gjmhmm8、_leng、TedXenon 和 MHanHanBing —— 他们发布了清晰、稳定的注册表 ID 和配方模式,使得本桥接成为可能。
同时也感谢 Applied Energistics 2 团队 —— 没有 AE2 就不会有 AE2LT,也就不会有这个桥接存在的理由。
免责声明
该名称仅用于非商业性的社区用途。如果任何权利持有人认为该名称构成侵权或不合适,请联系维护者,我们将迅速更改。
完整声明 — DISCLAIMER.md
Plugin API and runtime bridge library for AE2 Lightning Tech (AE2LT). Lets your mod integrate deeply with AE2LT's lightning energy network without ever touching its internal classes.
Thunderbolt_lib is a required dependency for any third-party plugin that extends, modifies, or hooks into AE2LT's lightning system. It ships no items, blocks, or recipes of its own — only frozen public APIs, NeoForge capability contracts, recipe builders, and a reflective runtime bridge that degrades gracefully when AE2LT itself is absent.
Why download this?
- Players / modpack authors — if a mod or modpack lists
ae2lt_api as a dependency, install this jar alongside AE2 Lightning Tech.
- Plugin developers — depend on this library to access AE2LT's machines, recipe types, and lightning energy capabilities without coupling to AE2LT's internal classes.
Important: Thunderbolt_lib only does meaningful work when AE2 Lightning Tech is installed in the same Minecraft instance. Both mods must be present.
Target
|
|
| Minecraft |
1.21.1 |
| Loader |
NeoForge 21.1.x |
| Java |
21 |
| Targets |
AE2 Lightning Tech (backwards-compatible since AE2LT introduced its lightning network) |
| Runtime mod ID |
ae2lt_api |
The project is presented as Thunderbolt_lib, but registers under ae2lt_api, so existing plugin dependency declarations are unaffected.
What it provides
Lightning energy capability
Make your blocks and items first-class citizens of the AE2LT lightning network. ILightningEnergyHandler is exposed via two NeoForge capabilities — LIGHTNING_ENERGY_BLOCK (sided) and LIGHTNING_ENERGY_ITEM (void) — implement the interface and register it to participate in reads and writes. All quantities are expressed as long, scaling cleanly from a single machine to network-wide accounting.
Lightning energy tier
A unified two-tier voltage definition that flows losslessly across API surfaces. LightningEnergyTier is a two-value enum (HIGH_VOLTAGE / EXTREME_HIGH_VOLTAGE), and ships with:
CODEC — Mojang Codec<LightningEnergyTier>
STREAM_CODEC — vanilla StreamCodec<RegistryFriendlyByteBuf, LightningEnergyTier>
fromOrdinal(int) — ordinal-based static decoder
It shares its on-the-wire format with AE2LT's own LightningTier, so packets and NBT round-trip cleanly between the two APIs without any hand-written adapter.
Reflective runtime bridge
Won't crash when AE2LT is missing — just degrades gracefully. Instead of hard-referencing AE2LT's classes at load time, this library probes them reflectively at runtime and wires the lightning energy capability onto the five grid-connected block entities AE2LT publicly registers:
ae2lt:lightning_collector
ae2lt:lightning_simulation_room
ae2lt:lightning_assembly_chamber
ae2lt:overload_processing_factory
ae2lt:tesla_coil
ae2lt:crystal_catalyzer runs on FE only, does not participate in the lightning energy network, and is intentionally excluded.
Frozen ID constants
Reference AE2LT's registry IDs without dragging its main jar onto your compile path. Two ResourceLocation constant sets collect everything in one place:
AE2LTBlockEntityIds — AE2LT's block-entity IDs, plus LIGHTNING_GRID_MEMBERS (the list of the five grid-connected machines above)
AE2LTRecipeIds — AE2LT's recipe-type IDs
Both live in com.qianchang.ae2lt_api.api.ids. If AE2LT later renames any internal resource, the patch lands here so plugins don't have to chase it.
Native API detection bridge
Lets both API surfaces coexist in your mod, leaving you in control of which one to call. com.qianchang.ae2lt_api.api.bridge.AE2LTNativeBridge checks at runtime whether AE2LT's first-party API package (com.moakiee.ae2lt.api, namespace ae2lt) is loaded.
| Surface |
This library |
AE2LT first-party |
| Java package |
com.qianchang.ae2lt_api.api.* |
com.moakiee.ae2lt.api.* |
| Namespace |
ae2lt_api |
ae2lt |
| Capability ID |
ae2lt_api:lightning_energy |
ae2lt:lightning_energy |
The two API surfaces are deliberately namespace-distinct; this library performs no implicit conversion between them, so callers explicitly choose which side to use.
Events
Intercept lightning collection and apply your own conditional logic. LightningCollectedEvent is fired when an AE2LT collector picks up lightning energy. The event is cancellable and exposes isNaturalWeather() (to distinguish a true thunderstorm from a machine-induced strike) along with the matching 5-argument constructor; the original 4-argument constructor is preserved with naturalWeather defaulted to false, so migration is painless.
Recipe builders
Generate schema-compliant JSON for all six AE2LT recipe types — drop them straight into your data generation pipeline:
| Builder |
Recipe type |
LightningAssemblyRecipeBuilder |
ae2lt:lightning_assembly |
LightningTransformRecipeBuilder |
ae2lt:lightning_transform |
LightningSimulationRecipeBuilder |
ae2lt:lightning_simulation |
OverloadProcessingRecipeBuilder |
ae2lt:overload_processing |
CrystalCatalyzerRecipeBuilder |
ae2lt:crystal_catalyzer |
LightningStrikeRecipeBuilder |
ae2lt:lightning_strike |
CrystalCatalyzerRecipeBuilder additionally supports dustMode() and outputTag(...), matching AE2LT's crystal_catalyzer/dust/*.json schema.
Plugin loading & API facade
Unified registration callbacks, no hand-rolled NeoForge lifecycle wiring. Plugin discovery runs through @AE2LTPlugin, IAE2LTPlugin, and Java ServiceLoader; the static facade AE2LTAPI collects the API version, capability handles, and bridge utilities into a single entry point you can pull in with one import static and use across your codebase with minimal boilerplate.
Adding as a dependency
Plugin developers — declare both ae2lt_api (this library) and ae2lt (the main mod) as required in your neoforge.mods.toml:
[[dependencies.your_mod_id]]
modId = "ae2lt_api"
type = "required"
versionRange = "[1.0.0,)"
ordering = "AFTER"
side = "BOTH"
[[dependencies.your_mod_id]]
modId = "ae2lt"
type = "required"
versionRange = "[1.0.0,)"
ordering = "AFTER"
side = "BOTH"
Set the lower bound of versionRange to the minimum version your plugin actually supports.
Feedback
Bug reports and suggestions are welcome on the project issue tracker. When reporting an issue, please include the versions of Minecraft, NeoForge, AE2 Lightning Tech, and Thunderbolt_lib you are running — it makes reproduction and triage much faster.
Source, changelog, releases
Credits
Maintained and developed by QianChang.
Special thanks to the AE2 Lightning Tech team — MOAKIEE, CystrySU, gjmhmm8, _leng, TedXenon, and MHanHanBing — for publishing clear, stable registry IDs and recipe schemas that make this bridge possible.
Thanks also to the Applied Energistics 2 team — without AE2 there would be no AE2LT, and no reason for this bridge to exist.
Disclaimer
This name is used for non-commercial community purposes only. If any rights holder considers the name to be infringing or unsuitable, please contact the maintainer and it will be changed promptly.
Full notice — DISCLAIMER.md
评论 0
登录后参与评分
还没有评论,来抢沙发吧