Expose ClippingHelper in BeginFrameEvent

This commit is contained in:
Jozufozu 2021-07-28 18:13:47 -07:00
parent eded055be8
commit 21269e9dd5
5 changed files with 48 additions and 3 deletions

View file

@ -0,0 +1,16 @@
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

@ -5,6 +5,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.ActiveRenderInfo;
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.minecraftforge.eventbus.api.Event;
@ -14,13 +15,15 @@ public class BeginFrameEvent extends Event {
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) {
public BeginFrameEvent(ClientWorld world, MatrixStack stack, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, ClippingHelper clippingHelper) {
this.world = world;
this.stack = stack;
this.info = info;
this.gameRenderer = gameRenderer;
this.lightTexture = lightTexture;
this.clippingHelper = clippingHelper;
}
public ClientWorld getWorld() {
@ -42,4 +45,8 @@ public class BeginFrameEvent extends Event {
public LightTexture getLightTexture() {
return lightTexture;
}
public ClippingHelper getClippingHelper() {
return clippingHelper;
}
}

View file

@ -0,0 +1,20 @@
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,6 +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.crumbling.CrumblingRenderer;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
@ -45,7 +46,7 @@ public class RenderHooksMixin {
@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 p_228426_9_, CallbackInfo ci) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, stack, info, gameRenderer, lightTexture));
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, stack, info, gameRenderer, lightTexture, Clipping.HELPER));
}
/**

View file

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