mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-13 05:54:17 +01:00
Fix nullpointer when contraptions stop
This commit is contained in:
parent
c674b5df8d
commit
468435e1a0
@ -50,13 +50,17 @@ public abstract class ContraptionRenderManager<C extends ContraptionRenderInfo>
|
||||
}
|
||||
|
||||
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<C extends ContraptionRenderInfo>
|
||||
renderInfos.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all render infos associated with dead/removed contraptions.
|
||||
*/
|
||||
public void removeDeadRenderers() {
|
||||
renderInfos.values().removeIf(ContraptionRenderInfo::isDead);
|
||||
}
|
||||
|
@ -80,13 +80,17 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
|
||||
|
||||
@Override
|
||||
public void removeDeadRenderers() {
|
||||
renderInfos.values().removeIf(renderer -> {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user