-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
This example registers a two-wave normal gateway using vanilla mobs and vanilla loot, then adds a crafting recipe for its pearl. It works with the common builder API on both supported branches.
下面的示例注册一个包含两波原版生物和原版战利品的普通网关,并添加对应珍珠配方。它使用两个分支共有的 Builder API。
// 测试网关 ID
const TEST_GATEWAY_ID = 'kubejs:vanilla_test'
// 注册网关与珍珠配方
ServerEvents.recipes(event => {
Gateway.customBuilder(TEST_GATEWAY_ID)
.name('Vanilla Test Gateway')
.tooltipText('Two waves with vanilla mobs and loot')
.size('small')
.color(0x55AAFF)
.addWave(wave => {
wave.addEntity('minecraft:zombie', 2)
wave.addEntity('minecraft:spider', 1)
wave.maxTime(1200)
wave.setupTime(40)
wave.addEntityLootReward('minecraft:zombie', 2)
wave.buildWave()
})
.addWave(wave => {
wave.addEntity('minecraft:skeleton', 2)
wave.maxTime(1200)
wave.setupTime(40)
wave.addLootTableReward('minecraft:chests/simple_dungeon', 1)
wave.buildWave()
})
.addReward('minecraft:diamond', 1)
.addExperienceReward(30, 3)
.register()
event.shaped(Gateway.createPearlItem(TEST_GATEWAY_ID), [
' E ',
'EPE',
' E '
], {
E: 'minecraft:ender_pearl',
P: 'minecraft:paper'
})
})Modded items and living entities use the same methods. Replace the IDs with real IDs from the installed modpack.
模组物品和活体生物使用完全相同的方法,只需替换为整合包中真实存在的注册 ID。
// 模组生物和模组物品示例
wave.addEntity('examplemod:custom_mob', 2)
wave.addReward('examplemod:custom_item', 4)
wave.addEntityLootReward('examplemod:custom_mob', 2)Non-living entities such as arrows, boats, and item entities are not suitable as standard wave mobs. Third-party custom Gateways entity codecs should be added through addEntityJson.
箭、船、掉落物等非活体实体不适合作为标准波次生物。第三方模组注册的 Gateways 自定义实体 codec 应通过 addEntityJson 添加。
After /reload, verify that the script loaded without errors, craft the pearl, open the gateway, clear both waves, and confirm all rewards appear.
执行 /reload 后,确认脚本无报错、珍珠可以合成、网关能够打开、两波生物正常生成并且奖励正确发放。
GatewaysJS Wiki · English first, 中文同步说明 · GitHub