aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-30 14:24:26 +0200
committermakamys <makamys@outlook.com>2022-06-30 16:58:13 +0200
commitf7de909c592785b3ce984472f06f3b7f6c2ca713 (patch)
treee22fbb3f6409f6e13da7782a042be573bf165d5b /src
parent4f747447be852d91ac794c9d09357cdb153cb5ff (diff)
downloadNeodymium-f7de909c592785b3ce984472f06f3b7f6c2ca713.tar.gz
Neodymium-f7de909c592785b3ce984472f06f3b7f6c2ca713.tar.bz2
Neodymium-f7de909c592785b3ce984472f06f3b7f6c2ca713.zip
Fix renderer trying to get created every frame that it's disabled
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/neodymium/Neodymium.java14
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java3
2 files changed, 12 insertions, 5 deletions
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<String> 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();
}
}