|
18 | 18 |
|
19 | 19 | package io.github.axolotlclient.oldanimations.mixin; |
20 | 20 |
|
21 | | -import com.mojang.blaze3d.platform.GlStateManager; |
| 21 | +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; |
| 22 | +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; |
22 | 23 | import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig; |
23 | | -import net.minecraft.client.entity.living.player.ClientPlayerEntity; |
24 | 24 | import net.minecraft.client.render.entity.layer.CapeLayer; |
| 25 | +import org.spongepowered.asm.mixin.Dynamic; |
25 | 26 | import org.spongepowered.asm.mixin.Mixin; |
26 | 27 | import org.spongepowered.asm.mixin.injection.At; |
27 | | -import org.spongepowered.asm.mixin.injection.Inject; |
28 | | -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
29 | 28 |
|
30 | 29 | @Mixin(CapeLayer.class) |
31 | | -public abstract class CapeLayerMixin { |
| 30 | +public class CapeLayerMixin { |
32 | 31 |
|
33 | | - @Inject(method = "render(Lnet/minecraft/client/entity/living/player/ClientPlayerEntity;FFFFFFF)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;translatef(FFF)V")) |
34 | | - private void axolotlClient$addSneakingTranslation(ClientPlayerEntity clientPlayerEntity, float f, float g, float h, float i, float j, float k, float l, CallbackInfo ci) { |
35 | | - if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.thirdPersonCapePosition.get() && clientPlayerEntity.isSneaking()) { |
36 | | - /* honestly, idk why the cape is positioned differently in 1.8 versus 1.7.... weird lol */ |
37 | | - /* this is a rough estimation of where it should be positioned... not ideal, but its better than nothing lol */ |
38 | | - GlStateManager.translatef(0.0F, 0.0125F, 0.0F); |
| 32 | + @Dynamic("OptiFine") |
| 33 | + @WrapWithCondition(method = "render(Lnet/minecraft/client/entity/living/player/ClientPlayerEntity;FFFFFFF)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;translatef(FFF)V", ordinal = 1)) |
| 34 | + private boolean axolotlclient$disableOptiFineTranslation(float f, float g, float h) { |
| 35 | + /* optifine attemps to fix 1.8's weird cape position... that's all well and good, but let's just disable that when we use our own :p */ |
| 36 | + return !OldAnimationsConfig.isEnabled() || !OldAnimationsConfig.instance.thirdPersonSneaking.get(); |
| 37 | + } |
| 38 | + |
| 39 | + @Dynamic("OptiFine") |
| 40 | + @ModifyExpressionValue(method = "render(Lnet/minecraft/client/entity/living/player/ClientPlayerEntity;FFFFFFF)V", at = @At(value = "CONSTANT", args = "floatValue=165.0")) |
| 41 | + private float axolotlclient$disableOptiFineClamp(float original) { |
| 42 | + if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.thirdPersonSneaking.get()) { |
| 43 | + /* optifine attemps to clamp the cape's physics... nuh uh */ |
| 44 | + return Float.MAX_VALUE; |
| 45 | + } |
| 46 | + return original; |
| 47 | + } |
| 48 | + |
| 49 | + @Dynamic("OptiFine") |
| 50 | + @ModifyExpressionValue(method = "render(Lnet/minecraft/client/entity/living/player/ClientPlayerEntity;FFFFFFF)V", at = @At(value = "CONSTANT", args = "floatValue=-5.0")) |
| 51 | + private float axolotlclient$disableOptiFineClamp2(float original) { |
| 52 | + if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.thirdPersonSneaking.get()) { |
| 53 | + /* optifine attemps to clamp the cape's physics... nuh uh */ |
| 54 | + return Float.MIN_VALUE; |
39 | 55 | } |
| 56 | + return original; |
40 | 57 | } |
41 | 58 | } |
0 commit comments