Skip to content

Commit

Permalink
1.21 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Jul 8, 2024
1 parent d89c6e4 commit 86bdd31
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import com.mojang.math.Axis;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
Expand Down Expand Up @@ -237,7 +238,7 @@ public static void setupPolyRendering(boolean enable) {
}
}

public static void drawScreen(float f, Screen screen, GuiGraphics guiGraphics) {
public static void drawScreen(DeltaTracker.Timer timer, Screen screen, GuiGraphics guiGraphics) {
Matrix4fStack posestack = RenderSystem.getModelViewStack();
posestack.pushMatrix();
posestack.identity();
Expand All @@ -256,7 +257,7 @@ public static void drawScreen(float f, Screen screen, GuiGraphics guiGraphics) {
GlStateManager.SourceFactor.ONE,
GlStateManager.DestFactor.ONE);

screen.render(guiGraphics, 0, 0, f);
screen.render(guiGraphics, 0, 0, timer.getRealtimeDeltaTicks());

RenderSystem.blendFuncSeparate(
GlStateManager.SourceFactor.SRC_ALPHA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class VRPassHelper {

private static float fovReduction = 1.0F;

public static void renderSingleView(RenderPass eye, DeltaTracker timer, boolean renderWorld) {
public static void renderSingleView(RenderPass eye, DeltaTracker.Timer timer, boolean renderWorld) {
RenderSystem.clearColor(0.0F, 0.0F, 0.0F, 1.0F);
RenderSystem.clear(16384, Minecraft.ON_OSX);
RenderSystem.enableDepthTest();
Expand Down Expand Up @@ -232,7 +232,7 @@ public static void renderSingleView(RenderPass eye, DeltaTracker timer, boolean
}
}

public static void renderAndSubmit(boolean renderLevel, long nanoTime, float actualPartialTicks) {
public static void renderAndSubmit(boolean renderLevel, DeltaTracker.Timer timer) {
// still rendering
mc.getProfiler().push("gameRenderer");

Expand Down Expand Up @@ -278,7 +278,7 @@ public static void renderAndSubmit(boolean renderLevel, long nanoTime, float act
mc.mainRenderTarget = KeyboardHandler.Framebuffer;
mc.mainRenderTarget.clear(Minecraft.ON_OSX);
mc.mainRenderTarget.bindWrite(true);
RenderHelper.drawScreen(actualPartialTicks, KeyboardHandler.UI, guiGraphics);
RenderHelper.drawScreen(timer, KeyboardHandler.UI, guiGraphics);
guiGraphics.flush();
}

Expand All @@ -287,7 +287,7 @@ public static void renderAndSubmit(boolean renderLevel, long nanoTime, float act
mc.mainRenderTarget = RadialHandler.Framebuffer;
mc.mainRenderTarget.clear(Minecraft.ON_OSX);
mc.mainRenderTarget.bindWrite(true);
RenderHelper.drawScreen(actualPartialTicks, RadialHandler.UI, guiGraphics);
RenderHelper.drawScreen(timer, RadialHandler.UI, guiGraphics);
guiGraphics.flush();
}
mc.getProfiler().pop();
Expand Down Expand Up @@ -315,7 +315,7 @@ public static void renderAndSubmit(boolean renderLevel, long nanoTime, float act
mc.getProfiler().push("setup");
mc.mainRenderTarget.bindWrite(true);
mc.getProfiler().pop();
VRPassHelper.renderSingleView(renderpass, actualPartialTicks, nanoTime, renderLevel);
VRPassHelper.renderSingleView(renderpass, timer, renderLevel);
mc.getProfiler().pop();

if (dataHolder.grabScreenShot) {
Expand Down Expand Up @@ -350,7 +350,7 @@ public static void renderAndSubmit(boolean renderLevel, long nanoTime, float act
// now we are done with rendering
mc.getProfiler().pop();

dataHolder.vrPlayer.postRender(actualPartialTicks);
dataHolder.vrPlayer.postRender(timer.getRealtimeDeltaTicks());
mc.getProfiler().push("Display/Reproject");

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.vivecraft.fabric.mixin;

import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Timer;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -17,18 +17,12 @@ public class FabricMinecraftVRMixin {

@Shadow
@Final
private Timer timer;

@Shadow
private volatile boolean pause;

@Shadow
private float pausePartialTick;
private DeltaTracker.Timer timer;

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;pop()V", ordinal = 4, shift = At.Shift.AFTER), method = "runTick", locals = LocalCapture.CAPTURE_FAILHARD)
public void vivecraft$renderVRPassesFabric(boolean renderLevel, CallbackInfo ci, long nanoTime) {
public void vivecraft$renderVRPassesFabric(boolean renderLevel, CallbackInfo ci) {
if (VRState.vrRunning) {
VRPassHelper.renderAndSubmit(renderLevel, nanoTime, this.pause ? this.pausePartialTick : this.timer.partialTick);
VRPassHelper.renderAndSubmit(renderLevel, this.timer);
}
}
}
1 change: 1 addition & 0 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set('forge_nonfunctional_without_changes')
setTargetNamespace("mojang")
}

jar {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.vivecraft.forge.mixin;

import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Timer;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -12,23 +12,17 @@
import org.vivecraft.client_vr.VRState;
import org.vivecraft.client_vr.render.helpers.VRPassHelper;

@Mixin(Minecraft.class)
@Mixin(value = Minecraft.class)
public class ForgeMinecraftVRMixin {

@Shadow
@Final
private Timer timer;
private DeltaTracker.Timer timer;

@Shadow
private volatile boolean pause;

@Shadow
private float pausePartialTick;

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/ForgeEventFactory;onRenderTickEnd(F)V", shift = At.Shift.AFTER), method = "runTick", locals = LocalCapture.CAPTURE_FAILHARD)
public void vivecraft$renderVRPassesForge(boolean renderLevel, CallbackInfo ci, long nanoTime) {
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/event/ForgeEventFactoryClient;onRenderTickEnd(Lnet/minecraft/client/DeltaTracker;)V", shift = At.Shift.AFTER), method = "runTick", locals = LocalCapture.CAPTURE_FAILHARD)
public void vivecraft$renderVRPassesForge(boolean renderLevel, CallbackInfo ci) {
if (VRState.vrRunning) {
VRPassHelper.renderAndSubmit(renderLevel, nanoTime, this.pause ? this.pausePartialTick : this.timer.partialTick);
VRPassHelper.renderAndSubmit(renderLevel, this.timer);
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ architectury_version=12.0.26
fabric_loader_version=0.15.11
fabric_api_version=0.100.1+1.21

forge_version=1.21-51.0.8
forge_version=1.21-51.0.22
neoforge_version=21.0.61-beta


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.vivecraft.neoforge.mixin;

import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Timer;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -17,18 +17,12 @@ public class NeoForgeMinecraftVRMixin {

@Shadow
@Final
private Timer timer;
private DeltaTracker.Timer timer;

@Shadow
private volatile boolean pause;

@Shadow
private float pausePartialTick;

@Inject(at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;fireRenderFramePost(F)V", shift = At.Shift.AFTER), method = "runTick", locals = LocalCapture.CAPTURE_FAILHARD)
public void vivecraft$renderVRPassesNeoForge(boolean renderLevel, CallbackInfo ci, long nanoTime) {
@Inject(at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;fireRenderFramePost(Lnet/minecraft/client/DeltaTracker;)V", shift = At.Shift.AFTER), method = "runTick", locals = LocalCapture.CAPTURE_FAILHARD)
public void vivecraft$renderVRPassesNeoForge(boolean renderLevel, CallbackInfo ci) {
if (VRState.vrRunning) {
VRPassHelper.renderAndSubmit(renderLevel, nanoTime, this.pause ? this.pausePartialTick : this.timer.partialTick);
VRPassHelper.renderAndSubmit(renderLevel, timer);
}
}
}

0 comments on commit 86bdd31

Please sign in to comment.