模组兼容


本页面的内容并不全面,且可能不是最新的!

JEI / REI

本节事件均为 Client 事件,你需要把它们放在client_scripts文件夹。
// 隐藏物品和流体 // 1.19 的写法为 JEIEvents.hide('item', event =>{}) // 如果是 REI,就将 jei 换成 rei onEvent('jei.hide.items', event => { event.hide('mod:item') // 对于 AE2 伪装板一类的靠 NBT 大肆刷屏的物品,试试这样 event.hide(Item.of('mod:item').ignoreNBT()) }) onEvent('jei.hide.fluids', event => { event.hide('mod:fluid') }) // 添加物品和流体 // 用来显示一些默认隐藏的物品,比如龙蛋 // 或者添加某些因 NBT 不同而外貌/功能不同的物品 onEvent('jei.add.items', event => { event.add('mod:item') }) onEvent('jei.add.fluids', event => { event.add('mod:fluid') }) // 添加 JEI 信息 onEvent('jei.infomation', event => { event.add('mod:item', ['message1', 'message2']) // 如果只有一条信息可以不用数组 }) // 隐藏整个配方类型,比如在 Twilight Forest 的拆解台上进行的配方。 onEvent('jei.hide.categories', event => { event.hide('mod:category') // 如果你不知道配方类型的 ID 的话 console.log(event.getCategoryIds()) // 这会在日志中打印所有的配方类型 // 你也可以看配方 JSON 文件里面的 type 的值 })
以下事件只适用于 REI,在 1.16,REI 兼容只能在 Fabric 使用,对于 1.18+,Forge 和 Fabric 都可使用。
onEvent('rei.group', event => { // This event allows you to add custom entry groups to REI, which can be used to clean up the entry list significantly. // As a simple example, we can add a 'Swords' group which will contain all (vanilla) swords // Note that each group will need an id (ResourceLocation) and a display name (Component / String) event.groupItems('kubejs:rei_groups/swords', 'Swords', [ 'minecraft:wooden_sword', 'minecraft:stone_sword', 'minecraft:iron_sword', 'minecraft:diamond_sword', 'minecraft:golden_sword', 'minecraft:netherite_sword' ]) // An easy use case for grouping stuff together could be using tags: // In this case, we want all the Hanging Signs and Sign Posts from Supplementaries to be grouped together event.groupItemsByTag('supplementaries:rei_groups/hanging_signs', 'Hanging Signs', 'supplementaries:hanging_signs') event.groupItemsByTag('supplementaries:rei_groups/sign_posts', 'Sign Posts', 'supplementaries:sign_posts') // Another example: We want all of these items to be grouped together ignoring NBT, // so you don't have a bajillion potions and enchanted books cluttering up REI anymore const useNbt = ['potion', 'enchanted_book', 'splash_potion', 'tipped_arrow', 'lingering_potion'] useNbt.forEach(id => { const item = Item.of(id) const { namespace, path } = Utils.id(item.id) event.groupSameItem(`kubejs:rei_groups/${namespace}/${path}`, item.name, item) }) // Items can also be grouped using anything that can be expressed as an IngredientJS, // including for example regular expressions or lists of ingredients event.groupItems('kubejs:rei_groups/spawn_eggs', 'Spawn Eggs', [ /spawn_egg/, /^ars_nouveau:.*_se$/, 'supplementaries:red_merchant_spawn_egg' ]) // you can even use custom predicates for grouping, like so: event.groupItemsIf('kubejs:rei_groups/looting_stuff', 'Stuff with Looting I', item => // this would group together all items that have the Looting I enchantment on them item.hasEnchantment('minecraft:looting', 1) ) // you can also group fluids in much the same way as you can group items, for instance: event.groupFluidsByTag('kubejs:rei_groups/fluid_tagged_as_water', '\'Water\' (yeah right lmao)', 'minecraft:water') })

Create

需要安装 KubeJS Create
如无特殊说明,本节所有事件均为 Server 事件。
onEvent('recipes', e =>{ // 粉碎轮粉碎 // 如果只有一个输出物品,可以不用数组,这也适用于很多其他配方 e.recipes.createCrushing([ 'minecraft:apple', '3x minecraft:gold_ingot', Item.of('minecraft:gold_nugget').withChance(0.25) ], 'minecraft:golden_apple') }) 基础知识 KJSEXP 暂无