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 de.johni0702.minecraft.gui.utils.EventRegistrations;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
//#if MC>=11500
import net.minecraft.client.util.math.MatrixStack;
@@ -65,11 +66,26 @@ public class EntityRendererHandler extends EventRegistrations implements WorldRe
//#endif
if (mc.world != null && mc.player != null) {
//#if MC>=11500
mc.gameRenderer.renderWorld(partialTicks, finishTimeNano, new MatrixStack());
//#else
//$$ mc.gameRenderer.renderWorld(partialTicks, finishTimeNano);
//#endif
Screen orgScreen = mc.currentScreen;
boolean orgPauseOnLostFocus = mc.options.pauseOnLostFocus;
try {
mc.currentScreen = null; // do not want to render the current screen (that'd just be the progress gui)
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