Fixed crash when attempting to render blocks with tile non-rendered entities

This commit is contained in:
Sollace 2020-10-10 19:15:36 +02:00
parent 1df7f4fa40
commit 83d81b0a25

View file

@ -13,6 +13,7 @@ import net.minecraft.client.model.Model;
import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.LivingEntityRenderer; import net.minecraft.client.render.entity.LivingEntityRenderer;
@ -100,6 +101,8 @@ public class WorldRenderDelegate {
BlockEntity blockEntity = ve.getBlockEntity(); BlockEntity blockEntity = ve.getBlockEntity();
if (blockEntity != null) { if (blockEntity != null) {
BlockEntityRenderer<BlockEntity> r = BlockEntityRenderDispatcher.INSTANCE.get(blockEntity);
if (r != null) {
blockEntity.setPos(e.getBlockPos()); blockEntity.setPos(e.getBlockPos());
matrices.push(); matrices.push();
@ -113,11 +116,12 @@ public class WorldRenderDelegate {
matrices.translate(-0.5, 0, -0.5); matrices.translate(-0.5, 0, -0.5);
BlockEntityRenderDispatcher.INSTANCE.get(blockEntity).render(blockEntity, 1, matrices, vertexConsumers, light, OverlayTexture.DEFAULT_UV); r.render(blockEntity, 1, matrices, vertexConsumers, light, OverlayTexture.DEFAULT_UV);
matrices.pop(); matrices.pop();
return; return;
} }
}
BipedEntityModel<?> model = getBipedModel(dispatcher, e); BipedEntityModel<?> model = getBipedModel(dispatcher, e);