diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/AnimationController.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/AnimationController.java index 9f3caa3..b264b55 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/AnimationController.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/AnimationController.java @@ -846,11 +846,12 @@ else if (hasEndTick() && extraData.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 @@ -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); } } diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationContainer.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationContainer.java index a8d8030..5433348 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationContainer.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationContainer.java @@ -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 diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationSnapshot.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationSnapshot.java index 24e53a1..5256a1d 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationSnapshot.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationSnapshot.java @@ -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 diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationStack.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationStack.java index 65466bb..82b5793 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationStack.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationStack.java @@ -37,16 +37,15 @@ public void tick(AnimationData state) { } @Override - public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) { + public void get3DTransform(@NotNull PlayerAnimBone bone) { for (Pair 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 diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/IAnimation.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/IAnimation.java index 039619b..87aaff0 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/IAnimation.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/IAnimation.java @@ -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; } diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/ModifierLayer.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/ModifierLayer.java index 7b9ef2f..407b950 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/ModifierLayer.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/ModifierLayer.java @@ -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 diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/PlayerAnimationFrame.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/PlayerAnimationFrame.java index 551c75a..be55a37 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/PlayerAnimationFrame.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/PlayerAnimationFrame.java @@ -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 { diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/AbstractFadeModifier.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/AbstractFadeModifier.java index d6578b9..86fb015 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/AbstractFadeModifier.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/AbstractFadeModifier.java @@ -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); @@ -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) { diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/AdjustmentModifier.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/AdjustmentModifier.java index fcb166a..a0c55a3 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/AdjustmentModifier.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/AdjustmentModifier.java @@ -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 = source.apply(bone.getName(), data); @@ -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) { diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/MirrorModifier.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/MirrorModifier.java index bfece8c..2050239 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/MirrorModifier.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/modifier/MirrorModifier.java @@ -38,8 +38,11 @@ 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); @@ -47,10 +50,9 @@ public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) { PlayerAnimBone newBone = new PlayerAnimBone(modelName); newBone.copyOtherBone(bone); - newBone = super.get3DTransform(newBone); + super.get3DTransform(newBone); transformBone(newBone); bone.copyOtherBone(newBone); - return bone; } @Override diff --git a/minecraft/common/src/main/java/com/zigythebird/playeranim/animation/AvatarAnimManager.java b/minecraft/common/src/main/java/com/zigythebird/playeranim/animation/AvatarAnimManager.java index 9ae7d31..a8f2dd2 100644 --- a/minecraft/common/src/main/java/com/zigythebird/playeranim/animation/AvatarAnimManager.java +++ b/minecraft/common/src/main/java/com/zigythebird/playeranim/animation/AvatarAnimManager.java @@ -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); } diff --git a/minecraft/common/src/main/java/com/zigythebird/playeranim/animation/layered/modifier/MirrorIfLeftHandModifier.java b/minecraft/common/src/main/java/com/zigythebird/playeranim/animation/layered/modifier/MirrorIfLeftHandModifier.java index e425998..bccba01 100644 --- a/minecraft/common/src/main/java/com/zigythebird/playeranim/animation/layered/modifier/MirrorIfLeftHandModifier.java +++ b/minecraft/common/src/main/java/com/zigythebird/playeranim/animation/layered/modifier/MirrorIfLeftHandModifier.java @@ -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); } } diff --git a/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/ElytraLayerMixin.java b/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/ElytraLayerMixin.java index 1103271..59cf753 100644 --- a/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/ElytraLayerMixin.java +++ b/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/ElytraLayerMixin.java @@ -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); diff --git a/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/LivingEntityRendererMixin.java b/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/LivingEntityRendererMixin.java index 327727e..b447efd 100644 --- a/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/LivingEntityRendererMixin.java +++ b/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/LivingEntityRendererMixin.java @@ -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; diff --git a/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/PlayerCapeModelMixin.java b/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/PlayerCapeModelMixin.java index 94b4f5b..db92a85 100644 --- a/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/PlayerCapeModelMixin.java +++ b/minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/PlayerCapeModelMixin.java @@ -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;