diff options
| author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-27 23:39:11 +0700 |
|---|---|---|
| committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-27 23:39:11 +0700 |
| commit | f1509146f504707dfab3e9abac36038f94040b64 (patch) | |
| tree | c1bc7b68627aa43692ba732a75841ef545afa61f /src/main/java/cc/polyfrost/oneconfig/utils | |
| parent | 358d5ca1a93b07003c5f45c30364de27a7fc101d (diff) | |
| download | OneConfig-f1509146f504707dfab3e9abac36038f94040b64.tar.gz OneConfig-f1509146f504707dfab3e9abac36038f94040b64.tar.bz2 OneConfig-f1509146f504707dfab3e9abac36038f94040b64.zip | |
universal events
add mixinextras and keventbus
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils')
| -rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java index 08f5fce..2fa2017 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java @@ -1,36 +1,29 @@ package cc.polyfrost.oneconfig.utils; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.Stage; +import cc.polyfrost.oneconfig.events.event.TickEvent; +import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; public class TickDelay { private int delay; private final Runnable function; public TickDelay(Runnable functionName, int ticks) { - register(); + EventManager.INSTANCE.getEventBus().register(this); delay = ticks; function = functionName; } - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent event) { - if (event.phase == TickEvent.Phase.START) { + @Subscribe + public void onTick(TickEvent event) { + if (event.stage == Stage.START) { // Delay expired if (delay < 1) { function.run(); - destroy(); + EventManager.INSTANCE.getEventBus().unregister(this); } delay--; } } - - private void destroy() { - MinecraftForge.EVENT_BUS.unregister(this); - } - - private void register() { - MinecraftForge.EVENT_BUS.register(this); - } } |
