From 6c17a2c6e19532b64b6874ab751d63cebae9025a Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Thu, 2 Mar 2023 20:25:25 +0100 Subject: [PATCH] added OldWalkingAnimation in classic --- gradle.properties | 2 +- .../fixes/visual/MixinBipedEntityModel.java | 32 +++++++++++++++++++ .../settings/groups/VisualSettings.java | 1 + src/main/resources/viafabricplus.mixins.json | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/visual/MixinBipedEntityModel.java diff --git a/gradle.properties b/gradle.properties index cf598e1a..7efe6566 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ minecraft_version=1.19.3 yarn_mappings=1.19.3+build.5 loader_version=0.14.14 -mod_version=1.5.6 +mod_version=1.5.7 maven_group=de.florianmichael archives_base_name=viafabricplus diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/visual/MixinBipedEntityModel.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/visual/MixinBipedEntityModel.java new file mode 100644 index 00000000..08c2bdd7 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/visual/MixinBipedEntityModel.java @@ -0,0 +1,32 @@ +package de.florianmichael.viafabricplus.injection.mixin.fixes.visual; + +import de.florianmichael.viafabricplus.settings.groups.VisualSettings; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.MathHelper; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(BipedEntityModel.class) +public class MixinBipedEntityModel { + + @Shadow @Final public ModelPart rightArm; + + @Shadow @Final public ModelPart leftArm; + + @Inject(method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/model/ModelPart;roll:F", ordinal = 1, shift = At.Shift.AFTER)) + public void addOldWalkAnimation(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) { + if (VisualSettings.getClassWrapper().oldWalkingAnimation.getValue()) { + this.rightArm.pitch = MathHelper.cos(f * 0.6662F + 3.1415927F) * 2.0F * g; + this.rightArm.roll = (MathHelper.cos(f * 0.2312F) + 1.0F) * 1.0F * g; + + this.leftArm.pitch = MathHelper.cos(f * 0.6662F) * 2.0F * g; + this.leftArm.roll = (MathHelper.cos(f * 0.2812F) - 1.0F) * 1.0F * g; + } + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/groups/VisualSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/groups/VisualSettings.java index f4e07b71..66102bbb 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/groups/VisualSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/groups/VisualSettings.java @@ -27,6 +27,7 @@ public class VisualSettings extends SettingGroup { // a1_0_15 -> c0_28toc0_30 public final ProtocolSyncBooleanSetting replaceCreativeInventory = new ProtocolSyncBooleanSetting(this, "Replace creative inventory", ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30)); + public final ProtocolSyncBooleanSetting oldWalkingAnimation = new ProtocolSyncBooleanSetting(this, "Old walking animation", ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30)); public VisualSettings() { super("Visual"); diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 0e6dbc20..f9e64b2e 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -134,6 +134,7 @@ "bridge.MixinConnectScreen", "bridge.MixinDownloadingTerrainScreen", "fixes.screen.MixinChatScreen", + "fixes.visual.MixinBipedEntityModel", "fixes.visual.MixinChatHud", "fixes.visual.MixinChatScreen", "fixes.visual.MixinClientPlayerEntity",