From 4817ce3fe157c14a4c178499e778c7e604543178 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Tue, 10 Aug 2021 17:39:11 -0700 Subject: [PATCH] Final loader and temporary ShaderSources --- .../com/jozufozu/flywheel/backend/Backend.java | 8 +------- .../com/jozufozu/flywheel/backend/Loader.java | 17 ++++++++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index 72a919218..62a3b108f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -35,9 +35,7 @@ public class Backend { return INSTANCE; } - public final Minecraft minecraft; - public ShaderSources sources; - public Loader loader; + public final Loader loader; public GLCapabilities capabilities; public GlCompat compat; @@ -52,10 +50,6 @@ public class Backend { private final Map programSpecRegistry = new HashMap<>(); protected Backend() { - // Can be null when running datagenerators due to the unfortunate time we call this - minecraft = Minecraft.getInstance(); - if (minecraft == null) return; - loader = new Loader(this); OptifineHandler.init(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/Loader.java b/src/main/java/com/jozufozu/flywheel/backend/Loader.java index bc69337b1..15efd3bcb 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Loader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Loader.java @@ -42,15 +42,18 @@ public class Loader implements ISelectiveResourceReloadListener { private static final Gson GSON = new GsonBuilder().create(); private final Backend backend; - public boolean shouldCrash; - + private boolean shouldCrash; public Loader(Backend backend) { this.backend = backend; - IResourceManager manager = backend.minecraft.getResourceManager(); - if (manager instanceof IReloadableResourceManager) { - ((IReloadableResourceManager) manager).registerReloadListener(this); + // Can be null when running datagenerators due to the unfortunate time we call this + Minecraft minecraft = Minecraft.getInstance(); + if (minecraft != null) { + IResourceManager manager = minecraft.getResourceManager(); + if (manager instanceof IReloadableResourceManager) { + ((IReloadableResourceManager) manager).registerReloadListener(this); + } } } @@ -71,11 +74,11 @@ public class Loader implements ISelectiveResourceReloadListener { ModLoader.get() .postEvent(new GatherContextEvent(backend)); - backend.sources = new ShaderSources(manager); + ShaderSources sources = new ShaderSources(manager); loadProgramSpecs(manager); - Resolver.INSTANCE.resolve(backend.sources); + Resolver.INSTANCE.resolve(sources); for (IShaderContext context : backend.allContexts()) { context.load();