跳到正文

KubeJs Goety

作者:AmicBeam

为 Goety 模组提供 KubeJS 集成,可通过 JavaScript 脚本自定义 Goety 仪式需求、酿造系统和配方系统。

收藏

介绍

介绍由机器翻译自 CurseForge 原页面,仅供参考。

KubeJS Goety

Goety 模组的 KubeJS 集成。可通过 JavaScript 脚本自定义 Goety 的仪式需求、酿造系统和配方系统。

功能

  • ✅ 使用 GoetyEvents 事件系统
  • ✅ 创建和修改仪式类型,并完全自定义仪式条件检查逻辑
  • ✅ 配置酿造系统(容量修正、催化剂、强化效果)
  • ✅ 配置配方系统(仪式配方、酿造配方、粉碎配方等)
  • ✅ 支持服务端脚本(server_scripts)
  • ✅ 无需修改 Goety 模组本身

前置要求

  • Minecraft 1.20.1
  • Forge 47.1.65+
  • KubeJS 2001.6+
  • Goety 2.5.38+

安装

  1. 将模组放入 mods 文件夹
  2. 确保已安装 KubeJS 和 Goety 模组
  3. 启动游戏

仪式系统配置

GoetyEvents.modifyRitual 和 GoetyEvents.registerRitual

使用 GoetyEvents 事件系统自定义 Goety 仪式需求。

创建脚本文件

在世界存档目录中创建脚本文件:

your_world_save/
└── kubejs/
    └── server_scripts/
        └── goety_rituals.js

修改现有仪式条件

GoetyEvents.modifyRitual(event => {
    // event.modify(ritualId, modifier)
    // - ritualId: Ritual ID to modify (string)
    // - modifier: Modifier function that receives a ritual object
    
    // Modify using configuration style
    event.modify('storm', ritual => {
        ritual.blocks = ['8x #minecraft:copper_ores', '3x minecraft:lightning_rod'];
        ritual.setWeather('thunder');         // Requires thunder weather
        ritual.setMinY(128);                  // Height >= 128
        ritual.setRequireSkyVisible(true);    // Requires sky visibility
    });
    
    // Modify using custom function
    event.modify('magic', ritual => {
        ritual.setRequirement((tileEntity, pos, level) => {
            // Custom check logic
            // Return true if conditions are met, false otherwise
            return true;
        });
    });
});

创建新的仪式类型

GoetyEvents.registerRitual(event => {
    // event.create(ritualId, builder)
    // - ritualId: Unique identifier for the ritual (string)
    // - builder: Builder function that receives a ritual object
    
    // Create simple ritual (only needs blocks)
    event.create('diamond_ritual', ritual => {
        ritual.blocks = ['5x minecraft:diamond_block', '3x minecraft:emerald_block'];
    });
    
    // Create complex ritual (needs special conditions and completion effects)
    event.create('thunder_ritual', ritual => {
        ritual.blocks = ['minecraft:lightning_rod'];
        ritual.setWeather('thunder');         // Requires thunder weather
        ritual.setRequireSkyVisible(true);    // Requires sky visibility
        ritual.setJeiIcon('minecraft:lightning_rod');  // Set JEI display icon (optional)
        
        // Set callback when ritual completes (optional)
        // Note: This callback is triggered when the recipe completes, i.e., after the ritual successfully executes and produces results
        ritual.setOnFinish((world, darkAltarPos, tileEntity, castingPlayer, activationItem) => {
            // Get coordinates
            let x = darkAltarPos.getX ? darkAltarPos.getX() : darkAltarPos.x;
            let y = darkAltarPos.getY ? darkAltarPos.getY() : darkAltarPos.y;
            let z = darkAltarPos.getZ ? darkAltarPos.getZ() : darkAltarPos.z;
            
            // Use commands to play sound (server-side)
            let server = world.getServer ? world.getServer() : null;
            if (server) {
                server.runCommandSilent(`playsound minecraft:entity.lightning_bolt.thunder weather @a ${x} ${y} ${z} 1 1`);
            }
        });
    });
});

禁用内置仪式

若要禁用内置仪式,请使用 modifyRitual,使条件检查始终返回 false:

GoetyEvents.modifyRitual(event => {
    event.modify('storm', ritual => {
        ritual.requirement = () => false; // Always return false to disable ritual
    });
});

配置选项

ritual 对象支持以下配置选项:

  • ritual.range(整数):扫描范围(默认值为 16)
  • ritual.blocks(数组/字符串):方块需求配置
    • 支持的格式:'9x minecraft:stone'、'/pattern/'、'#tag'、'@mod'
    • 正则表达式示例:'16x /prismarine/' 可匹配所有名称中包含 prismarine 的方块
  • ritual.setDimension(dimensionId, containsMatch)(字符串、布尔值):维度限制
    • dimensionId:维度 ID,例如 ‘minecraft:the_nether’ 或 ‘aether’
    • containsMatch:false(精确匹配,默认值)或 true(模糊匹配)
  • ritual.setWeather(weather)(字符串):天气要求(’thunder’/’rain’/’clear’)
  • ritual.setTimeOfDay(timeOfDay)(字符串):时间要求(’day’/’night’)
  • ritual.setBiome(biomeValue, type)(对象、字符串):生物群系要求
    • biomeValue:生物群系值(可以是字符串或数组),或者方法名称(当 type=’func’ 时)
    • type:’id’(生物群系 ID,默认值)、’tags’(标签)、’func’(方法调用)
    • 方法调用:ritual.setBiome('coldEnoughToSnow', 'func') 会调用 biome.coldEnoughToSnow(pos) 方法
    • 支持调用 Biome 类中的任意布尔值方法,并通过反射调用
  • ritual.setMinY(y)(整数):最低高度要求
  • ritual.setMaxY(y)(整数):最高高度要求
  • ritual.setRequireSkyVisible(boolean)(布尔值):是否要求天空可见
  • ritual.setRequireAltarWaterlogged(boolean)(布尔值):祭坛是否必须含水
  • ritual.setJeiIcon(item)(字符串/对象):JEI 显示图标(物品 ID 或物品对象,可选,默认为黑曜石)
  • ritual.setOnFinish(callback)(函数):配方完成时触发的回调函数(即仪式成功执行并产生结果后),接收参数 (world, darkAltarPos, tileEntity, castingPlayer, activationItem)
  • ritual.setRequirement(function)(函数):自定义检查函数(覆盖所有配置)

本地化(可选)

如果你创建了新的仪式类型,并希望在 JEI 或游戏中显示英文名称,则需要添加本地化文件:

使用 KubeJS 资源包

在你的世界存档目录中创建资源包结构:

your_world_save/
└── kubejs/
    └── assets/
        └── goety/
            └── lang/
                └── en_us.json

在 en_us.json 中添加:

{
  "jei.goety.craftType.diamond_ritual": "Diamond Ritual",
  "jei.goety.craftType.flame_ritual": "Flame Ritual"
}

本地化键格式:

  • 键名:jei.goety.craftType.<ritualId>
  • 其中 <ritualId> 是创建仪式时使用的 ID

注意:

  • 如果不添加本地化,仪式名称将显示为仪式 ID(例如 diamond_ritual)
  • 本地化为可选项,不会影响仪式功能
  • 你可以只添加所需语言的文件

酿造系统配置

GoetyEvents.registerBrew

配置 Goety 的酿造系统,包括容量修正、催化剂和强化效果。

创建脚本文件

在你的世界存档目录中创建一个脚本文件:

your_world_save/
└── kubejs/
    └── server_scripts/
        └── goety_brews.js

注册容量修饰器

GoetyEvents.registerBrew(event => {
    // event.addCapacity(item, level)
    // - item: Item ID (string) or item object
    // - level: Level (0-7)
    
    event.addCapacity('minecraft:nether_wart', 0);
    event.addCapacity('mymod:magic_crystal', 6);
});

注册增强项

GoetyEvents.registerBrew(event => {
    // event.addAugmentation(item, modifier, level)
    // - item: Item ID (string) or item object
    // - modifier: Augmentation type (string)
    //   - 'capacity' - Capacity
    //   - 'duration' - Duration
    //   - 'amplifier' - Effect amplifier
    //   - 'aoe' - Area of effect
    //   - 'linger' - Linger effect
    //   - 'quaff' - Quaff effect
    //   - 'velocity' - Velocity
    //   - 'aquatic' - Aquatic
    //   - 'fire_proof' - Fire proof
    // - level: Level (integer)
    
    event.addAugmentation('minecraft:redstone', 'duration', 0);
    event.addAugmentation('mymod:time_crystal', 'duration', 3);
    event.addAugmentation('mymod:power_crystal', 'amplifier', 2);
});

完整示例

GoetyEvents.registerBrew(event => {
    // Capacity modifiers
    event.addCapacity('mymod:magic_crystal', 6);
    event.addCapacity('mymod:magic_dust', 5);
    
    // Augmentations
    event.addAugmentation('mymod:time_crystal', 'duration', 3);
    event.addAugmentation('mymod:power_crystal', 'amplifier', 2);
    event.addAugmentation('mymod:range_crystal', 'aoe', 1);
});

注意:

  • 添加容量修饰器和增强项 → 使用 GoetyEvents.registerBrew
  • 添加催化剂(酿造配方) → 使用 event.recipes.goety.brewing(参见下方的配方系统)

配方系统配置

ServerEvents.recipes

使用 KubeJS 标准配方事件配置 Goety 的配方系统。

创建脚本文件

在你的世界存档目录中创建脚本文件:

your_world_save/
└── kubejs/
    └── server_scripts/
        └── goety_recipes.js

仪式配方

ServerEvents.recipes(event => {
    // event.recipes.goety.ritual(result, ritualType, ingredients)
    // - result: Output item (OutputItem)
    // - ritualType: Ritual type ID, choose based on function:
    //   - 'goety:craft' - Craft items (most common)
    //   - 'goety:enchant' - Enchanting
    //   - 'goety:summon' - Summon entities
    //   - 'goety:summon_tamed' - Summon tamed entities
    //   - 'goety:convert' - Convert entities
    //   - 'goety:teleport' - Teleportation
    // - ingredients: Material array (InputItem[])
    
    // Crafting ritual
    event.recipes.goety.ritual('minecraft:emerald', 'goety:craft', [
        'minecraft:gold_ingot',
        'minecraft:gold_ingot',
        'minecraft:diamond'
    ])
        .activationItem('minecraft:ender_pearl')
        .craftType('forge')  // Forge ritual
        .soulCost(5)
        .duration(20);
    
    // Summoning ritual
    event.recipes.goety.ritual('goety:jei_dummy/none', 'goety:summon', [
        'minecraft:rotten_flesh',
        'minecraft:bone'
    ])
        .activationItem('minecraft:ender_pearl')
        .craftType('necroturgy')
        .soulCost(10)
        .entityToSummon('minecraft:zombie')
        .summonLife(6000);
});

酿造配方

ServerEvents.recipes(event => {
    // event.recipes.goety.brewing(ingredient, effect)
    // - ingredient: Material item (InputItem)
    // - effect: Effect ID (String, e.g., 'minecraft:regeneration')
    
    event.recipes.goety.brewing('minecraft:golden_apple', 'minecraft:regeneration')
        .soulCost(15)
        .capacityExtra(0)
        .duration(30);  // 30 seconds
    
    // Brewing recipe requiring specific entity
    event.recipes.goety.brewing('minecraft:nether_star', 'minecraft:resistance')
        .soulCost(50)
        .entityType('minecraft:ender_dragon');  // Requires ender dragon
});

配置优先级:

  • 你可以使用 event.recipes.goety.brewing 添加新的催化剂配方,或调整现有效果的灵魂消耗(.soulCost())
  • 如果同时使用 config/goety-brews.toml 和 KubeJS 脚本,KubeJS 脚本的优先级更高,并会覆盖配置文件中的设置
  • 建议使用 KubeJS 脚本,因为它们更加灵活,也更便于进行版本控制

粉碎配方

ServerEvents.recipes(event => {
    // event.recipes.goety.pulverize(ingredient)
    // - ingredient: Material item (InputItem)
    
    // Pulverize recipe producing block
    event.recipes.goety.pulverize('minecraft:cobblestone')
        .blockResult('minecraft:gravel');
    
    // Pulverize recipe producing item
    event.recipes.goety.pulverize('minecraft:gravel')
        .itemResult('minecraft:flint');
});

诅咒注魔器配方

ServerEvents.recipes(event => {
    // event.recipes.goety.cursed_infuser_recipes(result, ingredient)
    // - result: Output item ID (String)
    // - ingredient: Material item (InputItem)
    
    event.recipes.goety.cursed_infuser_recipes('minecraft:emerald', 'minecraft:iron_sword')
        .cookingTime(100);  // 5 seconds (100 ticks)
});

火盆配方

ServerEvents.recipes(event => {
    // event.recipes.goety.brazier(result, ingredients)
    // - result: Output item (OutputItem)
    // - ingredients: Material array (InputItem[])
    
    event.recipes.goety.brazier('minecraft:emerald', [
        'minecraft:soul_sand',
        'minecraft:soul_sand',
        'minecraft:soul_sand',
        'minecraft:lapis_lazuli'
    ])
        .soulCost(10);
});

移除配方

ServerEvents.recipes(event => {
    // Remove existing recipes
    event.remove({ type: 'goety:ritual', craftType: 'magic' });
    event.remove({ type: 'goety:brewing', effect: 'minecraft:poison' });
    event.remove({ type: 'goety:pulverize', ingredient: 'minecraft:cobblestone' });
});

参与贡献

欢迎提交问题和拉取请求!

常见问题

KubeJs Goety 支持哪些 Minecraft 版本?

KubeJs Goety 支持 Minecraft Java 版 1.20.1–1.21.1,共 2 个版本,可用的加载器:Forge / NeoForge。下载时注意选择和你游戏版本一致的文件。

KubeJs Goety 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Forge / NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。

评论

登录后评论和评分

AmicBeam 的其他作品

查看全部 →