diff --git a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/BakedBlockEntityRenderer.java b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/BakedBlockEntityRenderer.java index 462919f..f96ac96 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/BakedBlockEntityRenderer.java +++ b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/BakedBlockEntityRenderer.java @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.objects.Object2ReferenceMap; import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectIterator; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap; import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; @@ -264,10 +265,13 @@ public static void render(WorldRenderContext wrc) { MatrixStack matrices = wrc.matrixStack(); matrices.push(); matrices.translate(-cam.x, -cam.y, -cam.z); - for (Map.Entry entry : regions.object2ReferenceEntrySet()) { + ObjectIterator> regionerator = regions.entrySet().iterator(); + while(regionerator.hasNext()) { + Map.Entry entry = regionerator.next(); + RenderRegionPos rrp = entry.getKey(); RegionBuffer regionBuffer = entry.getValue(); - if (isVisiblePos(entry.getKey(), cam)) { + if (isVisiblePos(rrp, cam) && rrp.origin != null) { // Iterate over used render layers in the region, render them matrices.push(); matrices.translate(rrp.origin.getX(), rrp.origin.getY(), rrp.origin.getZ()); @@ -276,7 +280,7 @@ public static void render(WorldRenderContext wrc) { matrices.pop(); } else { regionBuffer.release(); - regions.remove(rrp); + regionerator.remove(); } } RenderSystem.setShaderFogEnd(originalFogEnd);