Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,12 @@ else if (hasEndTick() && extraData.<Float>get(ExtraAnimationData.END_TICK_KEY).g
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
public void get3DTransform(@NotNull PlayerAnimBone bone) {
if (!modifiers.isEmpty()) {
return modifiers.getFirst().get3DTransform(bone);
modifiers.getFirst().get3DTransform(bone);
return;
}
return get3DTransformRaw(bone);
get3DTransformRaw(bone);
}

@Override
Expand Down Expand Up @@ -1065,8 +1066,8 @@ public void setupAnim(AnimationData state) {
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
return this.anim.get3DTransformRaw(bone);
public void get3DTransform(@NotNull PlayerAnimBone bone) {
this.anim.get3DTransformRaw(bone);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ public void tick(AnimationData state) {
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
if (anim != null) return anim.get3DTransform(bone);
return bone;
public void get3DTransform(@NotNull PlayerAnimBone bone) {
if (anim != null) anim.get3DTransform(bone);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ public boolean isActive() {
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
public void get3DTransform(@NotNull PlayerAnimBone bone) {
if (snapshots.containsKey(bone.getName())) {
return bone.copySnapshotSafe(snapshots.get(bone.getName()));
bone.copySnapshotSafe(snapshots.get(bone.getName()));
}
return bone;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@ public void tick(AnimationData state) {
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
public void get3DTransform(@NotNull PlayerAnimBone bone) {
for (Pair<Integer, IAnimation> layer : layers) {
if (layer.right().isActive() /*
Not sure if this is necessary, hard to implement rn
&& (!FirstPersonMode.isFirstPersonPass() || layer.right().getFirstPersonMode().isEnabled())
*/) {
bone = layer.right().get3DTransform(bone);
layer.right().get3DTransform(bone);
}
}
return bone;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ default void setupAnim(AnimationData state) {}
* @param bone the bone being currently animated.
* KEEP IN MIND THAT THE BONE RETURNED ISN'T ALWAYS THE SAME AS THE INPUT BONE!
*/
default PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
void get3DTransform(@NotNull PlayerAnimBone bone);

default PlayerAnimBone get3DTransform(@NotNull String name) {
PlayerAnimBone bone = new PlayerAnimBone(name);
get3DTransform(bone);
return bone;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ public boolean isActive() {
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
public void get3DTransform(@NotNull PlayerAnimBone bone) {
if (!modifiers.isEmpty()) {
return modifiers.get(0).get3DTransform(bone);
} else if (animation != null) return animation.get3DTransform(bone);
return bone;
modifiers.getFirst().get3DTransform(bone);
} else if (animation != null) {
animation.get3DTransform(bone);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ public void enableAll() {
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
public void get3DTransform(@NotNull PlayerAnimBone bone) {
PlayerBone part = parts.get(bone.getName());
if (part != null) return part.applyToBone(bone);
return bone;
if (part != null) part.applyToBone(bone);
}

public static class PlayerBone {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ public void tick(AnimationData state) {
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
public void get3DTransform(@NotNull PlayerAnimBone bone) {
if (calculateProgress(tickDelta, bone.getName()) > 1) {
return super.get3DTransform(bone);
super.get3DTransform(bone);
return;
}
PlayerAnimBone copy2 = new PlayerAnimBone(bone.getName());
copy2.copyOtherBone(bone);
Expand All @@ -95,7 +96,7 @@ public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
if (getFadeType() == FadeType.FADE_IN) {
if (transitionAnimation != null && transitionAnimation.isActive()) transitionAnimation.get3DTransform(bone);
}
return bone.scale(1 - a).add(copy2.scale(a));
bone.scale(1 - a).add(copy2.scale(a));
}

protected float calculateProgress(float f, String boneName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,10 @@ protected float getFadeIn() {
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
public void get3DTransform(@NotNull PlayerAnimBone bone) {
if (!enabled) {
return super.get3DTransform(bone);
super.get3DTransform(bone);
return;
}

Optional<PartModifier> partModifier = source.apply(bone.getName(), data);
Expand All @@ -218,9 +219,9 @@ public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
if (partModifier.isPresent()) {
super.get3DTransform(bone);
transformBone(bone, partModifier.get(), fade);
return bone;
return;
}
return super.get3DTransform(bone);
super.get3DTransform(bone);
}

protected void transformBone(PlayerAnimBone bone, PartModifier partModifier, float fade) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,21 @@ public class MirrorModifier extends AbstractModifier {
public boolean enabled = true;

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
if (!enabled) return super.get3DTransform(bone);
public void get3DTransform(@NotNull PlayerAnimBone bone) {
if (!enabled) {
super.get3DTransform(bone);
return;
}

String modelName = bone.getName();
if (mirrorMap.containsKey(modelName)) modelName = mirrorMap.get(modelName);
transformBone(bone);

PlayerAnimBone newBone = new PlayerAnimBone(modelName);
newBone.copyOtherBone(bone);
newBone = super.get3DTransform(newBone);
super.get3DTransform(newBone);
transformBone(newBone);
bone.copyOtherBone(newBone);
Copy link
Owner

@ZigyTheBird ZigyTheBird Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for the change was that for example here instead of applying newBone to bone you can just return newBone
But I guess I forgot to do that here...
Originally get3DTransform actually returned void very early in development

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let it return void again

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You gotta acknowledge that the way I did it has some advantages
I recognize it returning void also has it's own advantages, but at this point we gotta really consider if the change is worthwhile given the existence of multi version projects that might suffer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problems of multi-version projects are not our problems.
Returning the bone back creates confusing, and personally, I don't understand how to use it correctly.
Some people may return the wrong bone, and we will never know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi-version projects may simply not use the return value

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have personally had issues with returning the wrong bone and then getting stumped about why shit isn't working
I was about to write a paragraph about multi-version projects, but like now that I think about it fuck that

return bone;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void setTickDelta(float tickDelta) {

public void updatePart(ModelPart part, PlayerAnimBone bone) {
PartPose initialPose = part.getInitialPose();
bone = this.get3DTransform(bone);
this.get3DTransform(bone);
RenderUtil.translatePartToBone(part, bone, initialPose);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public MirrorIfLeftHandModifier() {
}

@Override
public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) {
if (getController() instanceof PlayerAnimationController controller && controller.getAvatar() == Minecraft.getInstance().player && Minecraft.getInstance().options.mainHand().get() == HumanoidArm.LEFT) return bone;
return super.get3DTransform(bone);
public void get3DTransform(@NotNull PlayerAnimBone bone) {
if (getController() instanceof PlayerAnimationController controller && controller.getAvatar() == Minecraft.getInstance().player && Minecraft.getInstance().options.mainHand().get() == HumanoidArm.LEFT) return;
super.get3DTransform(bone);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ private void inject(PoseStack poseStack, SubmitNodeCollector submitNodeCollector
if (emote != null && emote.isActive() && this.renderer instanceof AvatarRenderer<?> playerRenderer) {
playerRenderer.getModel().body.translateAndRotate(poseStack);
poseStack.translate(0, 0, 0.125);
PlayerAnimBone bone = emote.get3DTransform(new PlayerAnimBone("elytra"));
bone.applyOtherBone(emote.get3DTransform(new PlayerAnimBone("cape")));
PlayerAnimBone bone = emote.get3DTransform("elytra");
bone.applyOtherBone(emote.get3DTransform("cape"));
bone.positionY *= -1;
RenderUtil.translateMatrixToBone(poseStack, bone);
poseStack.translate(0, 0, -0.125);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void doTranslations(S livingEntityRenderState, PoseStack poseStack, Subm
poseStack.scale(-1.0F, -1.0F, 1.0F);

//These are additive properties
PlayerAnimBone body = animationPlayer.get3DTransform(new PlayerAnimBone("body"));
PlayerAnimBone body = animationPlayer.get3DTransform("body");

poseStack.translate(-body.getPosX()/16, body.getPosY()/16 + 0.75, body.getPosZ()/16);
body.rotX *= -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void setupAnim(AvatarRenderState avatarRenderState, CallbackInfo ci) {
bone.rotZ -= MochaMath.PI;
bone.rotX *= -1;
bone.rotY *= -1;
bone = emote.get3DTransform(bone);
emote.get3DTransform(bone);
bone.rotX *= -1;
bone.rotY *= -1;
bone.rotX += MochaMath.PI;
Expand Down