Repository navigation
CraftTweaker API
.addFluidCatalystInput(ILiquidStack stack, string[] tooltips, RecipeModifier[] modifiers) as RecipePrimer
.addGasCatalystInput(IGasStack stack, string[] tooltips, RecipeModifier[] modifiers) as RecipePrimer
.setMaxCatalyst(int max) as RecipePrimer流体和气体催化剂与 MMCE 原版物品催化剂拥有相同的可选检查、chance 消耗和 modifier 语义。setMaxCatalyst 只限制一次运行最多实际激活的催化剂种类;配方仍可声明更多催化剂。未选中的催化剂不会抽取或应用 modifier。气体方法需要 Mekanism。
本模组扩展 MMCE 的 RecipePrimer 与 IMachineController。
.addMEChannelInput(int amount) as RecipePrimeramount 必须是大于 0 的整数。配方开始前会检查同一机器的全部频道仓是否位于同一 AE 网络且可提供足够频道;运行期间保持占用,不足时暂停。完整规则见 ME 频道输入仓。
mods.modularmachinery.RecipeBuilder.newBuilder(
"channel_recipe", "my_machine", 200
)
.addMEChannelInput(8)
.build();.withModule(string[] ids) as RecipePrimer
.withoutModule(string[] ids) as RecipePrimer-
withModule:数组内模块必须全部生效(AND)。 -
withoutModule:数组内任意模块生效都会禁止配方。 - 两个方法都返回原
RecipePrimer,可继续链式调用。 - 可重复调用,条件会累加并去重。
- ID 不能空白,不能使用保留 ID
main。 - 同一个 ID 不能同时出现在需要与禁止集合中。
示例:
mods.modularmachinery.RecipeBuilder.newBuilder(
"distillation_with_cooling",
"distillation_tower",
200
)
.withModule(["cooling_compressor", "spacetime_pipe"])
.withoutModule(["low_pressure_pipe"])
.build();模块条件会在配方开始、重启以及运行过程中持续检查。运行中失去必需模块或出现禁止模块时,配方会返回相应失败状态。
controller.hasModule(string id) as bool
controller.moduleList as string[]判断模块当前是否生效。未声明、结构不完整、依赖不满足、冲突失效以及 main 都返回 false。
val upgraded as bool = controller.hasModule("advanced");返回当前已识别机器 JSON 中声明的全部附属模块 ID,保持 JSON 顺序,不含 main。注意它是“可用/已声明列表”,不是“当前生效列表”。控制器尚未识别机器时返回空数组。
需要所有当前生效模块时,遍历 moduleList 并逐个调用 hasModule。
MMEvents.onControllerGUIRender("elysia_reactor", function(event as ControllerGUIRenderEvent) {
var info as string[] = [
"§e///大型反应单元控制面板///",
"§a机器名称:§eELYSIA单元 - 大型反应单元",
"§a附属模块:" +
(event.controller.hasModule("advanced") ? "§e升级模块" : "§c无")
];
event.extraInfo = info;
});如果始终显示“无”,依次确认:主结构最近执行过检测、模块结构与旋转坐标正确、父模块生效、没有冲突模块、脚本 ID 与 JSON 大小写完全一致。可用 /data get block 或 NBT 工具检查控制器的 mmceComplementModules;有效模块应出现在该列表中。
注册机器专属数据名:
import mods.mmce_complement.RedstoneInterface;
RedstoneInterface.newRedstone(
"mymod:my_machine", "temperature"
).build(); // operator=0,最大值
RedstoneInterface.newRedstone(
"mymod:my_machine", "pressure", 1
).build(); // 最小值
RedstoneInterface.newRedstone(
"mymod:my_machine", "throughput", 2
).build(); // 求和在控制器事件 tick 中使用:
val input = controller.getRedstone("temperature");
controller.setRedstone("throughput", 15);setRedstone 只接受当前机器事件 tick 的输出,数值自动限制在 0~15;仓室标签必须与脚本名称一致。完整规则见 红石控制与信号接口。
MMCE Complement 为 RecipePrimer 提供以下输出修改器。修改器必须紧跟对应的流体或气体输出,多个修改器按声明顺序执行:
mods.modularmachinery.RecipeBuilder.newBuilder("dynamic", "my_machine", 200)
.addFluidOutput(<liquid:water> * 1000)
.addFluidModifier(function(controller, liquid) {
return <liquid:lava> * (liquid.amount * 2);
})
.addGasOutput(<gas:hydrogen> * 1000)
.addGasModifier(function(controller, gas) {
return <gas:oxygen> * (gas.amount * 2);
})
.build();-
.addFluidModifier(function(controller, liquid) as ILiquidStack)可修改流体种类、数量和 NBT;返回null或非正数量会取消该输出。 -
.addGasModifier(function(controller, gas))可修改气体种类和数量。为兼容可选 Mekanism 依赖,ZenScript 中参数/返回值表现为IIngredient,运行时必须是IGasStack。 - 修改结果会用于输出空间预检、并行数量计算和最终写入。
.setPreViewNBT(IData) 可用于物品和流体输入/输出:
recipe
.addFluidOutput(<liquid:water> * 1000)
.setPreViewNBT({Potion: "healing"});
recipe
.addGasOutput(<gas:hydrogen> * 1000)
.setGasTooltip("纯度:高", "经过压缩处理");流体 NBT 会显示在 JEI 流体槽中,不影响实际匹配或输出。气体不支持 .setPreViewNBT(IData);Mekanism GasStack 不支持任意 NBT,气体仅提供 Tooltip API。.addGasTooltip(String...) 追加提示行,.setGasTooltip(String...) 覆盖此前由本扩展添加的提示行;两者均支持气体输入和输出。
- 模块 ID 使用稳定的 ASCII
snake_case,发布后不要随意重命名。 -
moduleList适合动态 GUI/诊断,配方判定直接使用withModule/withoutModule。 - 不要把
as-upgrade与hasModule混为一谈:as-upgrade=false只关闭同名升级,不会阻止模块本身生效。 -
addMEChannelInput、红石注册和控制器红石 API 都应使用稳定名称;发布后修改名称会使旧机器 GUI 标签和脚本不再对应。
MMCE Complement 1.4.4 · GitHub · CurseForge · Releases · Issues
MMCE Complement 1.5.0
机制与组件
整合包开发
Language