跳到正文

Class API

作者:Misanthropy

Library mod

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。

Patreon

A small library mod for player classes.
It doesn’t add anything by itself. If a mod like Class Enhancement asks for it, install it and forget about it.

Forge 1.20.1  |  Client & Server


For players

NOTHING for you here.

For mod devs

One class mod installs itself as the provider. Everyone else just calls the API. If no provider is installed, every call is safe and returns nothing, so you can soft-depend on it!

Look things up

  • ClassApi.classOf(player), idOf, is(player, "knight"), hasClass
  • ClassApi.classes() and find(id) give you the full class: name, colour, tags, stats, attributes, kit, skill, passives and a free-form data tag
  • assign, clear, respec and openSelection on the server

Skills and passives

Register code under an id. A class JSON points at that id, and the class mod handles the key, cooldown and HUD.

ClassFeatures.registerSkill(new ResourceLocation("yourmod", "shield_wall"), ctx -> {
    ctx.player().addEffect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 60, 4));
    ctx.startCooldown();
    return true;
});
"skill": { "id": "yourmod:shield_wall", "name": "Shield Wall", "cooldown": "90s" }
  • Skills get activate, tick, equip and unequip. They can also report stacks, a meter or an active state for the HUD.
  • Passives get tick, equip and unequip.
  • ctx.params() hands you whatever numbers the JSON put in params, so one skill can be tuned per class.
  • Cooldowns: startCooldown, reduceCooldown, clearCooldown, from inside the skill or through ClassApi.skill(player).

Events

  • ClassChangeEvent.Pre (cancelable) and Post, with the old class, the new one and the cause
  • ClassKitEvent: cancel the kit or add items to it
  • ClassAvailabilityEvent: lock a class with a reason, or hide it
  • SkillActivateEvent: cancel a skill use

Client hooks

  • ClassClientHooks.beforeSelection and afterSelection: put your own screen before or after the class pick
  • skillDisplay: change a skill’s HUD name or icon, or draw on screen while it’s active

Want a strong Minecraft server? Support me by buying through this link: Kinetic Hosting

常见问题

Class API 支持哪些 Minecraft 版本?

Class API 支持 Minecraft Java 版 1.20.1,可用的加载器:Forge。下载时注意选择和你游戏版本一致的文件。

Class API 怎么安装?

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

评论

登录后评论和评分

Misanthropy 的其他作品

查看全部 →