diff --git a/projects/common/src/client/java/dan200/computercraft/client/render/TurtleBlockEntityRenderer.java b/projects/common/src/client/java/dan200/computercraft/client/render/TurtleBlockEntityRenderer.java index c52c5a485..caf56621e 100644 --- a/projects/common/src/client/java/dan200/computercraft/client/render/TurtleBlockEntityRenderer.java +++ b/projects/common/src/client/java/dan200/computercraft/client/render/TurtleBlockEntityRenderer.java @@ -55,7 +55,7 @@ public void render(TurtleBlockEntity turtle, float partialTicks, PoseStack trans // Render the label var label = turtle.getLabel(); var hit = renderer.cameraHitResult; - if (label != null && hit.getType() == HitResult.Type.BLOCK && turtle.getBlockPos().equals(((BlockHitResult) hit).getBlockPos())) { + if (label != null && hit != null && hit.getType() == HitResult.Type.BLOCK && turtle.getBlockPos().equals(((BlockHitResult) hit).getBlockPos())) { var mc = Minecraft.getInstance(); var font = this.font; diff --git a/projects/lints/src/main/kotlin/cc/tweaked/linter/MinecraftLibraryModel.kt b/projects/lints/src/main/kotlin/cc/tweaked/linter/MinecraftLibraryModel.kt index d38c2b100..bdf50167c 100644 --- a/projects/lints/src/main/kotlin/cc/tweaked/linter/MinecraftLibraryModel.kt +++ b/projects/lints/src/main/kotlin/cc/tweaked/linter/MinecraftLibraryModel.kt @@ -7,6 +7,7 @@ package cc.tweaked.linter import com.google.common.collect.ImmutableSet import com.google.common.collect.ImmutableSetMultimap import com.uber.nullaway.LibraryModels +import com.uber.nullaway.LibraryModels.FieldRef.fieldRef import com.uber.nullaway.LibraryModels.MethodRef.methodRef /** @@ -34,4 +35,9 @@ class MinecraftLibraryModel : LibraryModels { // Reasoning about nullability of BlockEntity.getLevel() is awkward. For now, assume it's non-null. methodRef("net.minecraft.world.level.block.entity.BlockEntity", "getLevel()"), ) + + override fun nullableFields(): ImmutableSet = ImmutableSet.of( + // This inherits from Minecraft.hitResult, and so can also be null. + fieldRef("net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher", "cameraHitResult"), + ) }