Event adjustments to work with optifine shadows

This commit is contained in:
Jozufozu 2021-08-05 14:53:22 -07:00
parent 6a881b17b3
commit 344ea74cab
5 changed files with 12 additions and 61 deletions

View File

@ -1,16 +0,0 @@
package com.jozufozu.flywheel.core;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.renderer.culling.ClippingHelper;
/**
* Used to capture the ClippingHelper from WorldRenderer#renderLevel
*/
public class Clipping {
/**
* Assigned in {@link com.jozufozu.flywheel.mixin.GlobalClippingHelperMixin this} mixin.
*/
public static ClippingHelper HELPER;
}

View File

@ -7,22 +7,17 @@ import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.culling.ClippingHelper;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.eventbus.api.Event;
public class BeginFrameEvent extends Event {
private final ClientWorld world;
private final MatrixStack stack;
private final ActiveRenderInfo info;
private final GameRenderer gameRenderer;
private final LightTexture lightTexture;
private final ClippingHelper clippingHelper;
public BeginFrameEvent(ClientWorld world, MatrixStack stack, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, ClippingHelper clippingHelper) {
public BeginFrameEvent(ClientWorld world, ActiveRenderInfo info, ClippingHelper clippingHelper) {
this.world = world;
this.stack = stack;
this.info = info;
this.gameRenderer = gameRenderer;
this.lightTexture = lightTexture;
this.clippingHelper = clippingHelper;
}
@ -30,23 +25,15 @@ public class BeginFrameEvent extends Event {
return world;
}
public MatrixStack getStack() {
return stack;
}
public ActiveRenderInfo getInfo() {
return info;
}
public GameRenderer getGameRenderer() {
return gameRenderer;
}
public LightTexture getLightTexture() {
return lightTexture;
}
public ClippingHelper getClippingHelper() {
return clippingHelper;
}
public Vector3d getCameraPos() {
return info.getPosition();
}
}

View File

@ -1,20 +0,0 @@
package com.jozufozu.flywheel.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.jozufozu.flywheel.core.Clipping;
import net.minecraft.client.renderer.culling.ClippingHelper;
import net.minecraft.util.math.vector.Matrix4f;
@Mixin(ClippingHelper.class)
public class GlobalClippingHelperMixin {
@Inject(at = @At("TAIL"), method = "<init>")
private void init(Matrix4f p_i226026_1_, Matrix4f p_i226026_2_, CallbackInfo ci) {
Clipping.HELPER = (ClippingHelper) (Object) this;
}
}

View File

@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.OptifineHandler;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.jozufozu.flywheel.core.Clipping;
import com.jozufozu.flywheel.core.EventCaptures;
import com.jozufozu.flywheel.core.crumbling.CrumblingRenderer;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
@ -25,6 +25,7 @@ import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeBuffers;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.culling.ClippingHelper;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Matrix4f;
@ -44,9 +45,9 @@ public class RenderHooksMixin {
@Final
private RenderTypeBuffers renderBuffers;
@Inject(at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.compileChunksUntil(J)V"), method = "renderLevel")
private void setupFrame(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projection, CallbackInfo ci) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, stack, info, gameRenderer, lightTexture, Clipping.HELPER));
@Inject(at = @At("HEAD"), method = "setupRender")
private void setupRender(ActiveRenderInfo info, ClippingHelper clippingHelper, boolean p_228437_3_, int frameCount, boolean isSpectator, CallbackInfo ci) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippingHelper));
}
/**

View File

@ -18,8 +18,7 @@
"atlas.SheetDataAccessor",
"light.LightUpdateMixin",
"light.NetworkLightUpdateMixin",
"FastChunkProviderMixin",
"GlobalClippingHelperMixin"
"FastChunkProviderMixin"
],
"injectors": {
"defaultRequire": 0