aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/utils/TickDelay.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/utils/TickDelay.java')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/utils/TickDelay.java40
1 files changed, 0 insertions, 40 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/utils/TickDelay.java b/src/main/java/io/polyfrost/oneconfig/utils/TickDelay.java
deleted file mode 100644
index 0babff1..0000000
--- a/src/main/java/io/polyfrost/oneconfig/utils/TickDelay.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package io.polyfrost.oneconfig.utils;
-
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent;
-
-public class TickDelay {
- private int delay;
- private final Runnable function;
-
- public TickDelay(Runnable functionName, int ticks) {
- register();
- delay = ticks;
- function = functionName;
- }
-
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- if (event.phase == TickEvent.Phase.START) {
- // Delay expired
- if (delay < 1) {
- run();
- destroy();
- }
- delay--;
- }
- }
-
- private void destroy() {
- MinecraftForge.EVENT_BUS.unregister(this);
- }
-
- private void register() {
- MinecraftForge.EVENT_BUS.register(this);
- }
-
- private void run() {
- function.run();
- }
-}