diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 580cedf9e..f4c4d6a01 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -25,7 +25,7 @@ import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.LeftClickPacket; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.RenderWork; +import com.simibubi.create.foundation.render.backend.RenderWork; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.tileEntity.behaviour.edgeInteraction.EdgeInteractionRenderer; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderInLayerMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java similarity index 74% rename from src/main/java/com/simibubi/create/foundation/mixin/RenderInLayerMixin.java rename to src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index d0fcb46ba..0014fea7c 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderInLayerMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -1,6 +1,7 @@ package com.simibubi.create.foundation.mixin; import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.backend.Backend; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; @@ -8,17 +9,25 @@ import com.simibubi.create.foundation.render.backend.OptifineHandler; import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.lwjgl.opengl.GL20; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.Set; + @OnlyIn(Dist.CLIENT) @Mixin(WorldRenderer.class) -public class RenderInLayerMixin { +public class RenderHooksMixin { + + @Shadow private ClientWorld world; /** * JUSTIFICATION: This method is called once per layer per frame. It allows us to perform @@ -43,4 +52,14 @@ public class RenderInLayerMixin { GL20.glUseProgram(0); } + + @Inject(at = @At(value = "TAIL"), method = "loadRenderers") + private void refresh(CallbackInfo ci) { + CreateClient.kineticRenderer.invalidate(); + ContraptionRenderDispatcher.invalidateAll(); + OptifineHandler.refresh(); + Backend.refresh(); + + if (world != null) world.loadedTileEntityList.forEach(CreateClient.kineticRenderer::add); + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/BufferedModel.java b/src/main/java/com/simibubi/create/foundation/render/backend/BufferedModel.java index 2e8c90e72..d209fd857 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/BufferedModel.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/BufferedModel.java @@ -1,6 +1,5 @@ package com.simibubi.create.foundation.render.backend; -import com.simibubi.create.foundation.render.RenderWork; import com.simibubi.create.foundation.render.TemplateBuffer; import com.simibubi.create.foundation.render.backend.gl.GlPrimitiveType; import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java b/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java index 883ee29bd..e5f40c872 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java @@ -5,16 +5,10 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.schematics.SchematicWorld; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; -import com.simibubi.create.foundation.render.RenderWork; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.OptifineHandler; -import com.simibubi.create.foundation.render.backend.light.ILightListener; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.WorldAttached; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.multiplayer.ClientChunkProvider; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderType; @@ -23,14 +17,8 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.potion.Effects; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.SectionPos; -import net.minecraft.world.ILightReader; -import net.minecraft.world.LightType; import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL20; -import org.lwjgl.system.CallbackI; import javax.annotation.Nullable; import java.util.ArrayList; @@ -93,14 +81,7 @@ public class FastRenderDispatcher { } public static void refresh() { - RenderWork.enqueue(() -> { - CreateClient.kineticRenderer.invalidate(); - OptifineHandler.refresh(); - Backend.refresh(); - Minecraft.getInstance().worldRenderer.loadRenderers(); - ClientWorld world = Minecraft.getInstance().world; - if (world != null) world.loadedTileEntityList.forEach(CreateClient.kineticRenderer::add); - }); + RenderWork.enqueue(Minecraft.getInstance().worldRenderer::loadRenderers); } private static void runQueue(@Nullable ConcurrentHashMap.KeySetView changed, Consumer action) { diff --git a/src/main/java/com/simibubi/create/foundation/render/RenderWork.java b/src/main/java/com/simibubi/create/foundation/render/backend/RenderWork.java similarity index 89% rename from src/main/java/com/simibubi/create/foundation/render/RenderWork.java rename to src/main/java/com/simibubi/create/foundation/render/backend/RenderWork.java index 6fc1fd6cb..5a44845f6 100644 --- a/src/main/java/com/simibubi/create/foundation/render/RenderWork.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/RenderWork.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render; +package com.simibubi.create.foundation.render.backend; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolume.java b/src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolume.java index 8dd0bc5ab..94c2e5ac5 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolume.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolume.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.render.backend.light; -import com.simibubi.create.foundation.render.RenderWork; +import com.simibubi.create.foundation.render.backend.RenderWork; import com.simibubi.create.foundation.render.backend.gl.GlTexture; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.SectionPos; diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index 4f171a769..ad05fd38b 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -3,7 +3,7 @@ "package": "com.simibubi.create.foundation.mixin", "compatibilityLevel": "JAVA_8", "refmap": "create.refmap.json", - "client": ["OnRemoveTileMixin", "ShaderCloseMixin", "CancelTileEntityRenderMixin", "LightUpdateMixin", "RenderInLayerMixin"], + "client": ["OnRemoveTileMixin", "ShaderCloseMixin", "CancelTileEntityRenderMixin", "LightUpdateMixin", "RenderHooksMixin"], "injectors": { "defaultRequire": 1 },