From f19444e271eb150c196a3e671fa8a64d48322255 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Thu, 15 Jul 2021 11:51:57 -0700 Subject: [PATCH] Mojmixins --- .../mixin/CancelTileEntityRenderMixin.java | 2 +- .../flywheel/mixin/FixFabulousDepthMixin.java | 2 +- .../flywheel/mixin/FogColorTrackerMixin.java | 2 +- .../flywheel/mixin/RenderHooksMixin.java | 26 +++++++++---------- .../flywheel/mixin/ShaderCloseMixin.java | 6 ++--- .../mixin/StoreProjectionMatrixMixin.java | 4 +-- .../flywheel/mixin/TileRemoveMixin.java | 6 ++--- .../flywheel/mixin/TileWorldHookMixin.java | 12 ++++----- .../flywheel/mixin/atlas/AtlasDataMixin.java | 6 ++--- .../mixin/light/LightUpdateMixin.java | 2 +- .../mixin/light/NetworkLightUpdateMixin.java | 2 +- 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/mixin/CancelTileEntityRenderMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/CancelTileEntityRenderMixin.java index e26f9ef79..fbc0b5b5f 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/CancelTileEntityRenderMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/CancelTileEntityRenderMixin.java @@ -25,7 +25,7 @@ public class CancelTileEntityRenderMixin { * list of tile entities to render. By filtering the output here, we prevent the game from * doing unnecessary light lookups and frustum checks. */ - @Inject(at = @At("RETURN"), method = "getTileEntities", cancellable = true) + @Inject(at = @At("RETURN"), method = "getRenderableBlockEntities", cancellable = true) private void noRenderInstancedTiles(CallbackInfoReturnable> cir) { if (Backend.getInstance() .canUseInstancing()) { diff --git a/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java index 8c8c85077..357ec5a64 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/FixFabulousDepthMixin.java @@ -20,7 +20,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; @Mixin(WorldRenderer.class) public class FixFabulousDepthMixin { - @Inject(method = "render", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;render(F)V")) + @Inject(method = "renderLevel", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;process(F)V")) private void disableTransparencyShaderDepth(MatrixStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) { GlStateManager._depthMask(false); } diff --git a/src/main/java/com/jozufozu/flywheel/mixin/FogColorTrackerMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/FogColorTrackerMixin.java index c9326d4ae..4c901b86c 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/FogColorTrackerMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/FogColorTrackerMixin.java @@ -12,7 +12,7 @@ import com.mojang.blaze3d.platform.GlStateManager; @Mixin(GlStateManager.class) public class FogColorTrackerMixin { - @Inject(at = @At("TAIL"), method = "fog") + @Inject(at = @At("TAIL"), method = "_fog") private static void copyFogColor(int pname, float[] params, CallbackInfo ci) { if (pname == GL11.GL_FOG_COLOR) { GlFog.FOG_COLOR = params; diff --git a/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java index 4a0437c5d..f78584cf8 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java @@ -35,11 +35,11 @@ import net.minecraftforge.common.MinecraftForge; public class RenderHooksMixin { @Shadow - private ClientWorld world; + private ClientWorld level; - @Inject(at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.updateChunks(J)V"), method = "render") + @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(world, stack, info, gameRenderer, lightTexture)); + MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, stack, info, gameRenderer, lightTexture)); } /** @@ -47,7 +47,7 @@ public class RenderHooksMixin { * layer-correct custom rendering. RenderWorldLast is not refined enough for rendering world objects. * This should probably be a forge event. */ - @Inject(at = @At("TAIL"), method = "renderLayer") + @Inject(at = @At("TAIL"), method = "renderChunkLayer") private void renderLayer(RenderType type, MatrixStack stack, double camX, double camY, double camZ, CallbackInfo ci) { Matrix4f view = stack.last() .pose(); @@ -55,22 +55,22 @@ public class RenderHooksMixin { viewProjection.multiplyBackward(Backend.getInstance() .getProjectionMatrix()); - MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(world, type, viewProjection, camX, camY, camZ)); + MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(level, type, viewProjection, camX, camY, camZ)); if (!OptifineHandler.usingShaders()) GL20.glUseProgram(0); } - @Inject(at = @At("TAIL"), method = "loadRenderers") + @Inject(at = @At("TAIL"), method = "allChanged") private void refresh(CallbackInfo ci) { Backend.getInstance() .refresh(); - MinecraftForge.EVENT_BUS.post(new ReloadRenderersEvent(world)); + MinecraftForge.EVENT_BUS.post(new ReloadRenderersEvent(level)); } - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;checkEmpty(Lcom/mojang/blaze3d/matrix/MatrixStack;)V", ordinal = 2 // after the game renders the breaking overlay normally - ), method = "render") + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;checkPoseStack(Lcom/mojang/blaze3d/matrix/MatrixStack;)V", ordinal = 2 // after the game renders the breaking overlay normally + ), method = "renderLevel") private void renderBlockBreaking(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) { if (!Backend.getInstance() .available()) return; @@ -82,16 +82,16 @@ public class RenderHooksMixin { .getProjectionMatrix()); Vector3d cameraPos = info.getPosition(); - CrumblingRenderer.renderBreaking(world, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z); + CrumblingRenderer.renderBreaking(level, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z); if (!OptifineHandler.usingShaders()) GL20.glUseProgram(0); } // Instancing - @Inject(at = @At("TAIL"), method = "scheduleBlockRerenderIfNeeded") + @Inject(at = @At("TAIL"), method = "setBlockDirty(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)V") private void checkUpdate(BlockPos pos, BlockState lastState, BlockState newState, CallbackInfo ci) { - InstancedRenderDispatcher.getTiles(world) - .update(world.getBlockEntity(pos)); + InstancedRenderDispatcher.getTiles(level) + .update(level.getBlockEntity(pos)); } } diff --git a/src/main/java/com/jozufozu/flywheel/mixin/ShaderCloseMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/ShaderCloseMixin.java index ab25c9670..76cdbd04f 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/ShaderCloseMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/ShaderCloseMixin.java @@ -19,12 +19,12 @@ public class ShaderCloseMixin { @Shadow @Nullable - public Screen currentScreen; + public Screen screen; - @Inject(at = @At("HEAD"), method = "displayGuiScreen") + @Inject(at = @At("HEAD"), method = "setScreen") private void whenScreenChanges(Screen screen, CallbackInfo info) { if (OptifineHandler.optifineInstalled() && screen instanceof VideoSettingsScreen) { - Screen old = this.currentScreen; + Screen old = this.screen; if (old != null && old.getClass() .getName() .startsWith(OptifineHandler.SHADER_PACKAGE)) { diff --git a/src/main/java/com/jozufozu/flywheel/mixin/StoreProjectionMatrixMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/StoreProjectionMatrixMixin.java index ccefbfb51..54059dae3 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/StoreProjectionMatrixMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/StoreProjectionMatrixMixin.java @@ -22,12 +22,12 @@ public abstract class StoreProjectionMatrixMixin { * We only want to copy the projection matrix if it is going to be used to render the world. * We don't care about the mat for your hand. */ - @Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;loadProjectionMatrix(Lnet/minecraft/util/math/vector/Matrix4f;)V")) + @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lnet/minecraft/util/math/vector/Matrix4f;)V")) private void projectionMatrixReady(float p_228378_1_, long p_228378_2_, MatrixStack p_228378_4_, CallbackInfo ci) { shouldCopy = true; } - @Inject(method = "loadProjectionMatrix", at = @At("TAIL")) + @Inject(method = "resetProjectionMatrix", at = @At("TAIL")) private void onProjectionMatrixLoad(Matrix4f projection, CallbackInfo ci) { if (shouldCopy) { Backend.getInstance() diff --git a/src/main/java/com/jozufozu/flywheel/mixin/TileRemoveMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/TileRemoveMixin.java index ffc1810c8..61e9afe53 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/TileRemoveMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/TileRemoveMixin.java @@ -19,11 +19,11 @@ public class TileRemoveMixin { @Shadow @Nullable - protected World world; + protected World level; - @Inject(at = @At("TAIL"), method = "remove") + @Inject(at = @At("TAIL"), method = "setRemoved") private void onRemove(CallbackInfo ci) { - if (world instanceof ClientWorld) InstancedRenderDispatcher.getTiles(this.world) + if (level instanceof ClientWorld) InstancedRenderDispatcher.getTiles(this.level) .remove((TileEntity) (Object) this); } } diff --git a/src/main/java/com/jozufozu/flywheel/mixin/TileWorldHookMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/TileWorldHookMixin.java index 071709622..49762dc64 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/TileWorldHookMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/TileWorldHookMixin.java @@ -26,15 +26,15 @@ public class TileWorldHookMixin { @Shadow @Final - public boolean isRemote; + public boolean isClientSide; @Shadow @Final - protected Set tileEntitiesToBeRemoved; + protected Set blockEntitiesToUnload; - @Inject(at = @At("TAIL"), method = "addTileEntity") + @Inject(at = @At("TAIL"), method = "addBlockEntity") private void onAddTile(TileEntity te, CallbackInfoReturnable cir) { - if (isRemote) { + if (isClientSide) { InstancedRenderDispatcher.getTiles(self) .queueAdd(te); } @@ -45,9 +45,9 @@ public class TileWorldHookMixin { */ @Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities") private void onChunkUnload(CallbackInfo ci) { - if (isRemote) { + if (isClientSide) { InstanceManager kineticRenderer = InstancedRenderDispatcher.getTiles(self); - for (TileEntity tile : tileEntitiesToBeRemoved) { + for (TileEntity tile : blockEntitiesToUnload) { kineticRenderer.remove(tile); } } diff --git a/src/main/java/com/jozufozu/flywheel/mixin/atlas/AtlasDataMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/atlas/AtlasDataMixin.java index d458c21f3..76d13a3a8 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/atlas/AtlasDataMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/atlas/AtlasDataMixin.java @@ -19,14 +19,14 @@ import net.minecraft.util.ResourceLocation; public abstract class AtlasDataMixin { @Shadow - public abstract ResourceLocation getId(); + public abstract ResourceLocation location(); - @Inject(method = "stitch", at = @At("RETURN")) + @Inject(method = "prepareToStitch", at = @At("RETURN")) public void stealAtlasData(IResourceManager resourceManager, Stream locationStream, IProfiler profiler, int mipMapLevels, CallbackInfoReturnable cir) { AtlasTexture.SheetData value = cir.getReturnValue(); SheetDataAccessor dataAccessor = (SheetDataAccessor) value; - AtlasInfo.setAtlasData(getId(), dataAccessor); + AtlasInfo.setAtlasData(location(), dataAccessor); } } diff --git a/src/main/java/com/jozufozu/flywheel/mixin/light/LightUpdateMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/light/LightUpdateMixin.java index ebcc79d40..0c40a62ab 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/light/LightUpdateMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/light/LightUpdateMixin.java @@ -33,7 +33,7 @@ public abstract class LightUpdateMixin extends AbstractChunkProvider { * the rendering system that it needs to redraw a chunk. It does all that work asynchronously, * and we should too. */ - @Inject(at = @At("HEAD"), method = "markLightChanged") + @Inject(at = @At("HEAD"), method = "onLightUpdate") private void onLightUpdate(LightType type, SectionPos pos, CallbackInfo ci) { ClientChunkProvider thi = ((ClientChunkProvider) (Object) this); ClientWorld world = (ClientWorld) thi.getLevel(); diff --git a/src/main/java/com/jozufozu/flywheel/mixin/light/NetworkLightUpdateMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/light/NetworkLightUpdateMixin.java index 4f81a37e7..cc9596070 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/light/NetworkLightUpdateMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/light/NetworkLightUpdateMixin.java @@ -24,7 +24,7 @@ import net.minecraft.world.chunk.Chunk; @Mixin(ClientPlayNetHandler.class) public class NetworkLightUpdateMixin { - @Inject(at = @At("TAIL"), method = "handleUpdateLight") + @Inject(at = @At("TAIL"), method = "handleLightUpdatePacked") private void onLightPacket(SUpdateLightPacket packet, CallbackInfo ci) { RenderWork.enqueue(() -> { ClientWorld world = Minecraft.getInstance().level;