#Use AnimationJS to cancel better combat animations

107 messages · Page 1 of 1 (latest)

quasi elbow
#

Can I use AnimationJS addon mod to directly cancel better combat animations?

wispy stirrupBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

quasi elbow
#

@lyric apex I'll ping you since you are the dev of the mod

lyric apex
#

hmm possibly

#

ill take a look at this when i have some time

#

maybe with animationjs internal methods

quasi elbow
lyric apex
#
let PlayerAnimAPI = Java.loadClass("lio.playeranimatorapi.API.PlayerAnimAPI")
PlayerAnimAPI.stopPlayerAnim(player.level, player, "some_animation_name");```
and this didnt work in server scripts?
quasi elbow
#

I'll give that a try. I was previously purely using kubejs

lyric apex
#

gotcha

quasi elbow
#

Would it be fine if this was placed in startup scripts? I shall "try it and see"

#

because I'm trying to stop the combat animation on a combat roll which is server sided but I need the special Java Adapter things

lyric apex
#

oh theres an example script where someone uses it

quasi elbow
#

strange I don't see stopPlayerAnim anywhere in the script

lyric apex
#

this showcases how to use the Java Adapter which is unrelated to that

quasi elbow
#

hmm maybe I should provide my current script so you have an idea

quasi elbow
jovial bronzeBOT
#

Paste version of roll_cancel_attack_hook.js, roll_cancel_attack.js, roll_cancel_attack_3rd.js from @quasi elbow

quasi elbow
#

I'll try grabbing the player animator registry for better combat. stopPlayerAnim method exists but maybe I don't have the right name?

quasi elbow
#

Link to class: https://github.com/KosmX/minecraftPlayerAnimator/blob/8465079b18590b4f59aa45738376b56b3e846114/minecraft/common/src/main/java/dev/kosmx/playerAnim/minecraftApi/PlayerAnimationRegistry.java#L68
I believe it needs Client Environment: @Environment(EnvType.CLIENT)

// startup_scripts

if (Platform.isClientEnvironment()) {
    ClientEvents.init((event) => {
        let $PlayerAnimationRegistry = Java.loadClass("dev.kosmx.playerAnim.minecraftApi.PlayerAnimationRegistry");

        console.log("RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");

        let allPlayerAnimationsMap = $PlayerAnimationRegistry.getAnimations();

        try {
            if (!allPlayerAnimationsMap) {
                console.log(`KubeJS: No PlayerAnimator animations found in registry.`);
                return;
            }

            console.log(`KubeJS: Found ${allPlayerAnimationsMap.size()} PlayerAnimator animations:`);

            allPlayerAnimationsMap.entrySet().forEach((entry) => {
                const animationId = entry.getKey();
                // const animationObject = entry.getValue();

                console.log(`  - ${animationId}`);
            });
        } catch (e) {
            console.log(`PlayerAnimator Registry Error: ${e}`);
        }
    });
}

Welp. Now it says it found 0 animations.
I'll try grabbing registry on a better combat attack

#

So far nothing has worked to cancel the better combat animations in third person and no errors apart from not being able to read the data from client -> server.
current logic: startup to hook onto combat roll -> sendData to client -> sendData to server

quasi elbow
jovial bronzeBOT
#

Paste version of animationRegistry.txt from @quasi elbow

lyric apex
quasi elbow
#

At least I can cancel iron's spells casting AND it's animations. so that's another script idea

lyric apex
#

true

#

find out how they register their animations exactly cause it should be registered, i wonder if better combat does something funky

lyric apex
#

ok and compare that to where irons spells registers their animations

lyric apex
#

better combat would have to do the same and call java PlayerAnimationFactory.ANIMATION_DATA_FACTORY.registerFactory
somewhere otherwise it wont be a registry

#

not with playeranimator anyways

quasi elbow
lyric apex
#

so i guess go into github dev mode by pressing "." and search for stopAnimation or something

#

maybe they have implementation for this, they have to

#

they probably had to move away from playeranimator because they did not update to 1.21 right away and better combat wanted to update

lyric apex
#

assuming length you pass in is the length in the list the animation is in in their map

quasi elbow
#

but cancelSwing() calls cancelWeaponSwing ??

lyric apex
#
private void cancelWeaponSwing() {
    var downWind = (int)Math.round(PlayerAttackHelper.getAttackCooldownTicksCapped(player) * (1 - 0.5 * BetterCombat.config.upswing_multiplier));
    ((PlayerAttackAnimatable) player).stopAttackAnimation(downWind);
    ClientPlayNetworking.send(
            Packets.AttackAnimation.ID,
            Packets.AttackAnimation.stop(player.getId(), downWind).write());
    upswingStack = null;
    itemUseCooldown = 0;
    setMiningCooldown(0);
}```
#

thats what it does

#

its private so you cant do Client.getInstance(). cancelWeaponSwing() but you can recreate it

quasi elbow
#

yes but?

    @Override
    public void cancelUpswing() {
        if (currentUpswingTicks() > 0) {
            cancelWeaponSwing();
        }
    }
lyric apex
#

or do clientPlayer.stopAttackAnimation(somenumber)

#

then do that pepeshrug

jovial bronzeBOT
quasi elbow
#

I did

#

it's in my script

lyric apex
#

o

quasi elbow
#

I thought it would be as simple as that

lyric apex
lyric apex
quasi elbow
#

true lol

quasi elbow
lyric apex
quasi elbow
jovial bronzeBOT
#

Paste version of better-combat-listeners.js from @quasi elbow

quasi elbow
#

Is there some quirk with using a server sided event to send stuff to a client?
attack start from better combat is client sided

lyric apex
#

uh

#

you did it through startup scripts though

quasi elbow
#

how does affect things?

lyric apex
#

were you getting the data when ServerSideRollEvents fired?

#

or was it not firing at all

quasi elbow
#

yes I was getting the data

#

because I was able to successfully cancel everything but the animations

#

like attack strength indicator, left click down

#

in my client script

lyric apex
#

yeah im lookin at it

#

btw you dont need to load in Minecraft class, theres a binding for it Client

#

other than that i havent gotten too far into it, you seemed to solve it on your own for the most part

#

so if it works™

quasi elbow
#

but it will be confusing for other players to still see the attack animation going on 😭

#

like at least there's no sound

lyric apex
#

wait i thought you were able to cancel it?

quasi elbow
#

but when I tried to use it in the client script it did NOT work

lyric apex
quasi elbow
lyric apex
#

ah

#

look to see how they play the animation in third person view ig

quasi elbow
#

👍 that might take a while if you're talking about having another account look at me

lyric apex
#

hmm should be handled by that but we'll see

quasi elbow
#

k I gtg 👋

jovial bronzeBOT
#

Paste version of roll_cancel_attack_hook.js, roll_cancel_attack.js from @quasi elbow

quasi elbow
# quasi elbow I'll post my current script:

More context about my confusion for anyone able to solve

in my client_scripts

Client.player //is a LocalPlayer type which should be able to call stopAttackAnimation() but doesn't seem to work

A script I got to stop attack animation

// startup_scripts

if (Platform.isClientEnvironment()) {
    ClientEvents.init((event) => {
        let $BetterCombatClientEvents = Java.loadClass("net.bettercombat.api.client.BetterCombatClientEvents");
        let $PlayerAttackStart = Java.loadClass("net.bettercombat.api.client.BetterCombatClientEvents$PlayerAttackStart");
        // 1. Register ATTACK_START
        $BetterCombatClientEvents.ATTACK_START.register(
            new JavaAdapter($PlayerAttackStart, {
                onPlayerAttackStart: function (player, attackHand) {
                    global.playerAttackStart(player, attackHand);
                },
            }),
        );
    });

    /**
     * @param {Internal.LocalPlayer} player
     * @param {Internal.AttackHand_} attackHand
     */
    global.playerAttackStart = (player, attackHand) => {
        console.log("--- ATTACK START ---");
                // This WORKS!!!
        player.stopAttackAnimation(4);
        if (player) return;
    };
}
quasi elbow
#

honestly if I can't fix it there's no problem because the attack animations only linger if the attack speed is really slow. The combat roll already overrides the attack animation only if the weapon attack speed is fast which is also another point of confusion
the weapon's attack speed determines how much of the roll animations is completely played. I am very clueless as to why

lyric apex
quasi elbow
#

🤷‍♂️ I am very bamboozled

lyric apex
#

yea, i think close this ticket and open another one targeting the new issue of it not working for Better Combat

#

maybe someone else will know

#

🤷‍♂️

#

this to be clear is not on animationjs btw, we are able to cancel the ones that were registered properly through PlayerAnimator mod. The issue is that you have to figure out their pipeline of how do they fully stop their animations on this version.

quasi elbow
#

🙀 I need to become a java dev and install intelliJ

#

but sure I will close ticket and create new one later

lyric apex