Skip to content

Commit

Permalink
Add setting to fix arm swing mirroring
Browse files Browse the repository at this point in the history
  • Loading branch information
lowercasebtw committed Dec 13, 2024
1 parent cfa88b6 commit e8a1e08
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/me/mixces/animatium/config/AnimatiumConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -71,4 +75,22 @@ protected MixinBipedEntityModel(ModelPart modelPart, Function<Identifier, Render
}
}
}

@WrapOperation(method = "animateArms", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;leftArm:Lnet/minecraft/client/model/ModelPart;", opcode = Opcodes.GETFIELD, ordinal = 3))
public ModelPart animatium$fixMirrorArmSwing$field(BipedEntityModel<?> instance, Operation<ModelPart> 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;
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/animatium/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down

0 comments on commit e8a1e08

Please sign in to comment.