Optimize lighting checks

Also
- Set null layer after rendering contraption
This commit is contained in:
PepperBell 2021-05-14 17:23:10 -07:00
parent 6c1c7a10d9
commit dac9010f20
2 changed files with 8 additions and 3 deletions

View file

@ -175,20 +175,22 @@ public class RenderedContraption {
for (Template.BlockInfo info : c.getBlocks()
.values())
renderWorld.setBlockState(info.pos, info.state);
// Skip individual lighting updates to prevent lag with large contraptions
renderWorld.setBlockState(info.pos, info.state, 128);
renderWorld.updateLightSources();
renderWorld.lighter.tick(Integer.MAX_VALUE, false, false);
return renderWorld;
}
private static BufferBuilder buildStructure(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) {
ForgeHooksClient.setRenderLayer(layer);
MatrixStack ms = new MatrixStack();
Random random = new Random();
BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize());
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
ForgeHooksClient.setRenderLayer(layer);
BlockModelRenderer.enableCache();
for (Template.BlockInfo info : c.getBlocks()
.values()) {
@ -208,6 +210,7 @@ public class RenderedContraption {
ms.pop();
}
BlockModelRenderer.disableCache();
ForgeHooksClient.setRenderLayer(null);
builder.finishDrawing();
return builder;

View file

@ -73,7 +73,9 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW
lighter.updateSectionStatus(sectionPos, false);
}
lighter.checkBlock(pos);
if ((flags & 128) == 0) {
lighter.checkBlock(pos);
}
return true;
}