#Use AnimationJS to cancel better combat animations
107 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
@lyric apex I'll ping you since you are the dev of the mod
hmm possibly
ill take a look at this when i have some time
maybe with animationjs internal methods
Here's some relevant information I tried:
ModifierLayer
IAnimation
IAnimatedPlayer
PlayerAnimationAccess
let PlayerAnimAPI = Java.loadClass("lio.playeranimatorapi.API.PlayerAnimAPI")
PlayerAnimAPI.stopPlayerAnim(player.level, player, "some_animation_name");```
and this didnt work in server scripts?
I'll give that a try. I was previously purely using kubejs
gotcha
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
strange I don't see stopPlayerAnim anywhere in the script
this showcases how to use the Java Adapter which is unrelated to that
hmm maybe I should provide my current script so you have an idea
Current roll cancel better combat attack script. The Attack itself is being cancelled in first person
Paste version of roll_cancel_attack_hook.js, roll_cancel_attack.js, roll_cancel_attack_3rd.js from @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?
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
k grabbing it on better combat attack worked
k no wonder I can't cancel it. It's not even on the registry??
Paste version of animationRegistry.txt from @quasi elbow

At least I can cancel iron's spells casting AND it's animations. so that's another script idea
true
find out how they register their animations exactly cause it should be registered, i wonder if better combat does something funky
ok and compare that to where irons spells registers their animations
probably here:
https://github.com/iron431/irons-spells-n-spellbooks/blob/1.20.1-legacy/src/main/java/io/redspace/ironsspellbooks/api/spells/SpellAnimations.java
https://github.com/iron431/irons-spells-n-spellbooks/blob/1.20.1-legacy/src/main/resources/assets/irons_spellbooks/animations/casting_animations.json
irons spells registers their animation factory on client setup
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
AnimationRegistry.load
https://github.com/ZsoltMolnarrr/BetterCombat/blob/1.20.1/common/src/main/java/net/bettercombat/client/BetterCombatClient.java
they added PlayerAnimationFactory.ANIMATION_DATA_FACTORY in 1.21.11 but not in 1.20.1 nor 1.21.1 nor 1.21.4

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

assuming length you pass in is the length in the list the animation is in in their map
but cancelSwing() calls cancelWeaponSwing ??
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
yes but?
@Override
public void cancelUpswing() {
if (currentUpswingTicks() > 0) {
cancelWeaponSwing();
}
}
o
I thought it would be as simple as that
then do this
i wouldnt be the one to ask this, you would ask the devs

true lol
ok this did stop attack animation when I triggered it on the ATTACK_START with another script I used. but sending the data then cancelling did not?

This works
Paste version of better-combat-listeners.js from @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
how does affect things?
were you getting the data when ServerSideRollEvents fired?
or was it not firing at all
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
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™
but it will be confusing for other players to still see the attack animation going on 😭
like at least there's no sound
wait i thought you were able to cancel it?
^
?
yes this cancelled the attack animation
but when I tried to use it in the client script it did NOT work
so why would they see it going on? youre not sending the packet to nearby players?
I mean I still see the attack animation in third person
👍 that might take a while if you're talking about having another account look at me
hmm should be handled by that but we'll see
Paste version of roll_cancel_attack_hook.js, roll_cancel_attack.js from @quasi elbow
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;
};
}
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

🤷♂️ I am very bamboozled
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.
fork the mod in intellij, will make things a lot easier to search for too: https://github.com/ZsoltMolnarrr/BetterCombat.git
🙀 I need to become a java dev and install intelliJ
but sure I will close ticket and create new one later
just being able to look things up in the "Shift + Shift" search bar is nice, github also works ig
