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))
     );
 });
 
 
  • Field Details

  • Constructor Details

  • Method Details

    • getFadeIn

      protected float getFadeIn(float delta)
    • tick

      public void tick()
      Description copied from interface: IAnimation
      Animation tick, on lag free client 20 [tick/sec] You can get the animations time from other places, but it will be invoked when the animation is ACTIVE
      Specified by:
      tick in interface IAnimation
      Overrides:
      tick in class AnimationContainer<IAnimation>
    • fadeOut

      public void fadeOut(int fadeOut)
    • getFadeOut

      protected float getFadeOut(float delta)
    • get3DTransform

      @Deprecated(forRemoval=true) @NotNull public @NotNull Vec3f get3DTransform(@NotNull @NotNull String modelName, @NotNull @NotNull TransformType type, float tickDelta, @NotNull @NotNull Vec3f value0)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IAnimation
      Get the transformed value to a model part, transform type.
      Specified by:
      get3DTransform in interface IAnimation
      Overrides:
      get3DTransform in class AnimationContainer<IAnimation>
      Parameters:
      modelName - The questionable model part
      type - Transform type
      tickDelta - Time since the last tick. 0-1
      value0 - The value before the transform. For identity transform return with it.
      Returns:
      The new transform value
    • get3DTransform

      @NotNull public @NotNull Vec3f get3DTransform(@NotNull @NotNull PartKey partKey, @NotNull @NotNull TransformType type, float tickDelta, @NotNull @NotNull Vec3f value0)
      Description copied from interface: IAnimation
      Get the transformed value to a model part, transform type.

      API note
      DO NOT CALL super.get3DTransform() as the default implementation will be removed.

      Specified by:
      get3DTransform in interface IAnimation
      Overrides:
      get3DTransform in class AnimationContainer<IAnimation>
      Parameters:
      partKey - The questionable model part
      type - Transform type
      tickDelta - Time since the last tick. 0-1
      value0 - The value before the transform. For identity transform return with it.
      Returns:
      The new transform value
    • transformVector

      protected Vec3f transformVector(Vec3f vector, TransformType type, AdjustmentModifier.PartModifier partModifier, float fade)