Use GameRenderer.render instead of renderWorld, improves compat

In particular, Iris updates its frame counter and timer in the outer method, so
if we only call the inner one, then its shadows and sky will not update
properly.
Since the render method also renders the GUI, we set the current screen to null
and cancel the HUD during rendering. MC also clears the depth before rendering
the HUD, which we don't want because it breaks the depth map export, so we
cancel that as well.

This also allows Vanilla post-processing (aka Super Secret Settings, aka Vanilla
Shaders) as well as entity outlines to function properly cause those are applied
in that method as well.
Should have done this a long time ago but better late than never.

Closes #321
This commit is contained in:
Jonas Herzig
2021-06-29 12:39:06 +02:00
parent ed99e240ec
commit 3f2456ba65
5 changed files with 75 additions and 6 deletions

View File

@@ -0,0 +1,28 @@
package com.replaymod.render.mixin;
import com.replaymod.render.hooks.EntityRendererHandler;
import net.minecraft.client.render.GameRenderer;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(GameRenderer.class)
public abstract class Mixin_PreserveDepthDuringGuiRendering {
@ModifyArg(
//#if MC>=11700
method = "render",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;clear(IZ)V"), index = 0
//#else
//$$ method = "setupOverlayRendering",
//$$ at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;clear(I)V"), index = 0
//#endif
)
private int replayModRender_skipClearWhenRecordingDepth(int mask) {
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) this).replayModRender_getHandler();
if (handler != null && handler.getSettings().isDepthMap()) {
mask = mask & ~GL11.GL_DEPTH_BUFFER_BIT;
}
return mask;
}
}

View File

@@ -0,0 +1,23 @@
package com.replaymod.render.mixin;
import com.replaymod.render.hooks.EntityRendererHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.InGameHud;
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.CallbackInfo;
//#if MC>=11400
@Mixin(InGameHud.class)
//#else
//$$ @Mixin({ GuiIngame.class, net.minecraftforge.client.GuiIngameForge.class })
//#endif
public abstract class Mixin_SkipHudDuringRender {
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
private void replayModRender_skipHudDuringRender(CallbackInfo ci) {
if (((EntityRendererHandler.IEntityRenderer) MinecraftClient.getInstance().gameRenderer).replayModRender_getHandler() != null) {
ci.cancel();
}
}
}