From 406eaec8bd9e7ca630d1f79ffe2ddda8493778eb Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:32:03 +1000 Subject: Fix: Crash and use less forge events (#1986) --- .../java/at/hannibal2/skyhanni/api/FmlEventApi.kt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/api/FmlEventApi.kt (limited to 'src/main/java/at/hannibal2/skyhanni/api') diff --git a/src/main/java/at/hannibal2/skyhanni/api/FmlEventApi.kt b/src/main/java/at/hannibal2/skyhanni/api/FmlEventApi.kt new file mode 100644 index 000000000..7af401401 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/FmlEventApi.kt @@ -0,0 +1,23 @@ +package at.hannibal2.skyhanni.api + +import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent +import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import net.minecraftforge.event.entity.EntityJoinWorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.network.FMLNetworkEvent + +@SkyHanniModule +object FmlEventApi { + + @SubscribeEvent + fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { + ClientDisconnectEvent().postAndCatch() + } + + // TODO when we have generic events, make this support generics + @SubscribeEvent + fun onEntityJoinWorld(event: EntityJoinWorldEvent) { + EntityEnterWorldEvent(event.entity).postAndCatch() + } +} -- cgit