GTNH 多方块 API

基本信息

属性 值
包路径 com.gtnewhorizons.horizonqa.api.gt
入口 GameTestHelper.gtnh() 返回 GTNHGameTestHelper
适配器实现 api/gt/adapter/GT5UnofficialAdapter.java(目标 GTNH GT5-Unofficial)
适配器接口 api/gt/adapter/GTAdapter.java
版本异常 api/gt/adapter/GTVersionMismatchException.java
公开方法数 20

[!IMPORTANT] 这是跨模组集成层:代码直接 import gregtech.api.*(如 IMetaTileEntity、 MTEMultiBlockBase、MTEHatchOutput),运行时必须存在 GregTech 5 Unofficial。 非 GT 环境下 helper.gtnh() 不可用。

功能

GTNHGameTestHelper 为 GregTech 机器的集成测试提供专用断言与世界操作, 底层通过 GTAdapter 抽象,当前唯一实现 GT5UnofficialAdapter 用反射在构造期解析所有查找 (GT5UnofficialAdapter.java:23:「resolves all reflective lookups at construction time」)。

公开方法

分组 方法
取得适配器 adapter
多方块结构 multiblock、multiBlockController、gtTile、metaTileEntity
结构形成 assertMachineFormed、assertMachineExploded、assertMachineHasIssues、assertCleanroomStatus
EU 电力 assertEUStored、supplyEU、fastForwardTicks
舱室 assertFluidInHatch、fillHatch
配方 withTestRecipe、withWarpRange、runUntilMachineIdle
维护 fixAllMaintenanceIssues
污染 assertPollutionEmitted
输入总线 assertItemInBus
电路 insertProgrammedCircuit
工具 rotateStructureTileNbt

完整方法名清单(grep -n '^ public ' GTNHGameTestHelper.java): adapter assertCleanroomStatus assertEUStored assertFluidInHatch assertItemInBus assertMachineExploded assertMachineFormed assertMachineHasIssues assertPollutionEmitted fastForwardTicks fillHatch fixAllMaintenanceIssues gtTile insertProgrammedCircuit metaTileEntity multiBlockController multiblock rotateStructureTileNbt runUntilMachineIdle supplyEU withTestRecipe withWarpRange

支撑类型

api/gt 包下的支撑类型共 11 个(ls src/main/java/com/gtnewhorizons/horizonqa/api/gt/):

类型 用途
Multiblock 多方块结构描述
Bus / BusGroup 输入 / 输出总线
Hatch 舱室(按类型索引)
ItemMatcher 物品匹配器
MaintenanceType 维护问题类型
TestRecipeScope 注入测试配方的范围
TimeWarpHandler 配方加速(warp)句柄
VirtualEUDynamo 虚拟 EU 供给(测试用,不建实体)
WarpDiffer warp 前后差异对比

GT 事件

api/event/ 下共 37 个类型(34 个事件记录 + TestEvent 标记接口 + EventLog 只读视图接口, ls src/main/java/com/gtnewhorizons/horizonqa/api/event/),其中直接对应 GT 机器行为的包括:

BusInserted EUBufferOverflow EUSupplyJobRegistered HatchFilled HatchVoltageMismatch MachineDeformed MachineDisabled MachineExploded MachineFormed PollutionEmitted ProgrammedCircuitSet RecipeStarted RecipeFinished RecipeProgressed RecipeAborted RecipeNotFound WarpStarted WarpFinished MaintenanceFixed MaintenanceIssueAppeared CleanroomEfficiencyChanged

对应的状态快照类型在 api/event/state/:DeformedCause ExplodedCause FormedCause HatchTopology MaintenanceSnapshot RecipeStateSnapshot(6 个)。

数值

数值名 值 来源
GTNHGameTestHelper 公开方法数 20 grep -n '^ public ' GTNHGameTestHelper.java
api/event 类型数 37 ls src/main/java/com/gtnewhorizons/horizonqa/api/event/*.java | wc -l
api/event/state 快照类型数 6 ls src/main/java/com/gtnewhorizons/horizonqa/api/event/state/
api/gt 类型数 11 ls src/main/java/com/gtnewhorizons/horizonqa/api/gt/*.java | wc -l
GTAdapter 实现数 1(GT5UnofficialAdapter) api/gt/adapter/ 目录

交互

GT5UnofficialAdapter 通过反射访问 GT 内部结构,代表性字段:

  • POLLUTION_CLASS = "gregtech.common.pollution.Pollution"(GT5UnofficialAdapter.java:26)
  • FACING_NBT_KEY = "mFacing"(GT5UnofficialAdapter.java:27)
  • 直接 import 的类型:IMetaTileEntity、IGregTechTileEntity、MTEExtendedPowerMultiBlockBase、 MTEHatchOutput、MTEMultiBlockBase(GT5UnofficialAdapter.java:14-18)

因为这些 import 是编译期硬依赖,GT5UnofficialAdapter 在未安装 GregTech 的环境下无法加载; GT 版本不匹配时抛 GTVersionMismatchException。

相关条目