aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/utils
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-27 23:54:03 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-27 23:54:03 +0200
commite968906af9435bd4a9b7a2befef1c9981dd3453a (patch)
tree9e30e2dc24bf3a821402b86bc223a38f29692ea0 /src/main/java/cc/polyfrost/oneconfig/utils
parenta4857ad657bc14009ac2d47b89c6981761d40df9 (diff)
parentf1509146f504707dfab3e9abac36038f94040b64 (diff)
downloadOneConfig-e968906af9435bd4a9b7a2befef1c9981dd3453a.tar.gz
OneConfig-e968906af9435bd4a9b7a2befef1c9981dd3453a.tar.bz2
OneConfig-e968906af9435bd4a9b7a2befef1c9981dd3453a.zip
Merge branch 'master' of github.com:Polyfrost/OneConfig
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java25
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);
- }
}