Fuels
基本信息
| 属性 | 值 |
|---|---|
| 类 | gttweaker.mods.gregtech.Fuels |
| ZenClass | mods.gregtech.Fuels |
| ModOnly | @ModOnly("gregtech") |
| ZenMethod 数 | 6 |
| 目标 RecipeMap | GTRecipeConstants.Fuel(注意:不是 RecipeMaps,是 GTRecipeConstants 里的常量) |
| 动作类型 | 私有 AddRecipeAction extends AddMultipleRecipeAction → OneWayAction(不可撤销) |
| 提交字段 | metadata(FUEL_VALUE, ...) + metadata(FUEL_TYPE, ...),duration(0),eut(0) |
| 作者 | Stan Hebben |
6 个 ZenMethod
| # | ZenMethod | type | 对应发电机 |
|---|---|---|---|
| 0 | addDieselFuel(IItemStack output, IIngredient input, int euPerMillibucket) |
0 | 柴油机 |
| 1 | addGasTurbineFuel(IItemStack output, IIngredient input, int euPerMillibucket) |
1 | 燃气轮机 |
| 2 | addThermalGeneratorFuel(IItemStack output, IIngredient input, int euPerMillibucket) |
2 | Thermal Generator |
| 3 | addDenseFluidFuel(IItemStack output, IIngredient input, int euPerMillibucket) |
3 | 高能流体发电机 |
| 4 | addPlasmaGeneratorFuel(IItemStack output, IIngredient input, int euPerMillibucket) |
4 | 等离子发电机 |
| 5 | addMagicGeneratorFuel(IItemStack output, IIngredient input, int euPerMillibucket) |
5 | 魔法发电机 |
6 个方法签名完全相同,仅 type 不同(Fuels.java:107-113)。type 既是 FUEL_TYPE metadata 的值,也是 GENERATORS 数组的索引。
提交逻辑(Fuels.java:116-126)
GTValues.RA.stdBuilder()
.itemInputs(i.nextItem()) // input(IIngredient 展开后的第一个)
.itemOutputs(i.nextItem()) // output(可为 null)
.metadata(FUEL_VALUE, i.nextInt()) // euPerMillibucket
.metadata(FUEL_TYPE, i.nextInt()) // type
.duration(0)
.eut(0)
.addTo(GTRecipeConstants.Fuel);
duration 与 eut 被硬编码为 0 —— 燃料配方不需要这两项。
数值
| 数值 | 值 |
|---|---|
| ZenMethod 数 | 6 |
FUEL_TYPE 取值域 |
0–5 |
GENERATORS 数组 |
{"diesel", "gas turbine", "thermal", "dense fluid", "plasma", "magic"} |
duration |
恒 0 |
eut |
恒 0 |
FUEL_VALUE |
脚本参数 euPerMillibucket 直传 |
| 目标 map | GTRecipeConstants.Fuel |
| 可撤销 | 否 |
describe() |
"Adding " + GENERATORS[type] + " fuel " + input |
源码缺陷
- 文档承诺的行为无实现:6 个方法的 Javadoc 都写「If the given item does not contain any liquid, it will generate the equivalent of 1000 millibuckets.」(
Fuels.java:27-28等),但applySingleRecipe完全没读GTUtility.getFluidForFilledItem—— 只有itemInputs/itemOutputs两个物品字段,没有fluidInputs/fluidOutputs。容器装液体的行为由 GT5 本体处理,本方法只注册物品侧的燃料值。文档描述的是本类之外的兜底行为,容易被误读为本类实现。 output参数可为null(Javadoc 明示「optional, can be null」):itemOutputs(null)的行为依赖GTRecipeBuilder,源码无保护。AddMultipleRecipeAction中IItemStack分支调MineTweakerMC.getItemStack(ILiquidStack...)——若 internal 为 null 可能 NPE。GENERATORS[type]索引无边界检查(:113):type由 6 个方法硬编码传入(0–5),当前安全;但构造器是public,若被反射以其他 type 调用即ArrayIndexOutOfBoundsException。GENERATORS是private static final String[]可变数组:final只保证引用不变,数组内容仍可被反射改写。AddRecipeAction是private static class:与RA2Builder.RecipeAddAction/RecipeRemover.RecipeRemoveAction的public static风格不一致,但因不对外暴露故无实际影响。- 6 个方法全部委托同一个私有 Action,无差异化逻辑 —— 6 倍代码量换来 1 个
type参数,属可直接用循环注册的样板。
相关条目
- AddMultipleRecipeAction - 私有
AddRecipeAction的基类 - RA2 Builder - 对比:可撤销的通用路径
- 化学类机器 - 同属 GTRecipeMap 体系