Skip to content

Commit

Permalink
Fixes maruohon#163
Browse files Browse the repository at this point in the history
 + Adjusted RenderEventHandler to be added to layeredDrawer
  • Loading branch information
EnricoMessall committed Sep 18, 2024
1 parent 0b4935c commit 28de853
Showing 1 changed file with 20 additions and 12 deletions.
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::renderChatOverwrite);
}

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

0 comments on commit 28de853

Please sign in to comment.