Modifiers - ZigyTheBird/ZigysPlayerAnimatorAPI GitHub Wiki

Modifiers... well modify the player animation.
They are very useful tools for changing aspects of an animation during runtime so see how to use them here.

Using code

Since modifiers are client side only this API has a class called CommonModifer.
It's constructor takes a ResourceLocation and a JsonObject for holding data.
Here is an example for Java:

    public static final ResourceLocation LENGTH_MODIFIER_ID = new ResourceLocation("playeranimatorapi", "length");
    public static final ResourceLocation MIRROR_MODIFIER = new ArrayList<>(){{add(new CommonModifier(new ResourceLocation("player-animator", "mirror"), null));}}

    public static void playPlayerAnim(ServerLevel level, Player player, ResourceLocation anim, float desiredLength) {
        //Sets animation length to the desiredLength float
        JsonObject json = new JsonObject();
        json.addProperty("desiredLength", desiredLength);
        PlayerAnimAPI.playPlayerAnim(level, player, anim, null, new ArrayList<>(){{add(new CommonModifier(LENGTH_MODIFIER_ID, json));}}, true);
    } 

    public static void playPlayerAnim(ServerLevel level, Player player, ResourceLocation anim) {
        //Mirrors the animation
        PlayerAnimAPI.playPlayerAnim(level, player, anim, null, MIRROR_MODIFIER, true);
    } 

As you can see we made a CommonModifier with the ResourceLocation of the length modifier and put it's desiredLength value inside a new JsonObject.
A CommonModifier can also be constructed given an AbstractModifier on the client side, basically allowing you to make a new instance of a modifier class and use it with the API.
Take a look here to see all available modifiers and the registerModifier method that will allow you to register your own modifiers on the CLIENT SIDE.
Once you register a modifier you can give it's ID to a CommonModifier and use it on both server and client side.
Modifiers are part of the client side only Player Animator mod so if you want to make your own modifiers you can ask for help here. (But please look at the modifiers included with the mod by default before doing that)

Using commands

There is an example for commands in the dedicated examples section showing you how to use the mirror modifier.
You can't pass in additional arguments for modifiers with commands as of the time of writing so some like the speed modifier won't be usable.
You can use multiple modifiers with commands for example if you wanted to use the modifiers examplemod:modifier and examplemod:modifier2 you would set this as the modifiers parameter: "examplemod:modifier;examplemod:modifier2" dividing the IDs with a semicolon.

List of Modifiers

  • player-animator:mirror: Mirrors the animation.
  • player-animator:speed: Multiplies the speed of the animation by the float "speed" value in the provided JsonObject.
  • playeranimatorapi:length: Sets the length of the animation in seconds to the float value "desiredLength" in the provided JsonObject.
  • playeranimatorapi:mirroronalthand: Mirrors the animation if the player has their left hand set as their main hand.
  • playeranimatorapi:headposboundcamera: Makes the camera move with the head animation.
  • playeranimatorapi:headrotboundcamera: Makes the camera rotate with the head animation.
⚠️ **GitHub.com Fallback** ⚠️