diff options
author | makamys <makamys@outlook.com> | 2021-06-04 22:21:18 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-06-04 22:21:18 +0200 |
commit | 2c2f34cb235f8959323505232d4e441233df0cbe (patch) | |
tree | 9253e859a3d5f55a83197f9d2194520f685d902d | |
parent | 81696d7b3dfae030d10672d38eb5b28049733cd5 (diff) | |
download | Neodymium-2c2f34cb235f8959323505232d4e441233df0cbe.tar.gz Neodymium-2c2f34cb235f8959323505232d4e441233df0cbe.tar.bz2 Neodymium-2c2f34cb235f8959323505232d4e441233df0cbe.zip |
Make WorldRenderer safer
I got NPEs here, this should fix it
-rw-r--r-- | src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java b/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java index 112c97c..2ec3365 100644 --- a/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java +++ b/src/main/java/makamys/lodmod/mixin/MixinWorldRenderer.java @@ -50,7 +50,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer { @Shadow public boolean needsUpdate; - public List<ChunkMesh> chunkMeshes = new ArrayList<>(); + public List<ChunkMesh> chunkMeshes; @Redirect(method = "setPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/Render;renderAABB(Lnet/minecraft/util/AxisAlignedBB;)V")) private void redirectRenderAABB(AxisAlignedBB p1) { @@ -72,7 +72,11 @@ abstract class MixinWorldRenderer implements IWorldRenderer { private void preUpdateRenderer(CallbackInfo ci) { if(LODMod.isActive()) { if(needsUpdate) { - chunkMeshes.clear(); + if(chunkMeshes != null) { + chunkMeshes.clear(); + } else { + chunkMeshes = new ArrayList<>(); + } } else { chunkMeshes = null; } @@ -92,7 +96,9 @@ abstract class MixinWorldRenderer implements IWorldRenderer { @Inject(method = "postRenderBlocks", at = @At(value = "HEAD")) private void prePostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) { if(LODMod.isActive() && !LODMod.renderer.disableChunkMeshes) { - chunkMeshes.add(((ITessellator)Tessellator.instance).toChunkMesh(pass)); + if(chunkMeshes != null) { + chunkMeshes.add(((ITessellator)Tessellator.instance).toChunkMesh(pass)); + } } } |