|
1 | 1 | package com.github.kd_gaming1.scaleme.client.mixin; |
2 | 2 |
|
3 | 3 | import com.github.kd_gaming1.scaleme.config.ScaleMeConfig; |
| 4 | +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; |
| 5 | +import net.minecraft.client.MinecraftClient; |
4 | 6 | import net.minecraft.client.gui.hud.InGameHud; |
5 | 7 | import net.minecraft.client.option.Perspective; |
6 | 8 | import org.spongepowered.asm.mixin.Mixin; |
7 | 9 | import org.spongepowered.asm.mixin.injection.At; |
8 | | -import org.spongepowered.asm.mixin.injection.Redirect; |
9 | 10 |
|
10 | 11 | @Mixin(InGameHud.class) |
11 | 12 | public class MixinInGameHud { |
12 | 13 |
|
13 | | - /** |
14 | | - * Redirects the perspective check in the crosshair rendering method to allow |
15 | | - * crosshair visibility in third person based on configuration settings. |
16 | | - */ |
17 | | - @Redirect( |
| 14 | + @ModifyExpressionValue( |
18 | 15 | method = "renderCrosshair(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/render/RenderTickCounter;)V", |
19 | 16 | at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z") |
20 | 17 | ) |
21 | | - private boolean shouldRenderCrosshair(Perspective perspective) { |
22 | | - // Always render in first person |
23 | | - if (perspective.isFirstPerson()) { |
| 18 | + private boolean shouldRenderCrosshair(boolean original) { |
| 19 | + if (original) { |
24 | 20 | return true; |
25 | 21 | } |
26 | | - // Check configuration for third person views |
27 | | - else if (perspective.isFrontView()) { |
| 22 | + |
| 23 | + MinecraftClient client = MinecraftClient.getInstance(); |
| 24 | + Perspective perspective = client.options.getPerspective(); |
| 25 | + |
| 26 | + if (perspective.isFrontView()) { |
28 | 27 | return ScaleMeConfig.enableCrosshairInThirdPersonFront; |
29 | 28 | } else { |
30 | | - // Third person back view |
31 | 29 | return ScaleMeConfig.enableCrosshairInThirdPerson; |
32 | 30 | } |
33 | 31 | } |
|
0 commit comments