Skip to content

条件与内容路由 ​

当前 API Minecraft 1.21.1 / MBD2 21.1.1
Recipe Viewer UI 编辑器中的命名内容显示区域
`uiName` 选择显示区域;`slotName` 独立选择 Trait handler 路由。
js
ServerEvents.recipes(event => {
  event.recipes.example.weather_machine()
    .id('example:weather_machine/storm_charge')
    .duration(400)
    .inputItems('minecraft:lightning_rod')
    .slotName('catalyst', r => r.inputItems('minecraft:amethyst_shard'))
    .uiName('main_output', r => r.outputItems('minecraft:creeper_spawn_egg'))
    .dimension('minecraft:overworld')
    .biome('minecraft:plains')
    .machineLevel(2)
    .positionY(64, 320)
    .raining(1, 15)
    .thundering(1, 15)
    .blocksInStructure(4, 16, 'minecraft:copper_block')
    .machineData({ mode: 'storm' }, true)
    .dayTime(false)
    .light(0, 15, 0, 15, true)
    .redstoneSignal(1, 15)
})
修饰器匹配对象常见错误
slotNameTrait definition 暴露的 recipe slot name误填 Trait 名称
uiNameRecipe Viewer UI 的内容控件名误以为它选择存储
machineData(data, true)只检查 machine.customData把它当成配方 data
blocksInStructure已成型结构中的方块计数用在单方块机器上期待全世界扫描

条件按配方条件引擎执行。不要在 onTick 中重复实现天气、维度或红石判断。

Released under the MIT License.