GT 模块(appeng.integration.modules.GT)
基本信息
| 属性 | 值 |
|---|---|
| 源码 | appeng/integration/modules/GT.java |
| 类声明 | 20,public class |
| 实现接口 | IIntegrationModule + IGT(integration/abstraction/IGT.java:17) |
| 静态单例 | public static GT instance |
| modID | gregtech(IntegrationType.java:60,显示名 GregTech) |
| side | BOTH |
| 本 wiki 收录情况 | GregTech 未被本 wiki 收录 —— 写全名 GregTech |
生命周期
| 阶段 | 行号 | 动作 |
|---|---|---|
init() |
33 | GT6 版本排除 + LayerIEnergyConnected 注册 |
postInit() |
42 | movable().addHandler(new NBTSpatialHandler(IGregTechTileEntity.class)) |
注入内容 0:GT6 版本排除(在构造器里,最先执行)
// GT.java:26-30
@Reflected
public GT() throws Throwable {
IntegrationHelper.testClassExistence(this, gregtech.api.interfaces.tileentity.IEnergyConnected.class);
String ver = Loader.instance().getIndexedModList().get("gregtech").getVersion();
if (ver.contains("GT6-MC1710")) throw new ModNotInstalled("gregtech");
}
| 行号 | 动作 |
|---|---|
| 22 | @Reflected 注解在 instance 字段上(:23)—— 供 ASM 转换器反射改写 |
| 25 | @Reflected 注解在构造器上 |
| 26 | 构造器声明,throws Throwable |
| 27 | IntegrationHelper.testClassExistence(...)(空操作,见下) |
| 28 | 取 gregtech 版本串 |
| 29 | 版本含 GT6-MC1710 → throw new ModNotInstalled("gregtech") |
GT6-MC1710 版本的 GregTech 被显式拒绝。
⚠️ getIndexedModList().get("gregtech") 没有判空。若 gregtech
完全没装,这里会 NullPointerException。实际安全,因为
IntegrationNode 的 Loader.isModLoaded 已先拦下。
⚠️ :27 的 IntegrationHelper.testClassExistence 是空操作
(integration/IntegrationHelper.java:15-17 丢弃了 isInstance 的返回值),
唯一作用是触发 IEnergyConnected.class 类字面量解析。
注入内容 1:part layer
// GT.java:34-38
if (IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.GT)) {
AEApi.instance().partHelper().registerNewLayer(
"appeng.parts.layers.LayerIEnergyConnected",
"gregtech.api.interfaces.tileentity.IEnergyConnected");
}
| AE2 侧 layer | GT 侧接口 |
|---|---|
appeng.parts.layers.LayerIEnergyConnected |
gregtech.api.interfaces.tileentity.IEnergyConnected |
注入内容 2:空间搬运 handler
// GT.java:43
AEApi.instance().registries().movable().addHandler(new NBTSpatialHandler(IGregTechTileEntity.class));
让 GT 机器能被 AE2 空间 IO 搬运。IGregTechTileEntity 是
gregtech.api.interfaces.tileentity 的类型(GT.java import 段)。
GT 是唯一用 @Integration 注解剥离的目标
全仓库 @Integration 只有 2 处,都是 GregTech:
| 被注解类 | 位置 | 剥离行为 |
|---|---|---|
appeng/tile/powersink/GTPowerSink.java:11 |
implements IEnergyConnected |
ASMIntegration.stripInterface(transformer/asm/ASMIntegration.java:143)→ 集成禁用时 classNode.interfaces.remove(...)(:173) |
appeng/parts/layers/LayerIEnergyConnected.java:14 |
同上接口 | 同上 |
机制与源码见 IGT 条目。
GT6 排除在构造阶段,不在 init()
GT.java 的方法顺序是:字段 → 构造器(:26)→ init()(:33)→
postInit()(:42)。版本检查在构造器里(:28-29),
比 IntegrationNode 调的 mod.init() 更早。
IntegrationNode 在 PRE_INIT 里做
newInstance()(integration/IntegrationNode.java:83),
所以构造器抛的 ModNotInstalled 与 init() 抛的被
IntegrationNode.java:102 的 catch (Throwable) 同样捕获 → FAILED。
mod 没装时是否安全跳过
是,两条路径:
- gregtech 未装 →
Loader.isModLoaded为false→FAILED(类不加载) - 装了但是 GT6-MC1710 → 构造器抛
ModNotInstalled(GT.java:21)→FAILED
独立的 GT5 P2P 隧道
parts/p2p/PartP2PGT5Power.java + PartType.P2PTunnelGT
(core/api/definitions/ApiParts.java:114)是 GT5 专用隧道,
不走 abstraction/ 也不由本模块注册。
对应条目:P2P 隧道(GT)、 AEFeature.P2PTunnelGregtech。