#crossbow load animation (fabric 1.21.1)

40 messages · Page 1 of 1 (latest)

zealous kite
#

so both the first person animation and the arm animation of crossbows are hardcoded and dont use the values of DEFAULT_PULL_TIME ect how do i make it so my crossbows load animation loads in the DEFAULT_PULL_TIME instead of it saying its loaded when its not

hollow needle
#

dont the animations depend on a property that is calculated based on use time?

hollow needle
#

then use a mixin and do so

zealous kite
#

my custom crossbow extends crossbow item and me changing DEFAULT_PULL_TIME doesnt do anything to the animation

zealous kite
hollow needle
#

right, its a default constant, its inlined when compiled

zealous kite
#

so what could i do

hollow needle
zealous kite
#

ye i replaced that in my item with default pull time

hollow needle
#

its a static method

#

are you making sure you override whatever is using the static methods

zealous kite
#

i am to everything in the crossbowitem class

#

but if its using something not in there

hollow needle
#

for instance

zealous kite
#

yes i am

hollow needle
#

show me

#

the 2nd one is from HeldItemRenderer

zealous kite
#

im not doing that one

#

im doing the other one

hollow needle
#

and just to make sure, you are using a custom NumericProperty for item rendering?

#

(not the crossbow one with hardcoded static method usage)

zealous kite
#

i think so

#

not rly sure what u mean

hollow needle
#

the crossbow's model predicate wont work for you

zealous kite
#

i have all the attributes from the crossbowitem in my class aswell remade and i copied all the other methods from crossbow item that use them

#

if thats what u mean

hollow needle
#

show me how you register the model predicate for your item

zealous kite
#

public class ModModelPredicates {
    public static void registerModelPredicates() {
        registerCustomCrossbow(ModItems.LONGCROSSBOW);
    }





    private static void registerCustomCrossbow(Item item) {



        register(
                item,
                Identifier.ofVanilla("pull"),
                (stack, world, entity, seed) -> {
                    if (entity == null) {
                        return 0.0F;
                    } else {
                        return CrossbowItem.isCharged(stack)
                                ? 0.0F
                                : (float)(stack.getMaxUseTime(entity) - entity.getItemUseTimeLeft()) / (float)CrossbowItem.getPullTime(stack, entity);
                    }
                }
        );
        register(
                item,
                Identifier.ofVanilla("pulling"),
                (stack, world, entity, seed) -> entity != null && entity.isUsingItem() && entity.getActiveItem() == stack && !CrossbowItem.isCharged(stack) ? 1.0F : 0.0F
        );
        register(item, Identifier.ofVanilla("charged"), (stack, world, entity, seed) -> CrossbowItem.isCharged(stack) ? 1.0F : 0.0F);
        register(item, Identifier.ofVanilla("firework"), (stack, world, entity, seed) -> {
            ChargedProjectilesComponent chargedProjectilesComponent = stack.get(DataComponentTypes.CHARGED_PROJECTILES);
            return chargedProjectilesComponent != null && chargedProjectilesComponent.contains(Items.FIREWORK_ROCKET) ? 1.0F : 0.0F;
        });




    }
}```
#

ngl i think i did it wrong it makes it render like a block

hollow needle
#

(stack.getMaxUseTime(entity) - entity.getItemUseTimeLeft()) / (float)CrossbowItem.getPullTime(stack, entity);
}
}
);

#

isnt that thet hardcoded static method?

zealous kite
#

ye just thought that but changing it does nothing

hollow needle
#

well, there are other parts that need changing. this is in regards to the animation of the model itself

zealous kite
#

it has every animation the load animations dont change duration tho

#

also this might be a cause idk but its flat normally then when i load it it becomes a block

hollow needle
#

sounds like the model in your override is missing

#

the console should be telling you that at game load time

zealous kite
#

i dont have any models yet my friend is makin them for me