generated from Polyfrost/OneConfigExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes and make it not have a seizure when rendering anymore
- Loading branch information
Showing
6 changed files
with
391 additions
and
376 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
src/main/java/org/polyfrost/crosshair/mixin/GuiIngameAccessor.java
This file was deleted.
Oops, something went wrong.
33 changes: 24 additions & 9 deletions
33
src/main/java/org/polyfrost/crosshair/mixin/GuiIngameMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
package org.polyfrost.crosshair.mixin; | ||
|
||
import net.minecraft.client.gui.GuiIngame; | ||
import net.minecraft.client.gui.Gui; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.client.GuiIngameForge; | ||
import org.polyfrost.crosshair.CrosshairHUD; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(GuiIngame.class) | ||
public class GuiIngameMixin { | ||
@Inject(method = "showCrosshair", at = @At("HEAD")) | ||
private void check(CallbackInfoReturnable<Boolean> cir) { | ||
//cir.setReturnValue(false); | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(GuiIngameForge.class) | ||
public abstract class GuiIngameMixin { | ||
@Redirect(method = "renderCrosshairs", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;bind(Lnet/minecraft/util/ResourceLocation;)V"), remap = false) | ||
private void bindTexture(GuiIngameForge it, ResourceLocation res) { | ||
if (CrosshairHUD.INSTANCE.getUseVanilla()) bind(res); | ||
else GlStateManager.bindTexture(CrosshairHUD.INSTANCE.getId()); | ||
} | ||
|
||
@Redirect(method = "renderCrosshairs", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;drawTexturedModalRect(IIIIII)V")) | ||
private void drawCrosshair(GuiIngameForge it, int x, int y, int u, int v, int w, int h) { | ||
final float tex = CrosshairHUD.INSTANCE.getUseVanilla() ? 256f : CrosshairHUD.INSTANCE.getWidth(); | ||
// #optimize-fold-zeroes | ||
Gui.drawModalRectWithCustomSizedTexture(x, y, 0f, 0f, w, h, tex, tex); | ||
} | ||
|
||
@Shadow(remap = false) | ||
protected abstract void bind(ResourceLocation res); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/org/polyfrost/crosshair/mixin/GuiIngameShowCrosshairMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.polyfrost.crosshair.mixin; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiIngame; | ||
import org.polyfrost.crosshair.CrosshairHUD; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(GuiIngame.class) | ||
public abstract class GuiIngameShowCrosshairMixin { | ||
@Inject(method = "showCrosshair", at = @At(value = "RETURN", ordinal = 0), cancellable = true) | ||
private void showWhenDebug(CallbackInfoReturnable<Boolean> cir) { | ||
if (CrosshairHUD.INSTANCE.getShowInDebug()) cir.setReturnValue(true); | ||
} | ||
|
||
@Inject(method = "showCrosshair", at = @At("HEAD"), cancellable = true) | ||
private void showWhenPerspective(CallbackInfoReturnable<Boolean> cir) { | ||
if (!CrosshairHUD.INSTANCE.getShowInThirdPerson() && Minecraft.getMinecraft().gameSettings.thirdPersonView != 0) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
|
||
@Inject(method = "showCrosshair", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;pointedEntity:Lnet/minecraft/entity/Entity;"), cancellable = true) | ||
private void showWhenSpectator(CallbackInfoReturnable<Boolean> cir) { | ||
if (CrosshairHUD.INSTANCE.getShowInSpectator()) cir.setReturnValue(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.