Skip to content

Commit

Permalink
Replace Redirect -> WrapOperation in MixinInGameHud#alwaysRenderCross…
Browse files Browse the repository at this point in the history
…hair (#649)
  • Loading branch information
lowercasebtw authored Dec 7, 2024
1 parent af6caab commit 7421abe
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
import net.minecraft.client.MinecraftClient;
Expand All @@ -37,7 +39,6 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
Expand All @@ -62,12 +63,12 @@ private boolean disableEmptyBubbles(DrawContext instance, Function<Identifier, R
return !VisualSettings.global().hideEmptyBubbleIcons.getValue();
}

@Redirect(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z"))
private boolean alwaysRenderCrosshair(Perspective instance) {
@WrapOperation(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z"))
private boolean alwaysRenderCrosshair(Perspective instance, Operation<Boolean> original) {
if (VisualSettings.global().alwaysRenderCrosshair.isEnabled()) {
return true;
} else {
return instance.isFirstPerson();
return original.call(instance);
}
}

Expand Down

0 comments on commit 7421abe

Please sign in to comment.