#Question about animation code

2 messages · Page 1 of 1 (latest)

quiet dock
#

Does anyone know if I'm doing it correctly? [Posting here cuz probably my question in mod-dev-1 will be ignored as people talk there.]

            else if (getMainHandStack().getItem() instanceof CrossbowItem && CrossbowItem.isCharged(getMainHandStack())) {
                anim = anim_crossbow;
            }
            else if (getMainHandStack().getItem() instanceof CrossbowItem && isSneaking() && CrossbowItem.isCharged(getMainHandStack())) {
                anim = anim_crossbow_sneak;

It's a custom player animation mod that I'm trying to edit, the source code is public (https://github.com/DentedLeft/BetterPlayerAnimations-1.20.2_fabric).

I've already created the .json animation file in blockbench and added it in the resource path

But, when I try to open the game to test, the mod stops working and a message like "Failed to reload resources" appears in the right top corner

If I remove these fields and the .json that I created, the game opens normally.

Idk what am I doing wrong here...

Here's the .java file.

quiet dock
#

I managed to make it work, just changed the IF condition to use the .equals instead of instanceof

            else if (getMainHandStack().getItem().equals(Items.CROSSBOW) && CrossbowItem.isCharged(getMainHandStack())) {
                anim = anim_crossbow;
            }
            else if (getMainHandStack().getItem().equals(Items.CROSSBOW) && isSneaking() && CrossbowItem.isCharged(getMainHandStack())) {
                anim = anim_crossbow_sneak;
            }