From 2cb50a171901583ea6f90a5d5b94dc6aee892bfa Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Tue, 22 Oct 2024 18:23:03 +0200 Subject: [PATCH] Add setting for body rotation interpolation fix Some mods changing the player rotation will break with this fix since they hook into the getYaw() call of the original function which we don't account for. --- .../mixin/fixes/minecraft/entity/MixinLivingEntity.java | 2 +- .../viafabricplus/settings/impl/VisualSettings.java | 3 +++ src/main/resources/assets/viafabricplus/lang/de_de.json | 1 + src/main/resources/assets/viafabricplus/lang/en_us.json | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java index e19385a7..922e4ce3 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java @@ -116,7 +116,7 @@ public abstract class MixinLivingEntity extends Entity { @Redirect(method = "turnHead", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(F)F")) private float changeBodyRotationInterpolation(float g) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_3)) { + if (VisualSettings.global().changeBodyRotationInterpolation.isEnabled()) { g = MathHelper.clamp(g, -75.0F, 75.0F); this.bodyYaw = this.getYaw() - g; if (Math.abs(g) > 50.0F) { diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java index 3f50b9e6..1ae160b5 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java @@ -57,6 +57,9 @@ public class VisualSettings extends SettingGroup { // 1.21 -> 1.20.5 public final VersionedBooleanSetting hideDownloadTerrainScreenTransitionEffects = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_download_terrain_screen_transition_effects"), VersionRange.andOlder(ProtocolVersion.v1_20_5)); + // 1.19.4 -> 1.19.3 + public final VersionedBooleanSetting changeBodyRotationInterpolation = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.change_body_rotation_interpolation"), VersionRange.andOlder(ProtocolVersion.v1_19_3)); + // 1.19.2 -> 1.19 public final VersionedBooleanSetting disableSecureChatWarning = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.disable_secure_chat_warning"), VersionRange.andOlder(ProtocolVersion.v1_19)); diff --git a/src/main/resources/assets/viafabricplus/lang/de_de.json b/src/main/resources/assets/viafabricplus/lang/de_de.json index 583a899e..6e9b13ca 100644 --- a/src/main/resources/assets/viafabricplus/lang/de_de.json +++ b/src/main/resources/assets/viafabricplus/lang/de_de.json @@ -107,6 +107,7 @@ "visual_settings.viafabricplus.force_unicode_font_for_non_ascii_languages": "Unicode-Schriftart für Nicht-ASCII-Sprachen erzwingen", "visual_settings.viafabricplus.filter_non_existing_glyphs": "Nicht vorhandene Glyphen filtern", "visual_settings.viafabricplus.sneak_instantly": "Sofort schleichen", + "visual_settings.viafabricplus.change_body_rotation_interpolation": "Interpolation der Körperdrehung ändern", "force_version.viafabricplus.title": "Bitte wähle die Version, mit der der Server gepingt/verbunden werden soll", diff --git a/src/main/resources/assets/viafabricplus/lang/en_us.json b/src/main/resources/assets/viafabricplus/lang/en_us.json index 5dae3cf3..9e0da597 100644 --- a/src/main/resources/assets/viafabricplus/lang/en_us.json +++ b/src/main/resources/assets/viafabricplus/lang/en_us.json @@ -107,6 +107,7 @@ "visual_settings.viafabricplus.force_unicode_font_for_non_ascii_languages": "Force Unicode font for non-ASCII languages", "visual_settings.viafabricplus.filter_non_existing_glyphs": "Filter non existing glyphs", "visual_settings.viafabricplus.sneak_instantly": "Sneak instantly", + "visual_settings.viafabricplus.change_body_rotation_interpolation": "Change body rotation interpolation", "force_version.viafabricplus.title": "Please select the version with which the server should be pinged/connected",