From e8a1e084a24db5fdf1dee9976bacc4766618fa2b Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 12 Dec 2024 21:37:09 -0500 Subject: [PATCH] Add setting to fix arm swing mirroring --- .../animatium/config/AnimatiumConfig.java | 3 +++ .../mixins/MixinBipedEntityModel.java | 22 +++++++++++++++++++ .../assets/animatium/lang/en_us.json | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/main/java/me/mixces/animatium/config/AnimatiumConfig.java b/src/main/java/me/mixces/animatium/config/AnimatiumConfig.java index 5a0b2a0..aa26d90 100644 --- a/src/main/java/me/mixces/animatium/config/AnimatiumConfig.java +++ b/src/main/java/me/mixces/animatium/config/AnimatiumConfig.java @@ -70,6 +70,9 @@ public class AnimatiumConfig extends MidnightConfig { // TODO/NOTE: Currently not accurate/broken public static boolean oldCapeMovement = false; // Changes the cape model movement to be how it used to be + @Entry + public static boolean fixMirrorArmSwing = false; // Fixes arm swing mirroring + @Entry public static CameraVersion cameraVersion = CameraVersion.v1_8; // Change the camera position to be as it was in said version range diff --git a/src/main/java/me/mixces/animatium/mixins/MixinBipedEntityModel.java b/src/main/java/me/mixces/animatium/mixins/MixinBipedEntityModel.java index f400a87..d603986 100644 --- a/src/main/java/me/mixces/animatium/mixins/MixinBipedEntityModel.java +++ b/src/main/java/me/mixces/animatium/mixins/MixinBipedEntityModel.java @@ -1,14 +1,18 @@ package me.mixces.animatium.mixins; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; import me.mixces.animatium.config.AnimatiumConfig; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.state.BipedEntityRenderState; +import net.minecraft.util.Arm; import net.minecraft.util.Identifier; +import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -71,4 +75,22 @@ protected MixinBipedEntityModel(ModelPart modelPart, Function instance, Operation original, @Local ModelPart modelPart) { + if (AnimatiumConfig.fixMirrorArmSwing) { + return modelPart; + } else { + return original.call(instance); + } + } + + @ModifyExpressionValue(method = "animateArms", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;sin(F)F", ordinal = 5)) + public float animatium$fixMirrorArmSwing$sin(float original, @Local Arm arm) { + if (AnimatiumConfig.fixMirrorArmSwing) { + return (arm == Arm.LEFT ? -1 : 1) * original; + } else { + return original; + } + } } diff --git a/src/main/resources/assets/animatium/lang/en_us.json b/src/main/resources/assets/animatium/lang/en_us.json index 6766340..cce39ac 100644 --- a/src/main/resources/assets/animatium/lang/en_us.json +++ b/src/main/resources/assets/animatium/lang/en_us.json @@ -45,6 +45,8 @@ "animatium.midnightconfig.fixBowArmMovement.tooltip": "TODO", "animatium.midnightconfig.oldCapeMovement": "Old cape model movement", "animatium.midnightconfig.oldCapeMovement.tooltip": "TODO", + "animatium.midnightconfig.fixMirrorArmSwing": "Fix arm swing mirroring", + "animatium.midnightconfig.fixMirrorArmSwing.tooltip": "TODO", "animatium.midnightconfig.cameraVersion": "Change camera position to be as it was in", "animatium.midnightconfig.cameraVersion.tooltip": "TODO",