Skip to content

Commit

Permalink
Clean up skull rendering, fixing potential crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Nov 17, 2023
1 parent 702b764 commit 18f30c0
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ private double internalDistToCenterSqr(BlockPos pos, double d, double e, double
private static void renderSkull(Direction direction, float f, float g, PoseStack poseStack,
MultiBufferSource multiBufferSource, int i, SkullModelBase skullModelBase, RenderType renderType,
CallbackInfo ci) {
if (skullModelBase instanceof SkullModelAccessor) {
if (lastSkull != null && skullModelBase instanceof SkullModelAccessor) {
Mesh mesh = lastSkull.getHeadLayers();
SkullModelAccessor accessor = (SkullModelAccessor) skullModelBase;
if (!renderNext) {
if (!renderNext || mesh == null) {
accessor.showHat(true);
lastSkull = null;
return;
Expand All @@ -91,10 +92,9 @@ private static void renderSkull(Direction direction, float f, float g, PoseStack
poseStack.scale(-1.0F, -1.0F, 1.0F);
float voxelSize = SkinLayersModBase.config.skullVoxelSize;
poseStack.scale(voxelSize, voxelSize, voxelSize);
Mesh mesh = lastSkull.getHeadLayers();
mesh.setPosition(0, -0.25f, 0);
mesh.setRotation(0, f * 0.017453292F, 0);
lastSkull.getHeadLayers().render(poseStack, multiBufferSource.getBuffer(renderType), i,
mesh.render(poseStack, multiBufferSource.getBuffer(renderType), i,
OverlayTexture.NO_OVERLAY);
poseStack.popPose();
renderNext = false;
Expand Down

0 comments on commit 18f30c0

Please sign in to comment.