Skip to content

修改枪械工作台配方例子

使用 KubeJS 配方管理 API 修改配方的例子。

配方 ID 可通过安装 Just Enough Items 并启用 高级提示框 后使用 Just Enough Items 的 显示物品配方 功能查看。

下面的代码使用 CC0 1.0 授权,你可以随意使用它们。

移除特定配方

js
// server_scripts/recipes.js
ServerEvents.recipes((event) => {
  // 移除 "磐石" 双管霰弹枪 的配方
  event.remove({ id: "create_armorer:gun/shotgun_db_stone" });
});

添加配方

具体的 JSON 结构可以参考 TaCZ 的文档

js
// server_scripts/recipes.js
ServerEvents.recipes((event) => {
  // 添加 "磐石" 双管霰弹枪 的配方
  event.custom({
    type: "tacz:gun_smith_table_crafting",
    materials: [
      { item: { item: "minecraft:apple" }, count: 3 },
      { item: { item: "minecraft:oak_button" }, count: 1 },
    ],
    result: {
      type: "gun",
      id: "create_armorer:shotgun_db_stone",
      count: 1,
    },
  });
});

修改已存在的配方

只需要结合 移除特定配方添加配方 即可。

js
// server_scripts/recipes.js
ServerEvents.recipes((event) => {
  // 移除原 "磐石" 双管霰弹枪 的配方
  event.remove({ id: "create_armorer:gun/shotgun_db_stone" });

  // 添加新的 "磐石" 双管霰弹枪 的配方
  event.custom({
    type: "tacz:gun_smith_table_crafting",
    materials: [
      { item: { item: "minecraft:apple" }, count: 3 },
      { item: { item: "minecraft:oak_button" }, count: 1 },
    ],
    result: {
      type: "gun",
      id: "create_armorer:shotgun_db_stone",
      count: 1,
    },
  });
});

赞助 ❤️

喜欢 TaCZ JS 吗?你可以在 爱发电 对我进行赞助,助力模组持续更新!

金主爸爸

Released under the CC BY-NC-SA 4.0.