Skip to content

Commit 2a3d963

Browse files
committed
Don't crash the cull thread on entities without renderer. Fix #269
1 parent 297011a commit 2a3d963

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/main/java/dev/tr7zw/entityculling/CullTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private void cullEntities(Vec3 cameraMC, Vec3d camera) {
125125
continue;
126126
}
127127
AABB boundingBox = NMSCullingHelper.getCullingBox(entity);
128-
if (boundingBox.getXsize() > hitboxLimit || boundingBox.getYsize() > hitboxLimit
128+
if (boundingBox == null || boundingBox.getXsize() > hitboxLimit || boundingBox.getYsize() > hitboxLimit
129129
|| boundingBox.getZsize() > hitboxLimit) {
130130
cullable.setCulled(false); // To big to bother to cull
131131
continue;

src/main/java/dev/tr7zw/entityculling/NMSCullingHelper.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ public static boolean ignoresCulling(Entity entity) {
1919
/*
2020
return entity.noCulling;
2121
*///? } else {
22-
23-
return ((EntityRendererInter<Entity>) MC.getEntityRenderDispatcher().getRenderer(entity))
22+
var renderer = MC.getEntityRenderDispatcher().getRenderer(entity);
23+
if (renderer == null) {
24+
return true;
25+
}
26+
return ((EntityRendererInter<Entity>) renderer)
2427
.entityCullingIgnoresCulling(entity);
2528
//? }
2629
}
@@ -35,8 +38,11 @@ public static AABB getCullingBox(Entity entity) {
3538
/*
3639
return entity.getBoundingBoxForCulling();
3740
*///? } else {
38-
39-
return ((EntityRendererInter<Entity>) MC.getEntityRenderDispatcher().getRenderer(entity))
41+
var renderer = MC.getEntityRenderDispatcher().getRenderer(entity);
42+
if (renderer == null) {
43+
return null;
44+
}
45+
return ((EntityRendererInter<Entity>) renderer)
4046
.entityCullingGetCullingBox(entity);
4147
//? }
4248
}

0 commit comments

Comments
 (0)