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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user