aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/utils
diff options
context:
space:
mode:
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);
- }
}