Skip to content

Commit 580be37

Browse files
committed
fix: hud invisible on NeoForge
1 parent 46229b3 commit 580be37

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/main/java/eu/midnightdust/midnightcontrols/client/gui/MidnightControlsHud.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public void init() {
7575
* Renders the MidnightControls HUD.
7676
*/
7777
public void render(GuiGraphics context, DeltaTracker tickCounter) {
78-
if (this.client == null || !isVisible) return;
78+
if (this.client == null) this.client = Minecraft.getInstance();
79+
if (!isVisible) return;
7980
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && this.client.screen == null) {
8081
isCrammed = client.getWindow().getGuiScaledWidth() < 520;
8182
int y = bottom(2);

src/main/java/eu/midnightdust/midnightcontrols/client/mixin/GameRendererMixin.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ public abstract class GameRendererMixin {
3838
if (this.minecraft.screen != null && MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER)
3939
MidnightControlsClient.input.onPreRenderScreen(this.minecraft.screen);
4040
}
41-
//? fabric
42-
@Inject(method = "render", at = @At(value = "INVOKE, target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltipAndSubtitles(Lnet/minecraft/client/gui/GuiGraphics;IIF)V", shift = At.Shift.AFTER))
43-
//? neoforge
44-
/*@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;drawScreen(Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/GuiGraphics;IIF)V", shift = At.Shift.AFTER))*/
41+
//? fabric {
42+
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltipAndSubtitles(Lnet/minecraft/client/gui/GuiGraphics;IIF)V", shift = At.Shift.AFTER))
43+
//?} else if neoforge {
44+
/*@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;drawScreen(Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/GuiGraphics;IIF)V", shift = At.Shift.AFTER))
45+
*//*?}*/
4546
private void midnightcontrols$renderVirtualCursor(DeltaTracker tickCounter, boolean tick, CallbackInfo ci, @Local GuiGraphics drawContext) {
4647
VirtualCursorRenderer.getInstance().renderCursor(drawContext, minecraft);
4748
if (MidnightControlsClient.isWayland) WaylandCursorRenderer.getInstance().renderCursor(drawContext, minecraft);

src/main/java/eu/midnightdust/midnightcontrols/client/mixin/InGameHudMixin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ public class InGameHudMixin {
1818
MidnightControlsHud.getInstance().init();
1919
}
2020

21-
//? fabric
21+
//? fabric {
2222
@Inject(method = "renderHotbarAndDecorations", at = @At("HEAD"))
23-
//? neoforge
24-
/*@Inject(method = "renderCrosshair", at = @At("HEAD"))*/
23+
//?} else if neoforge {
24+
/*@Inject(method = "renderCrosshair", at = @At("HEAD"))
25+
*///?}
2526
public void midnightcontrols$renderHud(GuiGraphics context, DeltaTracker tickCounter, CallbackInfo ci) {
2627
MidnightControlsHud.getInstance().render(context, tickCounter);
2728
}

0 commit comments

Comments
 (0)