diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java index 57d9fa089..8d94a681a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java @@ -50,13 +50,17 @@ public abstract class ContraptionRenderManager } public void beginFrame(BeginFrameEvent event) { - visible.clear(); renderInfos.int2ObjectEntrySet() .stream() .map(Map.Entry::getValue) .forEach(renderInfo -> renderInfo.beginFrame(event)); + collectVisible(); + } + + protected void collectVisible() { + visible.clear(); renderInfos.int2ObjectEntrySet() .stream() .map(Map.Entry::getValue) @@ -80,6 +84,9 @@ public abstract class ContraptionRenderManager renderInfos.clear(); } + /** + * Remove all render infos associated with dead/removed contraptions. + */ public void removeDeadRenderers() { renderInfos.values().removeIf(ContraptionRenderInfo::isDead); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java index 8bdb46d9f..3aff78682 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java @@ -80,13 +80,17 @@ public class FlwContraptionManager extends ContraptionRenderManager { - if (renderer.isDead()) { - renderer.invalidate(); - return true; - } - return false; - }); + boolean removed = renderInfos.values() + .removeIf(renderer -> { + if (renderer.isDead()) { + renderer.invalidate(); + return true; + } + return false; + }); + + // we use visible in #tick() so we have to re-evaluate it if any were removed + if (removed) collectVisible(); } @Override