Skip to content

Commit a0a9d4d

Browse files
committed
Add hard crash when render data fails to update
1 parent 52e9fb4 commit a0a9d4d

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

common/src/main/java/dev/ryanhcode/sable/sublevel/ClientSubLevel.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import dev.ryanhcode.sable.sublevel.plot.LevelPlot;
1414
import dev.ryanhcode.sable.sublevel.render.SubLevelRenderData;
1515
import dev.ryanhcode.sable.sublevel.render.dispatcher.SubLevelRenderDispatcher;
16+
import net.minecraft.CrashReport;
17+
import net.minecraft.CrashReportCategory;
18+
import net.minecraft.ReportedException;
1619
import net.minecraft.client.Minecraft;
1720
import net.minecraft.client.multiplayer.ClientLevel;
1821
import net.minecraft.core.BlockPos;
@@ -246,10 +249,17 @@ public void onRemove() {
246249
* Re-creates the render data using the current renderer.
247250
*/
248251
public void updateRenderData() {
249-
if (this.renderData != null) {
250-
this.renderData.close();
252+
try {
253+
if (this.renderData != null) {
254+
this.renderData.close();
255+
}
256+
this.renderData = SubLevelRenderDispatcher.get().createRenderData(this);
257+
} catch (final Throwable t) {
258+
final CrashReport crashreport = CrashReport.forThrowable(t, "Updating render data");
259+
final CrashReportCategory crashreportcategory = crashreport.addCategory("Render Dispatcher");
260+
crashreportcategory.setDetail("Class", () -> SubLevelRenderDispatcher.get().getClass().getName());
261+
throw new ReportedException(crashreport);
251262
}
252-
this.renderData = SubLevelRenderDispatcher.get().createRenderData(this);
253263
}
254264

255265
/**

0 commit comments

Comments
 (0)