From 83d81b0a251fc7b8a841c668de1c0ef25632248e Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 10 Oct 2020 19:15:36 +0200 Subject: [PATCH] Fixed crash when attempting to render blocks with tile non-rendered entities --- .../client/render/WorldRenderDelegate.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java index c803fa54..4d710778 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java @@ -13,6 +13,7 @@ import net.minecraft.client.model.Model; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.VertexConsumerProvider; 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.EntityRenderer; import net.minecraft.client.render.entity.LivingEntityRenderer; @@ -100,23 +101,26 @@ public class WorldRenderDelegate { BlockEntity blockEntity = ve.getBlockEntity(); if (blockEntity != null) { - blockEntity.setPos(e.getBlockPos()); - matrices.push(); + BlockEntityRenderer r = BlockEntityRenderDispatcher.INSTANCE.get(blockEntity); + if (r != null) { + blockEntity.setPos(e.getBlockPos()); + matrices.push(); - BlockState state = blockEntity.getCachedState(); - Direction direction = state.contains(Properties.HORIZONTAL_FACING) ? state.get(Properties.HORIZONTAL_FACING) : Direction.UP; + BlockState state = blockEntity.getCachedState(); + Direction direction = state.contains(Properties.HORIZONTAL_FACING) ? state.get(Properties.HORIZONTAL_FACING) : Direction.UP; - matrices.translate(x, y, z); + matrices.translate(x, y, z); - matrices.multiply(direction.getRotationQuaternion()); - matrices.multiply(Vector3f.NEGATIVE_X.getDegreesQuaternion(90)); + matrices.multiply(direction.getRotationQuaternion()); + matrices.multiply(Vector3f.NEGATIVE_X.getDegreesQuaternion(90)); - 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(); - return; + matrices.pop(); + return; + } } BipedEntityModel model = getBipedModel(dispatcher, e);