1.21.4: Use same render pass handling as Axiom, might fix some weirdness with Fabulous

This commit is contained in:
Moulberry committed 2025-02-11 14:58:35 +08:00
1 parent 12be917589
commit 42fbd062c5
1 file changed
+13 -1
@@ -3,7 +3,9 @@ package com.moulberry.flashback.mixin.visuals;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.framegraph.FrameGraphBuilder;
import com.mojang.blaze3d.framegraph.FramePass;
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
import com.mojang.blaze3d.resource.ResourceHandle;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.moulberry.flashback.Flashback;
@@ -34,15 +36,25 @@ public class MixinLevelRenderer {
))
public void renderLevelPost(GraphicsResourceAllocator graphicsResourceAllocator, net.minecraft.client.DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer,
Matrix4f matrix4f, Matrix4f projection, CallbackInfo ci, @Local FrameGraphBuilder frameGraphBuilder) {
if (!Flashback.isInReplay()) {
return;
}
FramePass framePass = frameGraphBuilder.addPass("flashback_mod_pass");
this.targets.main = framePass.readsAndWrites(this.targets.main);
if (this.targets.translucent != null) {
this.targets.translucent = framePass.readsAndWrites(this.targets.translucent);
}
if (this.targets.itemEntity != null) {
this.targets.itemEntity = framePass.readsAndWrites(this.targets.itemEntity);
}
if (this.targets.particles != null) {
this.targets.particles = framePass.readsAndWrites(this.targets.particles);
}
ResourceHandle<RenderTarget> resourceHandle = this.targets.main;
framePass.executes(() -> {
this.renderBuffers.bufferSource().endBatch();
resourceHandle.get().bindWrite(false); // Ensure main framebuffer is bound, for some reason this isn't the case with Fabulous in 1.21.4+
PoseStack poseStack = new PoseStack();
poseStack.mulPose(matrix4f);