Catches any errors that occur when triggering events.

It is pretty annoying for the game to crash because of a GUI mod. This should reduce that.
This commit is contained in:
Markil3
2021-03-26 09:25:55 -06:00
parent a94b7f2929
commit b4ebd7d6a2

View File

@@ -60,6 +60,8 @@ public class EventBus
*/
@SubscribeEvent
public static void onClick(final PlayerInteractEvent event)
{
try
{
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
{
@@ -70,6 +72,14 @@ public class EventBus
TimerUtils.onClick(event.getHand(), item);
});
}
catch (Exception e)
{
LOGGER.error(
"Error in running markil3.immersive_hud.EventBus#onClick " +
"event",
e);
}
}
/**
* Run whenever the player mounts something. This brings the mount's health
@@ -82,12 +92,22 @@ public class EventBus
*/
@SubscribeEvent
public static void onMount(final EntityMountEvent event)
{
try
{
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
{
TimerUtils.resetMountHealth();
});
}
catch (Exception e)
{
LOGGER.error(
"Error in running markil3.immersive_hud.EventBus#onMount " +
"event",
e);
}
}
/**
* Run whenever a hand is rendered in 1st person. This brings the player
@@ -97,6 +117,8 @@ public class EventBus
*/
@SubscribeEvent
public static void onRenderHand(final RenderHandEvent event)
{
try
{
if (TimerUtils.onRenderHand(event.getHand(),
event.getMatrixStack(),
@@ -105,6 +127,14 @@ public class EventBus
event.setCanceled(true);
}
}
catch (Exception e)
{
LOGGER.error(
"Error in running markil3.immersive_hud" +
".EventBus#onRenderHand event",
e);
}
}
/**
* Called whenever we are drawing a part of the GUI. This is where most of
@@ -114,6 +144,8 @@ public class EventBus
*/
@SubscribeEvent
public static void onGUIDraw(final RenderGameOverlayEvent event)
{
try
{
Minecraft mc = Minecraft.getInstance();
boolean fadeIn = false;
@@ -264,4 +296,11 @@ public class EventBus
break;
}
}
catch (Exception e)
{
LOGGER.error(
"Error in running markil3.immersive_hud.EventBus#onGUIDraw event",
e);
}
}
}