diff options
author | inglettronald <inglettronald@gmail.com> | 2023-06-09 04:01:08 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-06-09 04:01:08 -0500 |
commit | b5d0d5bafddb50eaf9bd52965d0226fb3e26ee7b (patch) | |
tree | 5229398fc3285e41e4cb8143883faa568efde43c /src/main/kotlin/com | |
parent | 3a8a132dd3e3c3760d9b4fa3e2be1ea8bcb06e87 (diff) | |
download | DulkirMod-Fabric-b5d0d5bafddb50eaf9bd52965d0226fb3e26ee7b.tar.gz DulkirMod-Fabric-b5d0d5bafddb50eaf9bd52965d0226fb3e26ee7b.tar.bz2 DulkirMod-Fabric-b5d0d5bafddb50eaf9bd52965d0226fb3e26ee7b.zip |
Adding some custom events
Diffstat (limited to 'src/main/kotlin/com')
4 files changed, 35 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt index 15b449d..95e3eb2 100644 --- a/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt +++ b/src/main/kotlin/com/dulkirfabric/DulkirModFabric.kt @@ -42,6 +42,7 @@ object DulkirModFabric : ModInitializer { Registrations.registerEventListeners() Registrations.registerCommands() + Registrations.registerEvents() DulkirConfig.loadConfig() } diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index 3068b86..b221971 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -3,7 +3,14 @@ package com.dulkirfabric import com.dulkirfabric.DulkirModFabric.EVENT_BUS import com.dulkirfabric.commands.ConfigCommand import com.dulkirfabric.commands.JoinDungeonCommands +import com.dulkirfabric.events.ClientTickEvent +import com.dulkirfabric.events.ServerTickEvent import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents +import net.minecraft.server.MinecraftServer +import net.minecraft.util.profiling.jfr.event.WorldLoadFinishedEvent + /** * Collection of different mod registration stuff ran on initializing the mod. It is separated for readability @@ -33,4 +40,15 @@ object Registrations { fun registerEventListeners() { EVENT_BUS.subscribe(DulkirModFabric) } + + fun registerEvents() { + // Register Custom Tick events so we can use them like 1.8.9 forge + ServerTickEvents.START_SERVER_TICK.register( + ServerTickEvents.StartTick { _ -> EVENT_BUS.post(ServerTickEvent.get()) } + ) + ClientTickEvents.START_CLIENT_TICK.register( + ClientTickEvents.StartTick { _ -> EVENT_BUS.post(ClientTickEvent.get()) } + ) + // WorldLoadFinishedEvent + } }
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/events/ClientTickEvent.kt b/src/main/kotlin/com/dulkirfabric/events/ClientTickEvent.kt new file mode 100644 index 0000000..f24fdf7 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/events/ClientTickEvent.kt @@ -0,0 +1,8 @@ +package com.dulkirfabric.events + +object ClientTickEvent { + @JvmStatic + fun get(): ClientTickEvent { + return this + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/events/ServerTickEvent.kt b/src/main/kotlin/com/dulkirfabric/events/ServerTickEvent.kt new file mode 100644 index 0000000..e1f4d21 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/events/ServerTickEvent.kt @@ -0,0 +1,8 @@ +package com.dulkirfabric.events + +object ServerTickEvent { + @JvmStatic + fun get(): ServerTickEvent { + return this + } +}
\ No newline at end of file |