From 344ea74cab8e08963ee5052dd56dde17cb4725a3 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Thu, 5 Aug 2021 14:53:22 -0700 Subject: [PATCH] Event adjustments to work with optifine shadows --- .../com/jozufozu/flywheel/core/Clipping.java | 16 ------------ .../flywheel/event/BeginFrameEvent.java | 25 +++++-------------- .../mixin/GlobalClippingHelperMixin.java | 20 --------------- .../flywheel/mixin/RenderHooksMixin.java | 9 ++++--- src/main/resources/flywheel.mixins.json | 3 +-- 5 files changed, 12 insertions(+), 61 deletions(-) delete mode 100644 src/main/java/com/jozufozu/flywheel/core/Clipping.java delete mode 100644 src/main/java/com/jozufozu/flywheel/mixin/GlobalClippingHelperMixin.java diff --git a/src/main/java/com/jozufozu/flywheel/core/Clipping.java b/src/main/java/com/jozufozu/flywheel/core/Clipping.java deleted file mode 100644 index 9f28ef46e..000000000 --- a/src/main/java/com/jozufozu/flywheel/core/Clipping.java +++ /dev/null @@ -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; -} diff --git a/src/main/java/com/jozufozu/flywheel/event/BeginFrameEvent.java b/src/main/java/com/jozufozu/flywheel/event/BeginFrameEvent.java index a4c508328..5c7006535 100644 --- a/src/main/java/com/jozufozu/flywheel/event/BeginFrameEvent.java +++ b/src/main/java/com/jozufozu/flywheel/event/BeginFrameEvent.java @@ -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(); + } } diff --git a/src/main/java/com/jozufozu/flywheel/mixin/GlobalClippingHelperMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/GlobalClippingHelperMixin.java deleted file mode 100644 index 39958bbc0..000000000 --- a/src/main/java/com/jozufozu/flywheel/mixin/GlobalClippingHelperMixin.java +++ /dev/null @@ -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 = "") - private void init(Matrix4f p_i226026_1_, Matrix4f p_i226026_2_, CallbackInfo ci) { - Clipping.HELPER = (ClippingHelper) (Object) this; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java index 80abdb73e..1203396c4 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java @@ -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)); } /** diff --git a/src/main/resources/flywheel.mixins.json b/src/main/resources/flywheel.mixins.json index 1959046f5..2c4db2153 100644 --- a/src/main/resources/flywheel.mixins.json +++ b/src/main/resources/flywheel.mixins.json @@ -18,8 +18,7 @@ "atlas.SheetDataAccessor", "light.LightUpdateMixin", "light.NetworkLightUpdateMixin", - "FastChunkProviderMixin", - "GlobalClippingHelperMixin" + "FastChunkProviderMixin" ], "injectors": { "defaultRequire": 0