Class FpRenderState
java.lang.Object
com.github.razorplay01.fp_pal.firstperson.FpRenderState
Holds the current first-person render state.
Updated every tick and read during rendering.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic floatUniform first-person display scale of the arm model, seeARM_DISPLAY_TRANSLATION.static final float[]First-person display translation of the arm model, in 1/16 block, like thetranslationof afirstperson_*item model entry.static final StringExtra 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 Stringstatic final StringExtra animation data keys used to overrideARM_DISPLAY_TRANSLATIONandARM_DISPLAY_SCALEper animation.static final com.zigythebird.playeranimcore.bones.PlayerAnimBoneThe FP camera transform.static final com.zigythebird.playeranimcore.bones.PlayerAnimBoneThe FP left arm bone transform, named like AzureLib'sleftArm.static final com.zigythebird.playeranimcore.bones.PlayerAnimBoneThe FP left item bone transform (for item offset in left hand).static final com.zigythebird.playeranimcore.bones.PlayerAnimBoneThe 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.PlayerAnimBoneThe FP right arm bone transform, named like AzureLib'srightArm.static final com.zigythebird.playeranimcore.bones.PlayerAnimBoneThe 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 booleanWhether FP rendering is active (a FP animation is currently playing).static booleanWhether the local player's held item is currently drawn with thefp_r_item/fp_l_itembone pose applied. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyAnimationDisplayTransform(List<?> translation, Float scale, Object anchor) Applies the display transform carried by the current animation, falling back to the transform configured throughsetArmDisplayTransform(float, float, float, float).static voidSaves the current camera transform as the previous tick.static voidcaptureItemFrame(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 voidcopy(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.FirstPersonConfigurationfirstPersonConfiguration(net.minecraft.world.entity.Entity entity) static com.zigythebird.playeranimcore.bones.PlayerAnimBoneget3DTransform(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.PlayerAnimBonegetCameraForRender(float partialTick) static com.zigythebird.playeranimcore.bones.PlayerAnimBonegetExtraBone(String name) static booleanhasArmBone(boolean right) static booleanhasItemBone(boolean right) static booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanisIdentity(com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) static booleanisPlayerArmMode(net.minecraft.world.entity.Entity entity) static voidreset()Resets all transforms to identity and leaves first-person arm mode.static voidRestores the neutral (identity) first-person display transform.static voidrestoreItemFrame(com.mojang.blaze3d.vertex.PoseStack poseStack) Rewinds the top of the pose stack to the frame captured bycaptureItemFrame(PoseStack), dropping every transform vanilla applied since then.static voidrotatePose(com.mojang.blaze3d.vertex.PoseStack poseStack, org.joml.Quaternionf rotation) Rotates the pose by a quaternion, hiding the 26.3mulPose->rotaterename.static voidsetArmBoneActive(boolean right, boolean left) Updates whether the current animation contains the arm bones.static voidsetArmDisplayTransform(float x, float y, float z, float scale) Sets the first-person display transform used by the arm pass.static voidsetItemBoneActive(boolean right, boolean left) Updates whether the current animation contains the item bones.static voidupdateExtraBones(com.zigythebird.playeranim.animation.AvatarAnimManager manager, Set<String> activeBoneNames) Updates the extra-bone cache with every bone the FP animation drives.
-
Field Details
-
isFpActive
public static boolean isFpActiveWhether FP rendering is active (a FP animation is currently playing). -
isFpItemPass
public static boolean isFpItemPassWhether the local player's held item is currently drawn with thefp_r_item/fp_l_itembone pose applied. While set,ItemTransformMixinskips vanilla's item display transform so the item lands where the animation puts it. -
fpPlayerArms
public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpPlayerArmsThe FP root bone (fp_player_arms), which moves and rotates the whole rig (arms, held items and the camera). -
fpRootPivot
public static float[] fpRootPivotRotation centre of the animation's model root in model units.FpAnimationSystemsets it when resolving the root bone; most rigs use the origin. -
fpRightArm
public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpRightArmThe FP right arm bone transform, named like AzureLib'srightArm. -
fpLeftArm
public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpLeftArmThe FP left arm bone transform, named like AzureLib'sleftArm. -
fpRightItem
public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpRightItemThe FP right item bone transform (for item offset in right hand). -
fpLeftItem
public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpLeftItemThe FP left item bone transform (for item offset in left hand). -
fpCamera
public static final com.zigythebird.playeranimcore.bones.PlayerAnimBone fpCameraThe FP camera transform. -
ARM_DISPLAY_TRANSLATION
public static final float[] ARM_DISPLAY_TRANSLATIONFirst-person display translation of the arm model, in 1/16 block, like thetranslationof afirstperson_*item model entry. An FP animation can override it through the extra data keysfpDisplayTranslation,fpDisplayScaleandfpDisplayAnchor. -
ARM_DISPLAY_SCALE
public static float ARM_DISPLAY_SCALEUniform first-person display scale of the arm model, seeARM_DISPLAY_TRANSLATION. -
FP_DISPLAY_TRANSLATION_KEY
Extra animation data keys used to overrideARM_DISPLAY_TRANSLATIONandARM_DISPLAY_SCALEper animation.- See Also:
-
FP_DISPLAY_SCALE_KEY
- See Also:
-
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.FpArmRendererMixinrewinds 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 bycaptureItemFrame(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
FirstPersonConfigurationthat decides what the first-person pass draws. It comes from this addon's controller rather than PAL's manager, because this controller reportsFirstPersonMode.NONEand 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.3mulPose->rotaterename. -
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
-
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,flashor the model root), ornullif it is not animated.
-
getExtraBones
-
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 differentfirstperson_*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 throughsetArmDisplayTransform(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_itemor the legacyfp_right_item).
-
hasLeftItemBone
public static boolean hasLeftItemBone()- Returns:
- true when the current animation contains a left-hand item bone (
fp_l_itemor the legacyfp_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 byFpAnimationSystemfrom 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 legacyfp_right_arm).
-
hasLeftArmBone
public static boolean hasLeftArmBone()- Returns:
- true when the current animation contains the left arm bone (
leftArm/left_arm, or the legacyfp_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 byFpAnimationSystemfrom 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 intofpCamera. -
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.
-