Emitting quads from block model causes crash when rendering breaking overlay
SuperMartijn642 opened this issue ยท 1 comments
Bug Description
When emitting any quad with DEFAULT ambient occlusion from FabricBlockStateModel#emitQuads when rendering the breaking overlay, this causes a crash because NonTerrainBlockRenderContext.defaultLightMode is null.
The only place defaultLightMode is set for NonTerrainBlockRenderContext is in AbstractBlockRenderContext#bufferDefaultModel. The default implementation for FabricBlockStateModel#emitQuads calls FabricBlockModelPart#emitQuads for all block model parts parts which in turn ends up calling AbstractBlockRenderContext#bufferDefaultModel.
When emitting a quad directly from FabricBlockStateModel#emitQuads (with ambient occlusion set to default), AbstractBlockRenderContext#bufferDefaultModel is never called and thus AbstractBlockRenderContext.defaultLightMode is null. This then results in a crash when calling LightPipelineProvider#getLighter with a null argument.
Reproduction Steps
Create a BlockStateModel which overwrites FabricBlockStateModel#emitQuads to emit a quad:
public class DummyBlockStateModel implements BlockStateModel {
...
@Override
public void emitQuads(QuadEmitter emitter, BlockAndTintGetter blockView, BlockPos pos, BlockState state, RandomSource random, Predicate<@Nullable Direction> cullTest){
emitter.emit();
}
}Overwrite the block model for cobblestone:
ModelLoadingPlugin.register(context -> {
context.modifyBlockModelAfterBake().register(
(model, modelContext) -> {
if(modelContext.state().is(Blocks.COBBLESTONE))
return new DummyBlockStateModel();
return model;
}
);
});Try to break a cobblestone block in survival such that it would show the block breaking overlay.
Observe that the game crashes.
Log File
Crash Report
I believe I'm getting the same issue.
Crash Logs: https://mclo.gs/VhymMgk