Class FpRenderState

java.lang.Object
com.github.razorplay01.fp_pal.firstperson.FpRenderState

public class FpRenderState extends Object
Holds the current first-person render state. Updated every tick and read during rendering.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static float
    Uniform first-person display scale of the arm model, see ARM_DISPLAY_TRANSLATION.
    static final float[]
    First-person display translation of the arm model, in 1/16 block, like the translation of a firstperson_* item model entry.
    static final String
    Extra animation data key that selects the frame the arm rig is rendered in: "camera" (default, origin on the view axis) or "hand" (the vanilla hand anchor used by AzureLib item rigs).
    static final String
     
    static final String
    Extra animation data keys used to override ARM_DISPLAY_TRANSLATION and ARM_DISPLAY_SCALE per animation.
    static final com.zigythebird.playeranimcore.bones.PlayerAnimBone
    The FP camera transform.
    static final com.zigythebird.playeranimcore.bones.PlayerAnimBone
    The FP left arm bone transform, named like AzureLib's leftArm.
    static final com.zigythebird.playeranimcore.bones.PlayerAnimBone
    The FP left item bone transform (for item offset in left hand).
    static final com.zigythebird.playeranimcore.bones.PlayerAnimBone
    The FP root bone (fp_player_arms), which moves and rotates the whole rig (arms, held items and the camera).
    static final com.zigythebird.playeranimcore.bones.PlayerAnimBone
    The FP right arm bone transform, named like AzureLib's rightArm.
    static final com.zigythebird.playeranimcore.bones.PlayerAnimBone
    The FP right item bone transform (for item offset in right hand).
    static float[]
    Rotation centre of the animation's model root in model units.
    static boolean
    Whether FP rendering is active (a FP animation is currently playing).
    static boolean
    Whether the local player's held item is currently drawn with the fp_r_item / fp_l_item bone pose applied.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyAnimationDisplayTransform(List<?> translation, Float scale, Object anchor)
    Applies the display transform carried by the current animation, falling back to the transform configured through setArmDisplayTransform(float, float, float, float).
    static void
    Saves the current camera transform as the previous tick.
    static void
    captureItemFrame(com.mojang.blaze3d.vertex.PoseStack poseStack)
    Remembers the frame the vanilla first-person item pass starts from, before vanilla adds the hand sway and the per-hand item transforms.
    static void
    copy(com.zigythebird.playeranimcore.bones.PlayerAnimBone from, com.zigythebird.playeranimcore.bones.PlayerAnimBone to)
    Copies a complete bone transform (position, rotation and scale) into one of the render state bones.
    static com.zigythebird.playeranimcore.api.firstPerson.FirstPersonConfiguration
    firstPersonConfiguration(net.minecraft.world.entity.Entity entity)
     
    static com.zigythebird.playeranimcore.bones.PlayerAnimBone
    get3DTransform(com.zigythebird.playeranim.animation.AvatarAnimManager manager, String boneName)
    Reads a bone transform out of PAL's animation stack, keeping the call sites identical across the PAL 1.2 signature change.
    static com.zigythebird.playeranimcore.bones.PlayerAnimBone
    getCameraForRender(float partialTick)
     
    static com.zigythebird.playeranimcore.bones.PlayerAnimBone
     
    static Map<String, com.zigythebird.playeranimcore.bones.PlayerAnimBone>
     
    static boolean
    hasArmBone(boolean right)
     
    static boolean
    hasItemBone(boolean right)
     
    static boolean
     
    static boolean
     
    static boolean
     
    static boolean
     
    static boolean
     
    static boolean
    isIdentity(com.zigythebird.playeranimcore.bones.PlayerAnimBone bone)
     
    static boolean
    isPlayerArmMode(net.minecraft.world.entity.Entity entity)
     
    static void
    Resets all transforms to identity and leaves first-person arm mode.
    static void
    Restores the neutral (identity) first-person display transform.
    static void
    restoreItemFrame(com.mojang.blaze3d.vertex.PoseStack poseStack)
    Rewinds the top of the pose stack to the frame captured by captureItemFrame(PoseStack), dropping every transform vanilla applied since then.
    static void
    rotatePose(com.mojang.blaze3d.vertex.PoseStack poseStack, org.joml.Quaternionf rotation)
    Rotates the pose by a quaternion, hiding the 26.3 mulPose -> rotate rename.
    static void
    setArmBoneActive(boolean right, boolean left)
    Updates whether the current animation contains the arm bones.
    static void
    setArmDisplayTransform(float x, float y, float z, float scale)
    Sets the first-person display transform used by the arm pass.
    static void
    setItemBoneActive(boolean right, boolean left)
    Updates whether the current animation contains the item bones.
    static void
    updateExtraBones(com.zigythebird.playeranim.animation.AvatarAnimManager manager, Set<String> activeBoneNames)
    Updates the extra-bone cache with every bone the FP animation drives.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • isFpActive

      public static boolean isFpActive
      Whether FP rendering is active (a FP animation is currently playing).
    • isFpItemPass

      public static boolean isFpItemPass
      Whether the local player's held item is currently drawn with the fp_r_item / fp_l_item bone pose applied. While set, ItemTransformMixin skips vanilla's item display transform so the item lands where the animation puts it.
    • fpPlayerArms

      public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpPlayerArms
      The FP root bone (fp_player_arms), which moves and rotates the whole rig (arms, held items and the camera).
    • fpRootPivot

      public static float[] fpRootPivot
      Rotation centre of the animation's model root in model units. FpAnimationSystem sets it when resolving the root bone; most rigs use the origin.
    • fpRightArm

      public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpRightArm
      The FP right arm bone transform, named like AzureLib's rightArm.
    • fpLeftArm

      public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpLeftArm
      The FP left arm bone transform, named like AzureLib's leftArm.
    • fpRightItem

      public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpRightItem
      The FP right item bone transform (for item offset in right hand).
    • fpLeftItem

      public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpLeftItem
      The FP left item bone transform (for item offset in left hand).
    • fpCamera

      public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpCamera
      The FP camera transform.
    • ARM_DISPLAY_TRANSLATION

      public static final float[] ARM_DISPLAY_TRANSLATION
      First-person display translation of the arm model, in 1/16 block, like the translation of a firstperson_* item model entry. An FP animation can override it through the extra data keys fpDisplayTranslation, fpDisplayScale and fpDisplayAnchor.
    • ARM_DISPLAY_SCALE

      public static float ARM_DISPLAY_SCALE
      Uniform first-person display scale of the arm model, see ARM_DISPLAY_TRANSLATION.
    • FP_DISPLAY_TRANSLATION_KEY

      public static final String FP_DISPLAY_TRANSLATION_KEY
      Extra animation data keys used to override ARM_DISPLAY_TRANSLATION and ARM_DISPLAY_SCALE per animation.
      See Also:
    • FP_DISPLAY_SCALE_KEY

      public static final String FP_DISPLAY_SCALE_KEY
      See Also:
    • FP_DISPLAY_ANCHOR_KEY

      public static final String FP_DISPLAY_ANCHOR_KEY
      Extra animation data key that selects the frame the arm rig is rendered in: "camera" (default, origin on the view axis) or "hand" (the vanilla hand anchor used by AzureLib item rigs).
      See Also:
  • Method Details

    • captureItemFrame

      public static void captureItemFrame(com.mojang.blaze3d.vertex.PoseStack poseStack)
      Remembers the frame the vanilla first-person item pass starts from, before vanilla adds the hand sway and the per-hand item transforms. FpArmRendererMixin rewinds to it before applying the animated bone poses.
    • restoreItemFrame

      public static void restoreItemFrame(com.mojang.blaze3d.vertex.PoseStack poseStack)
      Rewinds the top of the pose stack to the frame captured by captureItemFrame(PoseStack), dropping every transform vanilla applied since then. Does nothing before the first capture.
    • isPlayerArmMode

      public static boolean isPlayerArmMode(@Nullable net.minecraft.world.entity.Entity entity)
      Returns:
      true if the given entity is playing a first-person animation, which is what makes the render mixins replace the vanilla arm.
    • firstPersonConfiguration

      public static com.zigythebird.playeranimcore.api.firstPerson.FirstPersonConfiguration firstPersonConfiguration(@Nullable net.minecraft.world.entity.Entity entity)
      Returns:
      the FirstPersonConfiguration that decides what the first-person pass draws. It comes from this addon's controller rather than PAL's manager, because this controller reports FirstPersonMode.NONE and PAL would otherwise return the wrong defaults.
    • rotatePose

      public static void rotatePose(com.mojang.blaze3d.vertex.PoseStack poseStack, org.joml.Quaternionf rotation)
      Rotates the pose by a quaternion, hiding the 26.3 mulPose -> rotate rename.
    • get3DTransform

      public static com.zigythebird.playeranimcore.bones.PlayerAnimBone get3DTransform(com.zigythebird.playeranim.animation.AvatarAnimManager manager, String boneName)
      Reads a bone transform out of PAL's animation stack, keeping the call sites identical across the PAL 1.2 signature change.
    • updateExtraBones

      public static void updateExtraBones(com.zigythebird.playeranim.animation.AvatarAnimManager manager, Set<String> activeBoneNames)
      Updates the extra-bone cache with every bone the FP animation drives.
    • getExtraBone

      @Nullable public static com.zigythebird.playeranimcore.bones.PlayerAnimBone getExtraBone(String name)
      Returns:
      the transform of an extra bone of the current FP animation (for example mag, slide, flash or the model root), or null if it is not animated.
    • getExtraBones

      public static Map<String, com.zigythebird.playeranimcore.bones.PlayerAnimBone> getExtraBones()
      Returns:
      every extra bone transform of the current FP animation, read-only.
    • setArmDisplayTransform

      public static void setArmDisplayTransform(float x, float y, float z, float scale)
      Sets the first-person display transform used by the arm pass. Mods can call this when their item model uses a different firstperson_* display entry.
    • isHandAnchored

      public static boolean isHandAnchored()
      Returns:
      true when the rig is rendered in the vanilla hand frame (fpDisplayAnchor = "hand") instead of the camera frame.
    • applyAnimationDisplayTransform

      public static void applyAnimationDisplayTransform(@Nullable List<?> translation, @Nullable Float scale, @Nullable Object anchor)
      Applies the display transform carried by the current animation, falling back to the transform configured through setArmDisplayTransform(float, float, float, float).
    • resetArmDisplayTransform

      public static void resetArmDisplayTransform()
      Restores the neutral (identity) first-person display transform.
    • isIdentity

      public static boolean isIdentity(com.zigythebird.playeranimcore.bones.PlayerAnimBone bone)
      Returns:
      true when the bone has no position, rotation or scale, i.e. it is not animated.
    • copy

      public static void copy(com.zigythebird.playeranimcore.bones.PlayerAnimBone from, com.zigythebird.playeranimcore.bones.PlayerAnimBone to)
      Copies a complete bone transform (position, rotation and scale) into one of the render state bones.
    • hasRightItemBone

      public static boolean hasRightItemBone()
      Returns:
      true when the current animation contains a right-hand item bone (fp_r_item or the legacy fp_right_item).
    • hasLeftItemBone

      public static boolean hasLeftItemBone()
      Returns:
      true when the current animation contains a left-hand item bone (fp_l_item or the legacy fp_left_item).
    • hasItemBone

      public static boolean hasItemBone(boolean right)
      Parameters:
      right - true for the right hand, false for the left hand
      Returns:
      true when the current animation contains the item bone for that hand
    • setItemBoneActive

      public static void setItemBoneActive(boolean right, boolean left)
      Updates whether the current animation contains the item bones. Called by FpAnimationSystem from the animation's actual bone set, not from transform identity.
    • hasRightArmBone

      public static boolean hasRightArmBone()
      Returns:
      true when the current animation contains the right arm bone (rightArm / right_arm, or the legacy fp_right_arm).
    • hasLeftArmBone

      public static boolean hasLeftArmBone()
      Returns:
      true when the current animation contains the left arm bone (leftArm / left_arm, or the legacy fp_left_arm).
    • hasArmBone

      public static boolean hasArmBone(boolean right)
      Parameters:
      right - true for the right hand, false for the left hand
      Returns:
      true when the current animation contains the arm bone for that hand
    • setArmBoneActive

      public static void setArmBoneActive(boolean right, boolean left)
      Updates whether the current animation contains the arm bones. Called by FpAnimationSystem from the animation's actual bone set.
    • beginCameraTick

      public static void beginCameraTick()
      Saves the current camera transform as the previous tick. Call once before copying a new camera transform into fpCamera.
    • getCameraForRender

      public static com.zigythebird.playeranimcore.bones.PlayerAnimBone getCameraForRender(float partialTick)
      Parameters:
      partialTick - frame interpolation factor in [0, 1]
      Returns:
      the camera transform interpolated between the last two ticks
    • reset

      public static void reset()
      Resets all transforms to identity and leaves first-person arm mode.