Package foundry.veil.api.client.ui.util
Class PoseStackAnimator
java.lang.Object
foundry.veil.api.client.ui.util.PoseStackAnimator
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 Summary
ConstructorsConstructorDescriptionPoseStackAnimator(com.mojang.blaze3d.vertex.PoseStack poseStack) Constructs a newPoseStackAnimatorfor the givenPoseStack. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStage(long durationMillis, BiConsumer<Long, com.mojang.blaze3d.vertex.PoseStack> transform) Adds a new animation stage to the sequence.booleanChecks if the animation is currently active.voidResets the animation, stopping it and clearing any defined stages.voidStarts the animation sequence.voidAdvances the animation based on the elapsed time.
-
Constructor Details
-
PoseStackAnimator
public PoseStackAnimator(com.mojang.blaze3d.vertex.PoseStack poseStack) Constructs a newPoseStackAnimatorfor the givenPoseStack.- Parameters:
poseStack- ThePoseStackto 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 thePoseStackas 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.
-