Compatibility
Minecraft: Java Edition
Platforms
Supported environments
Links
Creators
Details
Classy
Classy is a library for highly customizable access to a class and ability system. All it contains are methods for registering classes and abilities, casting interactions, and equipping classes. All else is done by the developer using this dependency.
Classes
Classes are designed to be expandable for every use case. Multiple classes may be equipped at one, but depending on your selection code, you can restrict the maximum number of equipped classes.
Registering a Class
Registering a class is extremely simple, and can be done like registering any other object. Just do the following:
private static final DeferredRegister<PlayerClass> CLASSES = DeferredRegister.create(MOD_ID, PlayerClass.PLAYER_CLASS);
private static final RegistrySupplier<PlayerClass> EXAMPLE_CLASS = registerClass(CLASSES, () -> new PlayerClass(
ResourceLocation.fromNamespaceAndPath(MOD_ID, "example"),
List.of(
// This is where the abilities are added.
)
));
public static void init() {
CLASSES.register();
}
Classy has a command built-in to the mod to allow quickly equipping a class to test it. Simply just run /classy class [id] and it will equip or unequip the class.
Abilities
Abilities are very simple, not including cooldowns or a mana bar. Abilities only act as a system that are connected to a class. Choosing the ability to cast is also decided by your own code, allowing casting from index or identifier. Creating the rest of the ability is where it becomes more complicated.
An extremely basic ability can be done like this:
public class ExampleAbility extends PlayerAbility {
public ExampleAbility() {
super(ResourceLocation.fromNamespaceAndPath(MOD_ID, "example"));
}
@Override
public void serverCast(ServerPlayer player) {
player.hurt(player.damageSources().cactus(), 1f);
}
@Override
public boolean canCast(Player player) {
return true;
}
}
All this ability will do is apply half a heart of cactus damage to the casting player.
If you would like more complicated interactions, such as triggering clientside player animations or having a held ability, you can use the following methods and fields:
// An ability that plays your cool player animation when cast.
public class ClientAnimationAbility extends PlayerAbility {
public ClientAnimationAbility() {
super(ResourceLocation.fromNamespaceAndPath(MOD_ID, "cooler_example"));
}
@Override
public void clientCast(LocalPlayer player) {
AnimationHandler.playCoolAnimation(player);
}
@Override
public boolean canCast(Player player) {
return true;
}
}
// A held ability that charges up, and then gives you Speed I equivalent to how long you held for.
public class HeldAbility extends PlayerAbility {
public HeldAbility() {
super(ResourceLocation.fromNamespaceAndPath(MOD_ID, "coolest_example"));
}
int heldTimer = 0;
@Override
public void serverCast(ServerPlayer player) {
heldTimer = 0;
this.setActive(true);
}
@Override
public void serverTick(ServerPlayer player) {
heldTimer++;
this.setActive(player.classy$isCasting()); // deactivate when no longer casting the ability
}
@Override
public void serverEnd(ServerPlayer player) {
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, heldTimer, 0));
}
@Override
public boolean canCast(Player player) {
return true;
}
}



