aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/mixin
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-22 05:57:01 +0200
committermakamys <makamys@outlook.com>2022-06-22 05:57:15 +0200
commite44cc6847cc24f7cbfb67a2952b431bc51bf7a1e (patch)
treebfce4c849f450213496887e5f0d6a54dd7bcd36b /src/main/java/makamys/neodymium/mixin
parentbef6742c00977461daf36a56023432472e79bab5 (diff)
downloadNeodymium-e44cc6847cc24f7cbfb67a2952b431bc51bf7a1e.tar.gz
Neodymium-e44cc6847cc24f7cbfb67a2952b431bc51bf7a1e.tar.bz2
Neodymium-e44cc6847cc24f7cbfb67a2952b431bc51bf7a1e.zip
Fix memory leak
Meshes wouldn't get unloaded properly if they were never sent to the GPU, or if they are transparent.
Diffstat (limited to 'src/main/java/makamys/neodymium/mixin')
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
index fb73362..3901a7a 100644
--- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
+++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
@@ -49,6 +49,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
public boolean needsUpdate;
boolean savedDrawnStatus;
+ private boolean insideUpdateRenderer;
public List<CullableMeshCollection> chunkMeshes;
@@ -71,6 +72,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
@Inject(method = "updateRenderer", at = @At(value = "HEAD"))
private void preUpdateRenderer(CallbackInfo ci) {
saveDrawnStatus();
+ insideUpdateRenderer = true;
if(Neodymium.isActive()) {
if(needsUpdate) {
@@ -88,6 +90,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
@Inject(method = "updateRenderer", at = @At(value = "RETURN"))
private void postUpdateRenderer(CallbackInfo ci) {
notifyIfDrawnStatusChanged();
+ insideUpdateRenderer = false;
if(Neodymium.isActive()) {
if(chunkMeshes != null) {
@@ -99,7 +102,7 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
@Inject(method = "postRenderBlocks", at = @At(value = "HEAD"))
private void prePostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) {
- if(Neodymium.isActive() && !Config.disableChunkMeshes) {
+ if(insideUpdateRenderer && Neodymium.isActive() && !Config.disableChunkMeshes) {
if(chunkMeshes != null) {
chunkMeshes.add(ChunkMesh.fromTessellator(pass, WorldRenderer.class.cast(this), Tessellator.instance));
}