Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed malilib#163 - onRenderGameOverlayPost not actually rendering above all Hud Elements #164

Open
wants to merge 2 commits into
base: pre-rewrite/fabric/1.21.1-masa
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/main/java/fi/dy/masa/malilib/mixin/MixinInGameHud.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
package fi.dy.masa.malilib.mixin;

import fi.dy.masa.malilib.event.RenderEventHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import org.spongepowered.asm.mixin.Final;
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.CallbackInfo;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import fi.dy.masa.malilib.event.RenderEventHandler;

@Mixin(InGameHud.class)
public abstract class MixinInGameHud
{
@Shadow @Final private MinecraftClient client;
@Mixin(value = InGameHud.class)
public abstract class MixinInGameHud {
@Shadow
@Final
private MinecraftClient client;
@Shadow
@Final
private LayeredDrawer layeredDrawer;

@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
this.layeredDrawer.addLayer(this::renderGameOverlayPost);
}

@Inject(method = "render", at = @At("RETURN"))
private void onGameOverlayPost(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci)
{
private void renderGameOverlayPost(DrawContext context, RenderTickCounter tickCounter) {
((RenderEventHandler) RenderEventHandler.getInstance()).onRenderGameOverlayPost(context, this.client, tickCounter.getTickDelta(false));
}
}