Cobblemon KubeJS Bridge
将 Cobblemon 的数据、事件、存储查询、管理工具以及客户端图鉴显示功能引入 KubeJS。
Cobblemon KubeJS Bridge 允许整合包开发者使用 JavaScript 构建自定义进度系统、任务、奖励、命令、界面、战斗系统和服务器机制。
功能
Cobblemon 事件
监听服务端事件,例如:
- 图鉴进度变更
- 宝可梦扫描与捕获
- 宝可梦送出、收回、晕倒、获得、治疗或放生
- 经验值获取与升级
- 进化完成
- 战斗胜利与失败
- 战斗逃跑与认输
CobblemonEvents.pokemonCaptured(event => {
event.player.tell(
`You caught ${event.species} at level ${event.level}!`
)
})
图鉴 API
查询玩家的图鉴进度:
- 检查是否已看到或捕获某物种
- 统计已看到或捕获的物种总数
- 按属性类型统计进度
- 读取单个物种的进度
var caughtFire = CobblemonJS.pokedex.countCaughtByType(
player,
'fire'
)
物种 API
- 验证物种 ID
- 列出已实现的物种
- 读取物种属性
- 验证属性类型
- 查找所有指定属性的物种
支持简短 ID 和带命名空间的 ID:
CobblemonJS.species.exists('charizard')
CobblemonJS.species.exists('cobblemon:charizard')
队伍与 PC API
从玩家的队伍和 PC 中读取安全的宝可梦快照:
- 通过 UUID 搜索宝可梦
- 按物种或属性统计宝可梦数量
- 保留队伍、PC、箱子及槽位信息
- 读取等级、HP、性格、特性、招式、个体值(IVs)、努力值(EVs)、状态、携带物品等更多信息
var party = CobblemonJS.pokemon.getParty(player)
var pokemon = CobblemonJS.pokemon.getByUuid(player, pokemonUuid)
管理工具
受信任的服务端脚本可以:
- 向玩家赠送宝可梦
- 治疗玩家的队伍
- 在玩家附近生成宝可梦
- 在指定坐标生成宝可梦且不分配所有者
CobblemonJS.admin.givePokemon(
player,
'charizard level=50 shiny=true'
)
CobblemonJS.admin.spawnPokemon(
player.serverLevel,
'rayquaza level=70',
100,
80,
-50
)
客户端图鉴同步
服务端会将一个只读的图鉴缓存同步给拥有该功能的客户端。客户端脚本可用于实时提示框和其他界面,而无需每帧都向服务端请求数据。
CobblemonClientJS.pokedex.countSeen()
CobblemonClientJS.pokedex.countCaught()
CobblemonClientJS.pokedex.countCaughtByType('fire')
包含的示例中包含一个经过测试的动态望远镜提示框功能。
要求
- Cobblemon
- KubeJS
- Rhino(KubeJS 所需)
- Java 21
当使用同步的客户端图鉴 API 时,需在客户端和服务端同时安装此桥接插件。
加载器支持
目前仅支持 NeoForge。
Fabric 支持尚不可用。Fabric 模块仅为编译时的存根(stub),不暴露事件、API 或客户端同步功能。
文档与示例
本项目包含:
- 完整的 API 文档
- 每个函数的参数和返回值说明
- 完整的事件字段参考
- 宝可梦和招式数据模型参考
- 服务端和客户端脚本示例
- 故障排除指南
链接
注意事项
- 返回给脚本的宝可梦快照为只读。
- 管理方法会修改游戏状态,应仅通过具有适当权限检查的可信脚本暴露。
- 图鉴计数代表唯一的已实现物种,而非重复捕获次数。
- 未知物种、属性、格式错误的 UUID 以及无效的生成属性会产生描述性的脚本错误。
- 替换模组 jar 文件或网络代码需要完全重启。
Cobblemon KubeJS Bridge
Bring Cobblemon data, events, storage queries, administrative utilities, and
client-side Pokedex displays into KubeJS.
Cobblemon KubeJS Bridge lets modpack developers build custom progression,
quests, rewards, commands, interfaces, battle systems, and server mechanics
using JavaScript.
Features
Cobblemon events
Listen to server-side events such as:
- Pokedex progress changes
- Pokemon scans and captures
- Pokemon sent, recalled, fainted, gained, healed, or released
- Experience gain and level-up
- Evolution completion
- Battle victory and defeat
- Battle escape and forfeit
CobblemonEvents.pokemonCaptured(event => {
event.player.tell(
`You caught ${event.species} at level ${event.level}!`
)
})
Pokedex API
Query a player's Pokedex progress:
- Check whether a species was seen or caught
- Count total seen or caught species
- Count progress by elemental type
- Read individual species progress
var caughtFire = CobblemonJS.pokedex.countCaughtByType(
player,
'fire'
)
Species API
- Validate species IDs
- List implemented species
- Read species types
- Validate elemental types
- Find all species of a type
Both short and namespaced IDs are supported:
CobblemonJS.species.exists('charizard')
CobblemonJS.species.exists('cobblemon:charizard')
Party and PC API
Read safe Pokemon snapshots from a player's party and PC:
- Search Pokemon by UUID
- Count Pokemon by species or type
- Keep party, PC, box, and slot information
- Read level, HP, nature, ability, moves, IVs, EVs, status, held item, and more
var party = CobblemonJS.pokemon.getParty(player)
var pokemon = CobblemonJS.pokemon.getByUuid(player, pokemonUuid)
Administrative utilities
Trusted server scripts can:
- Give a Pokemon to a player
- Heal a player's party
- Spawn a Pokemon near a player
- Spawn a Pokemon at explicit coordinates without assigning an owner
CobblemonJS.admin.givePokemon(
player,
'charizard level=50 shiny=true'
)
CobblemonJS.admin.spawnPokemon(
player.serverLevel,
'rayquaza level=70',
100,
80,
-50
)
Client-side Pokedex synchronization
The server synchronizes a read-only Pokedex cache to the owning client. Client
scripts can use it for live tooltips and other interfaces without requesting
data from the server every frame.
CobblemonClientJS.pokedex.countSeen()
CobblemonClientJS.pokedex.countCaught()
CobblemonClientJS.pokedex.countCaughtByType('fire')
The included examples contain a tested dynamic spyglass tooltip.
Requirements
- Cobblemon
- KubeJS
- Rhino, as required by KubeJS
- Java 21
Install the bridge on both the client and server when using the synchronized
client Pokedex API.
Loader support
NeoForge is currently supported.
Fabric support is not available yet. The Fabric module is only a compile-time
stub and does not expose events, APIs, or client synchronization.
Documentation and examples
The project includes:
- Complete API documentation
- Every function's parameters and return values
- Full event field reference
- Pokemon and move data model reference
- Server and client script examples
- Troubleshooting instructions
Links
Notes
- Pokemon snapshots returned to scripts are read-only.
- Administrative methods mutate gameplay state and should only be exposed
through trusted scripts with appropriate permission checks.
- Pokedex counts represent unique implemented species, not duplicate captures.
- Unknown species, types, malformed UUIDs, and invalid spawn properties produce
descriptive script errors.
- Replacing the mod jar or networking code requires a full restart.
评论 0
登录后参与评分
还没有评论,来抢沙发吧