Skip to content

Commit

Permalink
add layerDrawer to onRenderOverlayPost
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Sep 18, 2024
1 parent cd2cac3 commit 7d31850
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.util.profiler.Profilers;
import org.jetbrains.annotations.ApiStatus;
Expand Down Expand Up @@ -84,7 +83,7 @@ public void registerWorldLastRenderer(IRenderer renderer)
}

@ApiStatus.Internal
public void onRenderGameOverlayPost(DrawContext drawContext, MinecraftClient mc, float partialTicks, LayeredDrawer layeredDrawer)
public void onRenderGameOverlayPost(DrawContext drawContext, MinecraftClient mc, float partialTicks)
{
Profiler profiler = Profilers.get();

Expand All @@ -95,7 +94,7 @@ public void onRenderGameOverlayPost(DrawContext drawContext, MinecraftClient mc,
for (IRenderer renderer : this.overlayRenderers)
{
profiler.push(renderer.getProfilerSectionSupplier());
renderer.onRenderGameOverlayPostAdvanced(drawContext, partialTicks, layeredDrawer, profiler, mc);
renderer.onRenderGameOverlayPostAdvanced(drawContext, partialTicks, profiler, mc);
renderer.onRenderGameOverlayPost(drawContext);
profiler.pop();
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/fi/dy/masa/malilib/interfaces/IRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.function.Supplier;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.util.profiler.Profiler;
import org.joml.Matrix4f;

Expand All @@ -18,7 +17,7 @@ public interface IRenderer
/**
* Called after the vanilla overlays have been rendered, with advanced Parameters such as ticks, drawer, profiler
*/
default void onRenderGameOverlayPostAdvanced(DrawContext drawContext, float partialTicks, LayeredDrawer layeredDrawer, Profiler profiler, MinecraftClient mc) {}
default void onRenderGameOverlayPostAdvanced(DrawContext drawContext, float partialTicks, Profiler profiler, MinecraftClient mc) {}

/**
* Called after the vanilla overlays have been rendered (Original)
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/fi/dy/masa/malilib/mixin/MixinInGameHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -19,9 +20,16 @@ public abstract class MixinInGameHud
@Shadow @Final private MinecraftClient client;
@Shadow @Final private LayeredDrawer layeredDrawer;

@Inject(method = "render", at = @At("RETURN"))
private void onGameOverlayPost(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci)
@Inject(method = "<init>", at = @At("TAIL"))
private void malilib_onInit(CallbackInfo info)
{
((RenderEventHandler) RenderEventHandler.getInstance()).onRenderGameOverlayPost(context, this.client, tickCounter.getTickDelta(false), this.layeredDrawer);
this.layeredDrawer.addLayer(this::malilib_onGameOverlayPost);
}

//@Inject(method = "render", at = @At("RETURN"))
@Unique
private void malilib_onGameOverlayPost(DrawContext context, RenderTickCounter tickCounter)
{
((RenderEventHandler) RenderEventHandler.getInstance()).onRenderGameOverlayPost(context, this.client, tickCounter.getTickDelta(false));
}
}
3 changes: 1 addition & 2 deletions src/main/java/fi/dy/masa/malilib/test/TestRenderHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.block.ShulkerBoxBlock;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Fog;
import net.minecraft.client.render.Frustum;
Expand Down Expand Up @@ -42,7 +41,7 @@ public class TestRenderHandler implements IRenderer
private boolean wasHeld = false;

@Override
public void onRenderGameOverlayPostAdvanced(DrawContext drawContext, float partialTicks, LayeredDrawer layeredDrawer, Profiler profiler, MinecraftClient mc)
public void onRenderGameOverlayPostAdvanced(DrawContext drawContext, float partialTicks, Profiler profiler, MinecraftClient mc)
{
if (MaLiLibConfigs.Test.TEST_CONFIG_BOOLEAN.getBooleanValue() && GuiBase.isAltDown())
{
Expand Down

0 comments on commit 7d31850

Please sign in to comment.