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

@@ -8,6 +8,7 @@ import com.replaymod.render.capturer.RenderInfo;
import com.replaymod.render.capturer.WorldRenderer; import com.replaymod.render.capturer.WorldRenderer;
import de.johni0702.minecraft.gui.utils.EventRegistrations; import de.johni0702.minecraft.gui.utils.EventRegistrations;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
//#if MC>=11500 //#if MC>=11500
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
@@ -65,11 +66,26 @@ public class EntityRendererHandler extends EventRegistrations implements WorldRe
//#endif //#endif
if (mc.world != null && mc.player != null) { if (mc.world != null && mc.player != null) {
//#if MC>=11500 Screen orgScreen = mc.currentScreen;
mc.gameRenderer.renderWorld(partialTicks, finishTimeNano, new MatrixStack()); boolean orgPauseOnLostFocus = mc.options.pauseOnLostFocus;
//#else try {
//$$ mc.gameRenderer.renderWorld(partialTicks, finishTimeNano); mc.currentScreen = null; // do not want to render the current screen (that'd just be the progress gui)
//#endif mc.options.pauseOnLostFocus = false; // do not want the pause menu to open if the window is unfocused
//#if MC>=11400
mc.gameRenderer.render(partialTicks, finishTimeNano, true);
//#else
//$$ mc.setIngameNotInFocus(); // this should already be the case but it somehow still sometimes is not
//#if MC>=10809
//$$ mc.entityRenderer.updateCameraAndRender(partialTicks, finishTimeNano);
//#else
//$$ mc.entityRenderer.updateCameraAndRender(partialTicks);
//#endif
//#endif
} finally {
mc.currentScreen = orgScreen;
mc.options.pauseOnLostFocus = orgPauseOnLostFocus;
}
} }
//#if MC>=11400 //#if MC>=11400

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();
}
}
}

View File

@@ -14,7 +14,9 @@
"Mixin_Omnidirectional_DisableFrustumCulling", "Mixin_Omnidirectional_DisableFrustumCulling",
"Mixin_Omnidirectional_Rotation", "Mixin_Omnidirectional_Rotation",
"Mixin_Omnidirectional_SkipHand", "Mixin_Omnidirectional_SkipHand",
"Mixin_PreserveDepthDuringGuiRendering",
"Mixin_SkipBlockOutlinesDuringRender", "Mixin_SkipBlockOutlinesDuringRender",
"Mixin_SkipHudDuringRender",
"Mixin_StabilizeCamera", "Mixin_StabilizeCamera",
"Mixin_Stereoscopic_Camera", "Mixin_Stereoscopic_Camera",
"Mixin_Stereoscopic_HandRenderPass", "Mixin_Stereoscopic_HandRenderPass",

View File

@@ -19,6 +19,7 @@ org.apache.maven.artifact.versioning.ComparableVersion net.minecraftforge.fml.co
org.lwjgl.glfw.GLFW com.replaymod.core.versions.GLFW org.lwjgl.glfw.GLFW com.replaymod.core.versions.GLFW
net.minecraft.client.MainWindow com.replaymod.core.versions.Window net.minecraft.client.MainWindow com.replaymod.core.versions.Window
net.minecraft.client.audio.SimpleSound net.minecraft.client.audio.PositionedSoundRecord net.minecraft.client.audio.SimpleSound net.minecraft.client.audio.PositionedSoundRecord
net.minecraft.client.gui.IngameGui net.minecraft.client.gui.GuiIngame
net.minecraft.resources.FolderPack getInputStream() getInputStreamByName() net.minecraft.resources.FolderPack getInputStream() getInputStreamByName()
net.minecraft.client.gui.GuiYesNoCallback confirmResult() confirmClicked() net.minecraft.client.gui.GuiYesNoCallback confirmResult() confirmClicked()
@@ -183,7 +184,6 @@ net.minecraft.client.gui.screen.Screen removed() onGuiClosed()
net.minecraft.client.gui.screen.Screen renderBackground() drawDefaultBackground() net.minecraft.client.gui.screen.Screen renderBackground() drawDefaultBackground()
net.minecraft.client.gui.screen.Screen renderDirtBackground() drawBackground() net.minecraft.client.gui.screen.Screen renderDirtBackground() drawBackground()
net.minecraft.client.gui.hud.ChatHud net.minecraft.client.gui.GuiNewChat net.minecraft.client.gui.hud.ChatHud net.minecraft.client.gui.GuiNewChat
net.minecraft.client.gui.hud.InGameHud net.minecraft.client.gui.GuiIngame
net.minecraft.client.GameSettings net.minecraft.client.settings.GameSettings net.minecraft.client.GameSettings net.minecraft.client.settings.GameSettings
net.minecraft.client.GameSettings debugEnabled showDebugInfo net.minecraft.client.GameSettings debugEnabled showDebugInfo
net.minecraft.client.GameSettings viewDistance renderDistanceChunks net.minecraft.client.GameSettings viewDistance renderDistanceChunks