From f7de909c592785b3ce984472f06f3b7f6c2ca713 Mon Sep 17 00:00:00 2001 From: makamys Date: Thu, 30 Jun 2022 14:24:26 +0200 Subject: Fix renderer trying to get created every frame that it's disabled --- src/main/java/makamys/neodymium/Neodymium.java | 14 +++++++++++--- .../java/makamys/neodymium/mixin/MixinRenderGlobal.java | 3 +-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/java/makamys/neodymium/Neodymium.java b/src/main/java/makamys/neodymium/Neodymium.java index fc036a5..8602e60 100644 --- a/src/main/java/makamys/neodymium/Neodymium.java +++ b/src/main/java/makamys/neodymium/Neodymium.java @@ -49,6 +49,8 @@ public class Neodymium public static NeoRenderer renderer; + private static World rendererWorld; + @EventHandler public void preInit(FMLConstructionEvent event) { MCLib.init(); @@ -80,8 +82,7 @@ public class Neodymium Config.reloadConfig(); } if(renderer != null) { - renderer.destroy(); - renderer = null; + destroyRenderer(); } if(Config.enabled && newWorld != null) { List warns = new ArrayList<>(); @@ -114,6 +115,7 @@ public class Neodymium renderer.hasIncompatibilities = !warns.isEmpty() || !criticalWarns.isEmpty(); } } + rendererWorld = newWorld; } @SubscribeEvent @@ -131,7 +133,7 @@ public class Neodymium } private World getRendererWorld() { - return renderer != null ? renderer.world : null; + return rendererWorld; } @SubscribeEvent @@ -205,4 +207,10 @@ public class Neodymium } } + public static void destroyRenderer() { + renderer.destroy(); + renderer = null; + rendererWorld = null; + } + } diff --git a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java index 3574868..a059e8e 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java +++ b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java @@ -40,8 +40,7 @@ abstract class MixinRenderGlobal { @Inject(method = "loadRenderers", at = @At(value = "HEAD")) public void preLoadRenderers(CallbackInfo ci) { if(Neodymium.isActive()) { - Neodymium.renderer.destroy(); - Neodymium.renderer = null; + Neodymium.destroyRenderer(); } } -- cgit