Fix compat with optifine shaders, again

This commit is contained in:
Jozufozu 2021-09-09 15:30:50 -07:00
parent a6377b5fe8
commit 3ef6a163f0

View file

@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import com.jozufozu.flywheel.backend.OptifineHandler;
import com.jozufozu.flywheel.event.BeginFrameEvent; import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
@ -35,6 +36,9 @@ public class BeginFrameMixin {
@Unique @Unique
private boolean setup; private boolean setup;
/**
* This version gets run by default.
*/
@Group(name = "setupRender", min = 1) @Group(name = "setupRender", min = 1)
@Inject(method = "renderLevel", @Inject(method = "renderLevel",
at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.compileChunksUntil(J)V"), at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.compileChunksUntil(J)V"),
@ -44,14 +48,20 @@ public class BeginFrameMixin {
CallbackInfo ci, // locals, only care about clippinghelper CallbackInfo ci, // locals, only care about clippinghelper
IProfiler iprofiler, Vector3d vector3d, double d0, double d1, double d2, Matrix4f matrix4f, boolean flag, IProfiler iprofiler, Vector3d vector3d, double d0, double d1, double d2, Matrix4f matrix4f, boolean flag,
ClippingHelper clippinghelper) { ClippingHelper clippinghelper) {
if (!OptifineHandler.usingShaders()) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippinghelper)); MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippinghelper));
setup = true; setup = true;
} }
}
/**
* This version gets run when optifine is installed and shaders are enabled.
*/
@Group(name = "setupRender") @Group(name = "setupRender")
@Inject(at = @At("HEAD"), method = "setupRender") @Inject(at = @At("HEAD"), method = "setupRender")
private void setupRenderOptifineCompat(ActiveRenderInfo info, ClippingHelper clippingHelper, boolean p_228437_3_, int frameCount, boolean isSpectator, CallbackInfo ci) { private void setupRender2(ActiveRenderInfo info, ClippingHelper clippingHelper, boolean p_228437_3_, int frameCount, boolean isSpectator, CallbackInfo ci) {
if (!setup) { if (!setup) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippingHelper)); MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippingHelper));
} }