Class PoseStackAnimator

java.lang.Object
foundry.veil.api.client.ui.util.PoseStackAnimator

public class PoseStackAnimator extends Object
A utility class to manage and apply animations to a PoseStack. Animations are defined as a sequence of PoseStackAnimator.AnimationStages, each with a duration and a transformation function.
  • Constructor Details

    • PoseStackAnimator

      public PoseStackAnimator(com.mojang.blaze3d.vertex.PoseStack poseStack)
      Constructs a new PoseStackAnimator for the given PoseStack.
      Parameters:
      poseStack - The PoseStack to animate.
  • Method Details

    • addStage

      public void addStage(long durationMillis, BiConsumer<Long,com.mojang.blaze3d.vertex.PoseStack> transform)
      Adds a new animation stage to the sequence.
      Parameters:
      durationMillis - The duration of the stage in milliseconds.
      transform - The transformation function to apply during this stage. This function receives the PoseStack as an argument, allowing you to directly modify its transformations.
    • startAnimation

      public void startAnimation()
      Starts the animation sequence.
    • tickAnimation

      public void tickAnimation()
      Advances the animation based on the elapsed time. Call this method once per frame to update the animation.
    • isAnimating

      public boolean isAnimating()
      Checks if the animation is currently active.
      Returns:
      True if the animation is running, false otherwise.
    • resetAnimation

      public void resetAnimation()
      Resets the animation, stopping it and clearing any defined stages.