本篇教程由作者设定使用 CC BY-NC-SA 协议。

控制器自定义
对控制器方块本身提供的修改, 详见下例.

{
    "registryname": "japanese_barbecue_stall",
    "localizedname": "Japanese Barbecue Stall",
    "controller": {
        "fullBlock": false, // 控制器是否为完整方块
        "alphaEnabled": true, // 控制器材质是否允许半透明
        "name": "japanese_barbecue_stall", // 自定义控制器注册名 (modularcontroller:japanese_barbecue_stall), 如两个机器的控制器注册名相同, 则两个机器共用一个控制器
        "translationKey": "tile.modularcontroller.japanese_barbecue_stall.name", // 自定义控制器未本地化名
        "lightValue": 15 // 自定义控制器方块亮度
    },
    "modifiers": []
}



CraftTweaker 事件

  • onMachineRecipeStart

导包: import mods.modularcontroller.MachineRecipeStartEvent;

*此事件可被取消*


ZenGetter

方法名返回类型描述
posIBlockPos
 获取 IBlockPos 格式的控制器坐标.
worldIWorld
获取 IWorld
recipeID
string
获取执行的配方的 ID ("modularmachinery:" 开头).
machineIDstring
获取执行配方的机器的 ID ("modularmachinery:" + 机器注册名).


ZenSetter

方法名描述
setFailed(String message)使配方执行失败(取消事件, 不输出产物), 并发送一条失败消息.


  • onMachineRecipeComplete

导包: import mods.modularcontroller.MachineRecipeCompleteEvent;

*此事件不可被取消*


ZenGetter

方法名返回类型描述
posIBlockPos
 获取 IBlockPos 格式的控制器坐标.
worldIWorld
获取 IWorld
recipeID
string
获取执行的配方的 ID ("modularmachinery:" 开头).
machineIDstring
获取执行配方的机器的 ID ("modularmachinery:" + 机器注册名).

成型音效


向对应定义机器的 JSON 文件中, 添加 "activated_sound" 元素.

所有 /ct soundevents 输出的音效均可使用.


本模组添加的音效:

modularcontroller:machine_activated_industry
modularcontroller:machine_activated_science_fiction
modularcontroller:machine_activated_steam


使用例:

{
    "registryname": "japanese_barbecue_stall",
    "localizedname":"placeholder",
    "activated_sound": "modularcontroller:machine_activated_science_fiction",
    "color": "535353",
    "parts": []
}



自定义模型和材质

*要使用此功能, 需要安装 ResourcesLoader 模组.*


  • Blockstates

进入 .minecraft/resources/modularcontroller/blockstates/ 文件夹, 找到机器注册名对应的 JSON 文件.

{
  "forge_marker": 1,
  "defaults": {
    "model": "modid:filenamedefault" // 方块被放置在世界中时使用的模型
  },
  "variants": {
    "facing=north": {
      "model": "modid:filenamenorth" // 方块朝北放置时使用的模型
    },
    "facing=south": {
      "model": "modid:filenamesouth", // 方块朝南放置时使用的模型
      "y": 180
    },
    "facing=west": {
      "model": "modid:filenamewest", // 方块朝东放置时使用的模型
      "y": 270
    },
    "facing=east": {
      "model": "modid:filenameeast", // 方块朝西放置时使用的模型
      "y": 90
    },
    "inventory": [
      {
        "transform": "forge:default-block" // 方块在物品栏中显示时使用的模型
      }
    ]
  }
}

"model": "modid:filenamedefault" 实际指向 .minecraft/resources/modid/models/block/filenamedefault.json, "modid" 和 "filename" 均可凭自己喜好更改.


  • 模型

打开对应模型文件, 以下为示例:

{
    "textures": {
        "all": "modid:blocks/testmmall", // 实际指向 .minecraft/resources/modid/textures/blocks/testmmall.png, 以下同理
        "north": "modid:blocks/testmmnorth",
        "east": "modid:blocks/testmmeast",
        "south": "modid:blocks/testmmsouth",
        "west": "modid:blocks/testmmwest",
        "up": "modid:blocks/testmmup",
        "down": "modid:blocks/testmmdown",
    },
    "elements": [ // 一整个方块的模型及 UV 数据, 非更换自定义模型请勿改动
        {
            "from": [0, 0, 0],
            "to": [16, 16, 16],
            "faces": {
                "north": {"uv": [0, 0, 16, 16], "texture": "#0"},
                "east": {"uv": [0, 0, 16, 16], "texture": "#0"},
                "south": {"uv": [0, 0, 16, 16], "texture": "#0"},
                "west": {"uv": [0, 0, 16, 16], "texture": "#0"},
                "up": {"uv": [0, 0, 16, 16], "texture": "#0"},
                "down": {"uv": [0, 0, 16, 16], "texture": "#0"}
            }
        },
        {
            "from": [0, 0, 0],
            "to": [16, 16, 16],
            "faces": {
                "north": {"uv": [0, 0, 16, 16], "texture": "#north"},
                "east": {"uv": [0, 0, 16, 16], "texture": "#east"},
                "south": {"uv": [0, 0, 16, 16], "texture": "#south"},
                "west": {"uv": [0, 0, 16, 16], "texture": "#west"},
                "up": {"uv": [0, 0, 16, 16], "texture": "#up"},
                "down": {"uv": [0, 0, 16, 16], "texture": "#down"}
            }
        }
    ]
}