blob: 9692ce7eba8da33f3267b06ba19cf368aadf8be8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package eu.olli.cowlection.util;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
public class TickDelay {
private Runnable task;
private int waitingTicks;
public TickDelay(Runnable task, int ticks) {
this.task = task;
this.waitingTicks = ticks;
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent e) {
if (e.phase == TickEvent.Phase.START) {
if (waitingTicks < 1) {
// we're done waiting! Do stuff and exit.
task.run();
MinecraftForge.EVENT_BUS.unregister(this);
}
waitingTicks--;
}
}
}
|