Modern Industrialization

Modern Industrialization

4M Downloads

`PipeColorProvider` errors when world argument is `null`

SuperMartijn642 opened this issue ยท 0 comments

commented

The BlockColor#getColor method takes 4 arguments, 2 of these are marked @Nullable which includes the world (BlockAndTintGetter) argument. This can indeed be null, for example when called from inside the BlockRenderDispatcher#renderSingleBlock method which doesn't take a world argument.

The implementation of BlockColor#getColor in PipeColorProvider simply calls BlockAndTintGetter#getBlockEntity on the world argument without a null check. Whenever the world argument is null, this leads to a null pointer exception.

@Override
public int getColor(BlockState state, BlockAndTintGetter world, BlockPos pos, int tintIndex) {
if (world.getBlockEntity(pos) instanceof PipeBlockEntity) {
PipeBlockEntity entity = (PipeBlockEntity) world.getBlockEntity(pos);

In my mod Entangled I happen to use BlockRenderDispatcher#renderSingleBlock to render other blocks in the world. When the rendered block is a pipe from Modern Industrialization, this leads to a crash.
Original issue here: SuperMartijn642/Entangled#61