Revelationary JS
使用 KubeJS 调用 Revelationary API 以创建可被隐藏的方块和物品。
Revelationary Wiki
例子
服务端脚本
ServerEvents.revelation(event => {
event.registerFromJson({
"block_states": {
"minecraft:grass": "minecraft:beacon",
"minecraft:tall_grass": "minecraft:obsidian",
"minecraft:tall_grass[half=upper]": "minecraft:netherite_block"
},
"items": {
"minecraft:nether_star": "minecraft:gunpowder"
},
"advancement": "minecraft:nether/root"
})
event.register("minecraft:adventure/root", revBuilder => {
revBuilder
.cloakBlockState("minecraft:grass", "minecraft:beacon")
.cloakItem("minecraft:nether_star", "minecraft:gunpowder")
.cloakItem("minecraft:diamond_ore", "minecraft:stone")
.replaceItemName("minecraft:nether_star", "block.minecraft.poppy")
.replaceItemName("minecraft:diamond_ore", "Probably Stone?")
.replaceItemName("minecraft:grass", "block.minecraft.dandelion")
.replaceItemName("minecraft:gold_ore", "Since Gold Ore is not in the items tag above, you should never see this")
.replaceBlockName("minecraft:grass", "block.minecraft.dandelion")
})
let count = 0;
event.onReveal((doneAdvancements, revealedBlocks, revealedItems, isJoinPacket) => {
console.log("Hey " + (++count))
})
})
启动脚本
// 注册一个被隐藏的方块
StartupEvents.registry("block", event => {
event
.create("revjs:example_block", "cloaked")
.cloakAdvancement("story/smelt_iron")
.cloakedBlockTranslation("I'm stone stairs!")
// Or just 'cloakBlock("stone_stiars")'
.blockStateCloak(Block.id("revjs:example_block"), Block.id("stone_stairs", { "facing": "west" }))
.onCloak((cloakedBlock, cloakAdvancement, cloakBlock) => { })
.onUnCloak((cloakedBlock, cloakAdvancement, cloakBlock) => { })
})
// 注册一个被隐藏的物品
StartupEvents.registry("item", event => {
event
.create("revjs:example_item", "cloaked")
.cloakAdvancement("story/smelt_iron")
.cloakedItemTranslation("I'm diamond!")
.cloakItem("diamond")
.onCloak((cloakedItem, cloakAdvancement, cloakItem) => { })
.onUnCloak((cloakedItem, cloakAdvancement, cloakItem) => { })
})