Skip to content

Commit bfb167a

Browse files
committed
fix: resolve crash on Luner Client
1 parent 54b970e commit bfb167a

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a crash when the mod was used on Luner Client

src/main/java/com/github/kd_gaming1/scaleme/client/mixin/MixinInGameHud.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
package com.github.kd_gaming1.scaleme.client.mixin;
22

33
import com.github.kd_gaming1.scaleme.config.ScaleMeConfig;
4+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
5+
import net.minecraft.client.MinecraftClient;
46
import net.minecraft.client.gui.hud.InGameHud;
57
import net.minecraft.client.option.Perspective;
68
import org.spongepowered.asm.mixin.Mixin;
79
import org.spongepowered.asm.mixin.injection.At;
8-
import org.spongepowered.asm.mixin.injection.Redirect;
910

1011
@Mixin(InGameHud.class)
1112
public class MixinInGameHud {
1213

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(
1815
method = "renderCrosshair(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/render/RenderTickCounter;)V",
1916
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z")
2017
)
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) {
2420
return true;
2521
}
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()) {
2827
return ScaleMeConfig.enableCrosshairInThirdPersonFront;
2928
} else {
30-
// Third person back view
3129
return ScaleMeConfig.enableCrosshairInThirdPerson;
3230
}
3331
}

0 commit comments

Comments
 (0)