Class ModifierLayer<T extends IAnimation>

java.lang.Object
dev.kosmx.playerAnim.api.layered.ModifierLayer<T>
Type Parameters:
T -
All Implemented Interfaces:
IAnimation

public class ModifierLayer<T extends IAnimation> extends Object implements IAnimation
Layer to easily swap animations, add modifiers or do other sort of effects Modifiers affect each other. For example if you put a fade modifier after a speed modifier, it will be affected by the modifier.
  • Constructor Details

    • ModifierLayer

      public ModifierLayer(@Nullable T animation, AbstractModifier... modifiers)
    • ModifierLayer

      public ModifierLayer()
  • Method Details

    • 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
    • addModifier

      public void addModifier(@NotNull @NotNull AbstractModifier modifier, int idx)
    • addModifierBefore

      public void addModifierBefore(@NotNull @NotNull AbstractModifier modifier)
    • addModifierLast

      public void addModifierLast(@NotNull @NotNull AbstractModifier modifier)
    • removeModifier

      public void removeModifier(int idx)
    • setAnimation

      public void setAnimation(@Nullable T animation)
    • replaceAnimationWithFade

      public void replaceAnimationWithFade(@NotNull @NotNull AbstractFadeModifier fadeModifier, @Nullable T newAnimation)
      Fade out from current animation into new animation. Does not fade if there is currently no active animation
      Parameters:
      fadeModifier - Fade modifier, use AbstractFadeModifier.standardFadeIn(int, Ease) for simple fade.
      newAnimation - New animation, can be null to fade into default state.
    • replaceAnimationWithFade

      public void replaceAnimationWithFade(@NotNull @NotNull AbstractFadeModifier fadeModifier, @Nullable T newAnimation, boolean fadeFromNothing)
      Fade out from current to a new animation
      Parameters:
      fadeModifier - Fade modifier, use AbstractFadeModifier.standardFadeIn(int, Ease) for simple fade.
      newAnimation - New animation, can be null to fade into default state.
      fadeFromNothing - Do fade even if we go from nothing. (for KeyframeAnimation, it can be false by default)
    • size

      public int size()
    • linkModifiers

      protected void linkModifiers()
    • isActive

      public boolean isActive()
      Description copied from interface: IAnimation
      Is the animation currently active. Tick will only be invoked when ACTIVE
      Specified by:
      isActive in interface IAnimation
      Returns:
      active
    • get3DTransform

      @NotNull public @NotNull Vec3f get3DTransform(@NotNull @NotNull String modelName, @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.
      Specified by:
      get3DTransform in interface 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
    • setupAnim

      public void setupAnim(float tickDelta)
      Description copied from interface: IAnimation
      Called before rendering a character
      Specified by:
      setupAnim in interface IAnimation
      Parameters:
      tickDelta - Time since the last tick. 0-1
    • getFirstPersonMode

      @NotNull public @NotNull FirstPersonMode getFirstPersonMode(float tickDelta)
      Retrieves the FirstPersonMode for the current object, based on the provided tickDelta.

      The method determines the appropriate FirstPersonMode by following this logic: 1. It first attempts to retrieve the active AbstractModifier by calling getFirstPersonModifierOrDefault(). If a modifier is found, it delegates the call to the modifier's AnimationContainer.getFirstPersonMode(float) method. 2. If no modifier is available or applicable, it checks if there is an active animation. If an animation exists, it delegates the call to the animation's IAnimation.getFirstPersonMode(float) method. 3. If neither a modifier nor an animation is present, it falls back to the default implementation provided by the IAnimation interface.

      Specified by:
      getFirstPersonMode in interface IAnimation
      Parameters:
      tickDelta - A float value representing the partial tick time (used to interpolate between frames). This parameter is typically used in rendering calculations.
      Returns:
      The FirstPersonMode determined by the current modifier, animation, or the default implementation.
    • getFirstPersonConfiguration

      @NotNull public @NotNull FirstPersonConfiguration getFirstPersonConfiguration(float tickDelta)
      Retrieves the FirstPersonConfiguration for the current object, based on the provided tickDelta.

      The method determines the appropriate FirstPersonConfiguration by following this logic: 1. It first attempts to retrieve the active AbstractModifier by calling getFirstPersonModifierOrDefault(). If a modifier is found, it delegates the call to the modifier's AnimationContainer.getFirstPersonConfiguration(float) method. 2. If no modifier is available or applicable, it checks if there is an active animation. If an animation exists, it delegates the call to the animation's IAnimation.getFirstPersonConfiguration(float) method. 3. If neither a modifier nor an animation is present, it falls back to the default implementation provided by the IAnimation interface.

      Specified by:
      getFirstPersonConfiguration in interface IAnimation
      Parameters:
      tickDelta - A float value representing the partial tick time (used to interpolate between frames). This parameter is typically used in rendering calculations.
      Returns:
      The FirstPersonConfiguration determined by the current modifier, animation, or the default implementation.