Class FpArmRenderUtil
1:1 port of AzureLib's AzItemArmRenderUtil (MIT License, Copyright (c) 2024 AzureDoom),
adapted only for PAL's types (PlayerAnimBone instead of AzBone,
FpRenderBuffer instead of AzModelRenderer).
AzureLib does not animate a separate first-person arm model: the leftArm / rightArm
bones are part of the animated model, and this class draws the vanilla arm mesh at that bone (the
bone itself stays hidden). The pose must already be in the model frame, created by
applyCameraAnchor(PoseStack) or applyHandTransform(PoseStack, boolean) plus
applyArmDisplayTransform(PoseStack, float[], float).
PAL's loader keeps the raw Blockbench values, so the X/Y negation AzureLib applies when baking is
done here in translateMatrixToBone(PoseStack, PlayerAnimBone) and
rotateMatrixAroundBone(PoseStack, PlayerAnimBone) (rotation order Z, Y, X).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringBone name used by AzureLib and byplayer_arms_import.bbmodel.static final float[]Rotation centre of the left arm as authored inplayer_arms_import.bbmodel.static final float[]Pivot of thefp_l_itembone, mirror ofRIGHT_ITEM_PIVOT.static final float[]The rig root needs no pivot translation: its pivot is the model origin.static final StringBone name used by AzureLib and byplayer_arms_import.bbmodel.static final float[]Rotation centre of the right arm in model units, as stored after AzureLib's X mirroring.static final float[]Pivot of thefp_r_itembone, which sits on the hand likerightArm. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyArmDisplayTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, float[] translation, float scale) Applies the display transform of the item model that owns the arm bones: the translation (in 1/16 block) and uniform scale of afirstperson_*entry.static voidapplyArmTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone arm, float[] pivot) Applies an arm bone's full transform in the model frame.static voidapplyBoneTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) Applies the offset, rotation and scale of a bone around the pose origin.static voidapplyBoneTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone, float[] pivot) Applies the offset, pivot, rotation and scale of a bone in one go (same order asRenderUtils.prepMatrixForBone).static voidapplyCameraAnchor(com.mojang.blaze3d.vertex.PoseStack poseStack) Applies the camera anchor: same distance and height as the vanilla hand anchor, but on the view axis, so a rig authored around the model origin renders centred like in Blockbench.static voidapplyCameraTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone camera) Applies thefp_cameratransform, which moves, rotates and scales the first-person pass around the view origin.static voidapplyHandTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, boolean isLeftHand) Applies the vanilla first-person hand anchor (without equip progress), the frame AzureLib gun rigs are authored against.static voidapplyItemTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone item) Applies the item bone offset in the model frame, keeping the item on the model origin (thefpDisplayAnchor: "hand"convention).static voidapplyItemTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone item, float[] pivot) Applies the item bone transform so the item model ends up on the bone itself.static voidapplyRootTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone wholeRig) Applies thefp_player_armsroot transform, which moves, rotates and scales the whole rig (both arms and both held items) around the model origin.static voidapplyRootTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone wholeRig, float[] pivot) Applies the animated model root around its own pivot, like AzureLib'sprepMatrixForBone.static booleanisArmBone(com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) static voidrenderArmForBone(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone, float[] pivot, net.minecraft.client.model.player.PlayerModel playerModel, net.minecraft.resources.Identifier playerSkin, int packedLight, FpRenderBuffer render) Renders the vanilla player arm for the given arm bone, hiding the bone itself but keeping children visible.static voidRestores the vanilla arm and sleeve parts of the local player's shared model, so the third-person renderer never inherits the first-person rig pose.static voidrotateMatrixAroundBone(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) static voidscaleMatrixForBone(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) static voidtranslateAwayFromPivotPoint(com.mojang.blaze3d.vertex.PoseStack poseStack, float[] pivot) static voidtranslateMatrixToBone(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) Same convention as AzureLib'stranslateMatrixToBone: X is negated and Y is not, because PAL's loader keeps the raw Blockbench value.static voidtranslateToPivotPoint(com.mojang.blaze3d.vertex.PoseStack poseStack, float[] pivot)
-
Field Details
-
LEFT_ARM_BONE
Bone name used by AzureLib and byplayer_arms_import.bbmodel.- See Also:
-
RIGHT_ARM_BONE
Bone name used by AzureLib and byplayer_arms_import.bbmodel.- See Also:
-
RIGHT_ARM_PIVOT
public static final float[] RIGHT_ARM_PIVOTRotation centre of the right arm in model units, as stored after AzureLib's X mirroring. -
LEFT_ARM_PIVOT
public static final float[] LEFT_ARM_PIVOTRotation centre of the left arm as authored inplayer_arms_import.bbmodel. -
RIGHT_ITEM_PIVOT
public static final float[] RIGHT_ITEM_PIVOTPivot of thefp_r_itembone, which sits on the hand likerightArm. -
LEFT_ITEM_PIVOT
public static final float[] LEFT_ITEM_PIVOTPivot of thefp_l_itembone, mirror ofRIGHT_ITEM_PIVOT. -
NO_PIVOT
public static final float[] NO_PIVOTThe rig root needs no pivot translation: its pivot is the model origin.
-
-
Method Details
-
isArmBone
public static boolean isArmBone(com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) - Returns:
- true if this is a left or right arm bone
-
renderArmForBone
public static void renderArmForBone(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone, float[] pivot, net.minecraft.client.model.player.PlayerModel playerModel, net.minecraft.resources.Identifier playerSkin, int packedLight, FpRenderBuffer render) Renders the vanilla player arm for the given arm bone, hiding the bone itself but keeping children visible. The pose stack must already be in the model frame and contain the parent chain of the arm (for PAL's first-person rig,fp_player_arms). -
resetPlayerModelArms
public static void resetPlayerModelArms()Restores the vanilla arm and sleeve parts of the local player's shared model, so the third-person renderer never inherits the first-person rig pose. -
applyHandTransform
public static void applyHandTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, boolean isLeftHand) Applies the vanilla first-person hand anchor (without equip progress), the frame AzureLib gun rigs are authored against. -
applyCameraAnchor
public static void applyCameraAnchor(com.mojang.blaze3d.vertex.PoseStack poseStack) Applies the camera anchor: same distance and height as the vanilla hand anchor, but on the view axis, so a rig authored around the model origin renders centred like in Blockbench. -
applyArmDisplayTransform
public static void applyArmDisplayTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, float[] translation, float scale) Applies the display transform of the item model that owns the arm bones: the translation (in 1/16 block) and uniform scale of afirstperson_*entry. -
applyRootTransform
public static void applyRootTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone wholeRig) Applies thefp_player_armsroot transform, which moves, rotates and scales the whole rig (both arms and both held items) around the model origin. -
applyRootTransform
public static void applyRootTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone wholeRig, float[] pivot) Applies the animated model root around its own pivot, like AzureLib'sprepMatrixForBone.- Parameters:
pivot- root pivot in model units (FpRenderState.fpRootPivot)
-
applyCameraTransform
public static void applyCameraTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone camera) Applies thefp_cameratransform, which moves, rotates and scales the first-person pass around the view origin. The camera keeps PAL's(+X, -Y, +Z)convention. -
applyArmTransform
public static void applyArmTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone arm, float[] pivot) Applies an arm bone's full transform in the model frame. This is the same transform used byrenderArmForBone(PoseStack, PlayerAnimBone, float[], PlayerModel, Identifier, int, FpRenderBuffer), exposed so a held item can be rendered in exactly the same arm frame. -
applyItemTransform
public static void applyItemTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone item) Applies the item bone offset in the model frame, keeping the item on the model origin (thefpDisplayAnchor: "hand"convention). A rig authored around the model origin usesapplyItemTransform(PoseStack, PlayerAnimBone, float[])instead. -
applyItemTransform
public static void applyItemTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone item, float[] pivot) Applies the item bone transform so the item model ends up on the bone itself. Vanilla draws the item's1x1x1box around the origin of the frame it is handed, so the box has to be moved to the bone origin before the bone rotation is applied; rotating it about the pivot without that translation would offset it by-R * pivot.- Parameters:
pivot- the bone origin in model units, orNO_PIVOTfor a rig whose item sits on the model origin
-
applyBoneTransform
public static void applyBoneTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) Applies the offset, rotation and scale of a bone around the pose origin. -
applyBoneTransform
public static void applyBoneTransform(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone, float[] pivot) Applies the offset, pivot, rotation and scale of a bone in one go (same order asRenderUtils.prepMatrixForBone).- Parameters:
pivot- rotation centre in model units (raw model space, Y keeps its sign here)
-
translateMatrixToBone
public static void translateMatrixToBone(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) Same convention as AzureLib'stranslateMatrixToBone: X is negated and Y is not, because PAL's loader keeps the raw Blockbench value. -
translateToPivotPoint
public static void translateToPivotPoint(com.mojang.blaze3d.vertex.PoseStack poseStack, float[] pivot) -
rotateMatrixAroundBone
public static void rotateMatrixAroundBone(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) -
scaleMatrixForBone
public static void scaleMatrixForBone(com.mojang.blaze3d.vertex.PoseStack poseStack, com.zigythebird.playeranimcore.bones.PlayerAnimBone bone) -
translateAwayFromPivotPoint
public static void translateAwayFromPivotPoint(com.mojang.blaze3d.vertex.PoseStack poseStack, float[] pivot)
-