From c299e84512548ab087c32a1cdb31d750cd6e1126 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 18 May 2021 14:41:16 -0700 Subject: [PATCH] Be lazy grabbing instance fields statically --- .../render/ContraptionRenderDispatcher.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 7f0e689ee..f8a2e942e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -59,15 +59,17 @@ import net.minecraft.world.World; import net.minecraft.world.gen.feature.template.Template; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.common.util.Lazy; public class ContraptionRenderDispatcher { - private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); - private static final BlockModelShapes BLOCK_MODELS = Minecraft.getInstance().getModelManager().getBlockModelShapes(); + private static final Lazy MODEL_RENDERER = Lazy.of(() -> new BlockModelRenderer(Minecraft.getInstance().getBlockColors())); + private static final Lazy BLOCK_MODELS = Lazy.of(() -> Minecraft.getInstance().getModelManager().getBlockModelShapes()); private static int worldHolderRefreshCounter; public static final Int2ObjectMap RENDERERS = new Int2ObjectOpenHashMap<>(); public static final Int2ObjectMap WORLD_HOLDERS = new Int2ObjectOpenHashMap<>(); public static final Compartment> CONTRAPTION = new Compartment<>(); + private static final ResourceLocation ctxRoot = new ResourceLocation("create", "context/contraption"); public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); public static final WorldContext TILES = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)); @@ -272,8 +274,8 @@ public class ContraptionRenderDispatcher { ms.push(); ms.translate(pos.getX(), pos.getY(), pos.getZ()); - MODEL_RENDERER.renderModel(renderWorld, BLOCK_MODELS.getModel(state), state, pos, ms, builder, true, - random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); + MODEL_RENDERER.get().renderModel(renderWorld, BLOCK_MODELS.get().getModel(state), state, pos, ms, builder, true, + random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); ms.pop(); } BlockModelRenderer.disableCache();