Skip to content

Commit 8543b46

Browse files
committed
Try not to crash the game
1 parent 5cb30ab commit 8543b46

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

Common/src/main/kotlin/gay/object/hexdebug/gui/splicing/widgets/BaseIotaButton.kt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gay.`object`.hexdebug.gui.splicing.widgets
33
import at.petrak.hexcasting.api.casting.iota.IotaType
44
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
55
import com.mojang.blaze3d.systems.RenderSystem
6+
import gay.`object`.hexdebug.HexDebug
67
import gay.`object`.hexdebug.api.client.splicing.SplicingTableIotaRenderer
78
import gay.`object`.hexdebug.api.splicing.SplicingTableIotaClientView
89
import gay.`object`.hexdebug.resources.splicing.SplicingTableIotasResourceReloadListener
@@ -35,7 +36,12 @@ abstract class BaseIotaButton(x: Int, y: Int) : HexagonButton(
3536
super.renderWidget(guiGraphics, mouseX, mouseY, partialTick)
3637
RenderSystem.disableBlend()
3738

38-
renderer.render(guiGraphics, mouseX, mouseY, partialTick)
39+
try {
40+
renderer.render(guiGraphics, mouseX, mouseY, partialTick)
41+
} catch (e: Exception) {
42+
HexDebug.LOGGER.error("Caught exception while rendering ${renderer.type.typeName().string}", e)
43+
this.renderer = null
44+
}
3945
}
4046
}
4147

@@ -53,12 +59,17 @@ abstract class BaseIotaButton(x: Int, y: Int) : HexagonButton(
5359

5460
active = true
5561

56-
renderer = iotaType
57-
?.let { SplicingTableIotasResourceReloadListener.PROVIDERS[it] }
58-
?.createRenderer(iotaType, iotaView, x, y)
59-
?: SplicingTableIotasResourceReloadListener.FALLBACK
62+
try {
63+
renderer = iotaType
64+
?.let { SplicingTableIotasResourceReloadListener.PROVIDERS[it] }
6065
?.createRenderer(iotaType, iotaView, x, y)
66+
?: SplicingTableIotasResourceReloadListener.FALLBACK
67+
?.createRenderer(iotaType, iotaView, x, y)
6168

62-
tooltip = renderer?.createTooltip()
69+
tooltip = renderer?.createTooltip()
70+
} catch (e: Exception) {
71+
HexDebug.LOGGER.error("Caught exception while preparing renderer for ${iotaType.typeName().string}", e)
72+
renderer = null
73+
}
6374
}
6475
}

0 commit comments

Comments
 (0)