Fix compat with optifine shaders, again

This commit is contained in:
Jozufozu 2021-09-09 15:30:50 -07:00
parent 98823e3cf1
commit b706936be1

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.LocalCapture;
import com.jozufozu.flywheel.backend.OptifineHandler;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.mojang.blaze3d.matrix.MatrixStack;
@ -35,6 +36,9 @@ public class BeginFrameMixin {
@Unique
private boolean setup;
/**
* This version gets run by default.
*/
@Group(name = "setupRender", min = 1)
@Inject(method = "renderLevel",
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
IProfiler iprofiler, Vector3d vector3d, double d0, double d1, double d2, Matrix4f matrix4f, boolean flag,
ClippingHelper clippinghelper) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippinghelper));
setup = true;
if (!OptifineHandler.usingShaders()) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippinghelper));
setup = true;
}
}
/**
* This version gets run when optifine is installed and shaders are enabled.
*/
@Group(name = "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) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippingHelper));
}