forked from CleanroomMC/Multiblocked
-
Notifications
You must be signed in to change notification settings - Fork 0
更改多方块结构
Hidocmatn edited this page Aug 2, 2024
·
2 revisions
你可以当配方结束时改变多方块结构,例如通过给多方块结构设置其被"污染"的概率从而造成效率损失或其他后果。此处有一个当配方完成时改变多方块结构的例子(当然,你也可以通过其他KubeJS事件在机器没有运行时去更改多方块结构,不建议在机器配方运行时更改结构,因为那样会造成很多问题,建议在相对"安全"的阶段进行更改,例如示例中的配方完成事件的post阶段)
onEvent("mbd.recipe_finish.post.tester.updatable", event => {
let gold = Block.getBlock('minecraft:gold_block')
let diamond = Block.getBlock('minecraft:diamond_block')
let netherite = Block.getBlock('minecraft:netherite_block')
let controller = event.getRecipeLogic().controller
let iron = Block.getBlock('minecraft:iron_block')
let level = event.getRecipeLogic().controller.self().getLevel()
let poses = controller.getMultiblockState().getCache()
for (const pos of poses) {
var find = false
var block = level.getBlockState(pos).getBlock()
if (diamond.equals(block)) {
level.setBlock(pos, gold.defaultBlockState(), 3)
break;
}
if (netherite.equals(block)) {
level.setBlock(pos, diamond.defaultBlockState(), 3)
break;
}
}
})