This commit is contained in:
Moulberry committed 2024-08-29 10:34:49 +08:00
1 parent d2a217509f
commit 4d8f896cdf
90 files changed
+2345 -720

No files matched your search

@@ -6,18 +6,34 @@ import com.mojang.blaze3d.pipeline.RenderTarget;
import com.moulberry.flashback.editor.ui.ReplayUI;
import net.minecraft.client.Minecraft;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL30;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(value = RenderTarget.class, priority = 1100)
public class MixinRenderTarget {
@Mixin(value = RenderTarget.class, priority = 800)
public abstract class MixinRenderTarget {
@WrapOperation(method = "_blitToScreen", at=@At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_viewport(IIII)V", remap = false))
public void blitToScreenViewport(int left, int bottom, int width, int height, Operation<Void> original) {
if ((Object)this == Minecraft.getInstance().getMainRenderTarget() && ReplayUI.shouldModifyViewport()) {
ReplayUI.setupMainViewport();
} else {
original.call(left, bottom, width, height);
@Shadow
public int frameBufferId;
@Inject(method = "blitToScreen(IIZ)V", at = @At("HEAD"), cancellable = true)
public void blitToScreenSodium(int width, int height, boolean noBlend, CallbackInfo ci) {
if ((Object)this == Minecraft.getInstance().getMainRenderTarget() && ReplayUI.isActive()) {
var window = Minecraft.getInstance().getWindow();
int frameBottom = (ReplayUI.viewportSizeY - (ReplayUI.frameY + ReplayUI.frameHeight)) * window.framebufferHeight / ReplayUI.viewportSizeY;
int frameLeft = ReplayUI.frameX * window.framebufferWidth / ReplayUI.viewportSizeX;
int frameWidth = Math.max(1, ReplayUI.frameWidth) * window.framebufferWidth / ReplayUI.viewportSizeX;
int frameHeight = Math.max(1, ReplayUI.frameHeight) * window.framebufferHeight / ReplayUI.viewportSizeY;
GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, this.frameBufferId);
GL30.glBlitFramebuffer(0, 0, width, height, frameLeft, frameBottom, frameLeft+frameWidth, frameBottom+frameHeight,
GL11.GL_COLOR_BUFFER_BIT, GL11.GL_LINEAR);
GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, 0);
ci.cancel();
}
}