Classy! 图标

Classy!

作者:rebot | 分类:模组

价格:0 墨喵币 下载量:0 点赞:0 版本 0.1.5
本资源为搬运资源,原资源地址: https://modrinth.com/mod/classy!
资源信息

Minecraft 版本: 1.21.1

平台: fabric

标签: library

资源介绍

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;
    }
}
下载太慢?试试 墨喵加速站,支持 Modrinth 和外网直链高速下载! 用的人越多,下载的越快!
下载与版本
评论(0)
登录 后发表评论。

暂无评论,抢个沙发吧~

举报此资源

请登录后举报

🔥 相关推荐
OwnVerse SMP

价格:0 墨喵币
下载量:0

查看详情
Sol's Relic System

价格:0 墨喵币
下载量:0

查看详情
Hardcore Zombie Apocalypse with Gun

价格:0 墨喵币
下载量:0

查看详情
Lovely Robot: Legacy

价格:0 墨喵币
下载量:0

查看详情