Class AdjustmentModifier

All Implemented Interfaces:
IAnimation

public class AdjustmentModifier extends AbstractModifier
Adjusts body parts during animations.
Make sure this instance is the very first one, over the KeyframeAnimationPlayer, in the animation stack.

Example use (adjusting the vertical angle of a custom attack animation):

 
 new AdjustmentModifier((partName) -> {
     float rotationX = 0;
     float rotationY = 0;
     float rotationZ = 0;
     float scaleX = 0;
     float scaleY = 0;
     float scaleZ = 0;
     float offsetX = 0;
     float offsetY = 0;
     float offsetZ = 0;

     var pitch = player.getPitch() / 2F;
     pitch = (float) Math.toRadians(pitch);
     switch (partName) {
         case "body" -> {
             rotationX = (-1F) * pitch;
         }
         case "rightArm", "leftArm" -> {
             rotationX = pitch;
         }
         default -> {
             return Optional.empty();
         }
     }

     return Optional.of(new AdjustmentModifier.PartModifier(
             new Vec3f(rotationX, rotationY, rotationZ),
             new Vec3f(scaleX, scaleY, scaleZ),
             new Vec3f(offsetX, offsetY, offsetZ))
     );
 });